diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index a3b320f37..86b72f0b9 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -19,27 +19,18 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.head_ref || github.ref_name }} - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - - name: Check PHP Version - run: php -v - - name: Validate composer.json and composer.lock run: composer validate --strict - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v3 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- - - name: Install dependencies run: composer install --prefer-dist --no-progress @@ -47,4 +38,4 @@ jobs: run: php -dxdebug.mode=coverage vendor/bin/phpunit --coverage-clover coverage.xml - name: Push coverage report - run: bash <(curl -s https://codecov.io/bash) + uses: codecov/codecov-action@v2 diff --git a/src/qtism/cli/Cli.php b/src/qtism/cli/Cli.php index 1d2e0f1ad..b6947a799 100644 --- a/src/qtism/cli/Cli.php +++ b/src/qtism/cli/Cli.php @@ -59,7 +59,7 @@ abstract class Cli * * @var int */ - const EXIT_SUCCESS = 0; + public const EXIT_SUCCESS = 0; /** * POSIX generic exit status (1). @@ -69,7 +69,7 @@ abstract class Cli * * @var int */ - const EXIT_FAILURE = 1; + public const EXIT_FAILURE = 1; /** * An Arguments object (from php-cli-tools) representing the input @@ -83,7 +83,7 @@ abstract class Cli /** * Main CLI entry point. */ - public static function main() + public static function main(): void { $cli = new static(); @@ -122,7 +122,7 @@ abstract protected function run(); * @return Arguments An Arguments object (from php-cli-tools). * @see https://github.com/wp-cli/php-cli-tools The PHP CLI Tools github repository. */ - abstract protected function setupArguments(); + abstract protected function setupArguments(): Arguments; /** * Check the arguments given to the CLI Module. @@ -141,7 +141,7 @@ abstract protected function checkArguments(); * * @param Arguments $arguments An Arguments object from php-cli-tools. */ - private function setArguments(Arguments $arguments) + private function setArguments(Arguments $arguments): void { $this->arguments = $arguments; } @@ -151,7 +151,7 @@ private function setArguments(Arguments $arguments) * * @return Arguments An Arguments object from php-cli-tools. */ - protected function getArguments() + protected function getArguments(): Arguments { return $this->arguments; } @@ -163,7 +163,7 @@ protected function getArguments() * * @param string $message The error message. */ - protected function error($message) + protected function error($message): void { $this->out("%r${message}%n", true); } @@ -176,7 +176,7 @@ protected function error($message) * * @param string $message The success message. */ - protected function success($message) + protected function success($message): void { if ($this->isVerbose() === true) { $this->out("%g${message}%n", true); @@ -192,7 +192,7 @@ protected function success($message) * * @param string $message The error message. */ - protected function fail($message) + protected function fail($message): void { $this->error($message); exit(self::EXIT_FAILURE); @@ -201,7 +201,7 @@ protected function fail($message) /** * @param $longName */ - protected function missingArgument($longName) + protected function missingArgument($longName): void { $arguments = $this->getArguments(); $options = $arguments->getOptions(); @@ -225,7 +225,7 @@ protected function missingArgument($longName) * * @param string $message An information message. */ - protected function info($message) + protected function info($message): void { if ($this->isVerbose() === true) { $this->out("%w${message}%n", true); @@ -238,7 +238,7 @@ protected function info($message) * @param string $data The data to go in output. * @param bool $newLine Whether to display a new line after $data. */ - protected function out($data, $newLine = true) + protected function out($data, $newLine = true): void { CliTools\out($data); @@ -255,7 +255,7 @@ protected function out($data, $newLine = true) * * @return bool */ - protected function isVerbose() + protected function isVerbose(): bool { $arguments = $this->getArguments(); return $this->arguments['verbose'] === true; diff --git a/src/qtism/cli/Render.php b/src/qtism/cli/Render.php index d970c1ca5..1443573ca 100644 --- a/src/qtism/cli/Render.php +++ b/src/qtism/cli/Render.php @@ -45,7 +45,7 @@ class Render extends Cli /** * @return Arguments */ - protected function setupArguments() + protected function setupArguments(): Arguments { $arguments = new Arguments(['strict' => false]); @@ -104,7 +104,7 @@ protected function setupArguments() return $arguments; } - protected function checkArguments() + protected function checkArguments(): void { $arguments = $this->getArguments(); @@ -159,7 +159,7 @@ protected function checkArguments() * This implementations considers that all necessary checks about * arguments and their values were performed in \qtism\cli\Render::checkArguments(). */ - protected function run() + protected function run(): void { $engine = $this->instantiateEngine(); $arguments = $this->getArguments(); @@ -227,7 +227,7 @@ protected function run() * @return string The rendered data as a string. * @throws RenderingException */ - private function runGoldilocks(XmlDocument $doc, GoldilocksRenderingEngine $renderer) + private function runGoldilocks(XmlDocument $doc, GoldilocksRenderingEngine $renderer): string { $arguments = $this->getArguments(); $profile = $arguments['flavour']; @@ -315,7 +315,7 @@ private function runGoldilocks(XmlDocument $doc, GoldilocksRenderingEngine $rend * @return string The raw rendering data. * @throws RenderingException */ - private function runXhtml(XmlDocument $doc, XhtmlRenderingEngine $renderer) + private function runXhtml(XmlDocument $doc, XhtmlRenderingEngine $renderer): string { $arguments = $this->getArguments(); $profile = $arguments['flavour']; @@ -385,7 +385,7 @@ private function runXhtml(XmlDocument $doc, XhtmlRenderingEngine $renderer) * * @return AbstractMarkupRenderingEngine */ - private function instantiateEngine() + private function instantiateEngine(): AbstractMarkupRenderingEngine { $arguments = $this->getArguments(); $engine = null; diff --git a/src/qtism/common/Comparable.php b/src/qtism/common/Comparable.php index 32d30609d..fe2bce23b 100644 --- a/src/qtism/common/Comparable.php +++ b/src/qtism/common/Comparable.php @@ -38,5 +38,5 @@ interface Comparable * @return bool Whether the object to compare is equal to this one. * @link http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object) */ - public function equals($obj); + public function equals($obj): bool; } diff --git a/src/qtism/common/QtiSdkPackageContentException.php b/src/qtism/common/QtiSdkPackageContentException.php index 0d4b5b609..221c1f7b4 100644 --- a/src/qtism/common/QtiSdkPackageContentException.php +++ b/src/qtism/common/QtiSdkPackageContentException.php @@ -19,8 +19,6 @@ * * @license GPLv2 */ -declare(strict_types=1); - namespace qtism\common; /** diff --git a/src/qtism/common/Resolver.php b/src/qtism/common/Resolver.php index 451fa3e21..524e51e5c 100644 --- a/src/qtism/common/Resolver.php +++ b/src/qtism/common/Resolver.php @@ -35,5 +35,5 @@ interface Resolver * @return string A resolved URL. * @throws ResolutionException If an error occurs during the resolution of $url. */ - public function resolve($url); + public function resolve($url): string; } diff --git a/src/qtism/common/beans/Bean.php b/src/qtism/common/beans/Bean.php index 9e5268aae..fb24c25a5 100644 --- a/src/qtism/common/beans/Bean.php +++ b/src/qtism/common/beans/Bean.php @@ -38,7 +38,7 @@ class Bean * * @var string */ - const ANNOTATION_PROPERTY = '@qtism-bean-property'; + public const ANNOTATION_PROPERTY = '@qtism-bean-property'; /** * The object to be wrapped as a bean as a PHP ReflectionObject. @@ -85,7 +85,7 @@ public function __construct($object, $strict = false, $asInstanceOf = '') * * @param ReflectionClass $class A ReflectionClass object. */ - protected function setClass(ReflectionClass $class) + protected function setClass(ReflectionClass $class): void { $this->class = $class; } @@ -95,7 +95,7 @@ protected function setClass(ReflectionClass $class) * * @return ReflectionClass A ReflectionClass object. */ - protected function getClass() + protected function getClass(): ReflectionClass { return $this->class; } @@ -109,7 +109,7 @@ protected function getClass() * @throws InvalidArgumentException If $property is not a string nor a Bean * @throws ReflectionException */ - public function getGetter($property) + public function getGetter($property): BeanMethod { if (is_string($property)) { $propertyName = $property; @@ -178,7 +178,7 @@ public function hasGetter($property) * @throws BeanException * @throws ReflectionException */ - public function getGetters($excludeConstructor = false) + public function getGetters($excludeConstructor = false): BeanMethodCollection { $methods = new BeanMethodCollection(); @@ -202,7 +202,7 @@ public function getGetters($excludeConstructor = false) * @throws InvalidArgumentException If $property is not a string nor a BeanProperty object. * @throws ReflectionException */ - public function getSetter($property) + public function getSetter($property): BeanMethod { if (is_string($property)) { $propertyName = $property; @@ -238,7 +238,7 @@ public function getSetter($property) * @return bool * @throws ReflectionException */ - public function hasSetter($property) + public function hasSetter($property): bool { if (is_string($property)) { $propertyName = $property; @@ -267,7 +267,7 @@ public function hasSetter($property) * @throws BeanException * @throws ReflectionException */ - public function getSetters($excludeConstructor = false) + public function getSetters($excludeConstructor = false): BeanMethodCollection { $methods = new BeanMethodCollection(); @@ -293,7 +293,7 @@ public function getSetters($excludeConstructor = false) * @return bool * @throws ReflectionException */ - public function hasProperty($propertyName) + public function hasProperty($propertyName): bool { return $this->isPropertyAnnotated($propertyName); } @@ -306,7 +306,7 @@ public function hasProperty($propertyName) * @throws BeanException * @throws ReflectionException */ - public function getProperty($propertyName) + public function getProperty($propertyName): BeanProperty { $className = $this->getClass()->getName(); @@ -330,7 +330,7 @@ public function getProperty($propertyName) * @throws BeanException * @throws ReflectionException */ - public function getProperties() + public function getProperties(): BeanPropertyCollection { $properties = new BeanPropertyCollection(); @@ -361,7 +361,7 @@ public function getProperties() * @throws BeanException * @throws ReflectionException */ - public function getConstructorGetters() + public function getConstructorGetters(): BeanMethodCollection { $getters = new BeanMethodCollection(); @@ -379,7 +379,7 @@ public function getConstructorGetters() * @throws BeanException * @throws ReflectionException */ - public function getConstructorSetters() + public function getConstructorSetters(): BeanMethodCollection { $setters = new BeanMethodCollection(); @@ -398,7 +398,7 @@ public function getConstructorSetters() * @throws BeanException * @throws ReflectionException */ - public function getConstructorParameters() + public function getConstructorParameters(): BeanParameterCollection { $parameters = new BeanParameterCollection(); @@ -421,7 +421,7 @@ public function getConstructorParameters() * @return bool * @throws ReflectionException */ - public function hasConstructorParameter($parameterName) + public function hasConstructorParameter($parameterName): bool { $hasConstructorParameter = false; @@ -444,7 +444,7 @@ public function hasConstructorParameter($parameterName) * @return bool * @throws ReflectionException */ - protected function isPropertyAnnotated($propertyName) + protected function isPropertyAnnotated($propertyName): bool { $target = $this->getClass(); $isAnnotated = false; @@ -474,7 +474,7 @@ protected function isPropertyAnnotated($propertyName) * @throws BeanException * @throws ReflectionException */ - protected function validateStrictBean() + protected function validateStrictBean(): void { /* * 1st rule to respect: @@ -532,7 +532,7 @@ protected function validateStrictBean() * @param string $propertyName The name of the property. * @return array An array of possible getter method names for a given $propertyName. */ - protected static function getPossibleGetterNames($propertyName) + protected static function getPossibleGetterNames($propertyName): array { $ucPropName = ucfirst($propertyName); diff --git a/src/qtism/common/beans/BeanException.php b/src/qtism/common/beans/BeanException.php index 233a03b8f..85b1163ee 100644 --- a/src/qtism/common/beans/BeanException.php +++ b/src/qtism/common/beans/BeanException.php @@ -36,49 +36,49 @@ class BeanException extends Exception * * @var int */ - const UNKNOWN = 0; + public const UNKNOWN = 0; /** * Error code to use when a class method does not exist. * * @var int */ - const NO_METHOD = 1; + public const NO_METHOD = 1; /** * Error code to use when a class property does not exist. * * @var int */ - const NO_PROPERTY = 2; + public const NO_PROPERTY = 2; /** * Error code to use when a method parameter does not exist. * * @var int */ - const NO_PARAMETER = 3; + public const NO_PARAMETER = 3; /** * Error code to use when an expected bean annotation cannot be found. * * @var int */ - const NO_ANNOTATION = 4; + public const NO_ANNOTATION = 4; /** * Error code to use when the bean has no constructor. * * @var int */ - const NO_CONSTRUCTOR = 5; + public const NO_CONSTRUCTOR = 5; /** * Error code to use when a bean is not a strict bean. * * @var int */ - const NOT_STRICT = 6; + public const NOT_STRICT = 6; /** * Create a new BeanException object. diff --git a/src/qtism/common/beans/BeanMethod.php b/src/qtism/common/beans/BeanMethod.php index 37416ecf6..30445c29e 100644 --- a/src/qtism/common/beans/BeanMethod.php +++ b/src/qtism/common/beans/BeanMethod.php @@ -60,7 +60,7 @@ public function __construct($class, $name) * * @return string */ - public function getName() + public function getName(): string { return $this->getMethod()->getName(); } @@ -70,7 +70,7 @@ public function getName() * * @param ReflectionMethod $method A ReflectionMethod object. */ - protected function setMethod(ReflectionMethod $method) + protected function setMethod(ReflectionMethod $method): void { $this->method = $method; } @@ -80,7 +80,7 @@ protected function setMethod(ReflectionMethod $method) * * @return ReflectionMethod A ReflectionMethod object. */ - public function getMethod() + public function getMethod(): ReflectionMethod { return $this->method; } diff --git a/src/qtism/common/beans/BeanMethodCollection.php b/src/qtism/common/beans/BeanMethodCollection.php index acb1509f3..d95ba6c32 100644 --- a/src/qtism/common/beans/BeanMethodCollection.php +++ b/src/qtism/common/beans/BeanMethodCollection.php @@ -37,7 +37,7 @@ class BeanMethodCollection extends AbstractCollection * @param mixed $value A given value. * @throws InvalidArgumentException If $value is not an instance of BeanMethod. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof BeanMethod) { $msg = 'The BeanMethodCollection class only accepts to store BeanMethod objects.'; diff --git a/src/qtism/common/beans/BeanParameter.php b/src/qtism/common/beans/BeanParameter.php index 3bd7be74a..2e4c48fc8 100644 --- a/src/qtism/common/beans/BeanParameter.php +++ b/src/qtism/common/beans/BeanParameter.php @@ -61,7 +61,7 @@ public function __construct($class, $method, $name) * * @param ReflectionParameter $parameter A ReflectionParameter object. */ - protected function setParameter(ReflectionParameter $parameter) + protected function setParameter(ReflectionParameter $parameter): void { $this->parameter = $parameter; } @@ -71,7 +71,7 @@ protected function setParameter(ReflectionParameter $parameter) * * @return ReflectionParameter A ReflectionParameter object. */ - public function getParameter() + public function getParameter(): ReflectionParameter { return $this->parameter; } @@ -81,7 +81,7 @@ public function getParameter() * * @return string */ - public function getName() + public function getName(): string { return $this->getParameter()->getName(); } diff --git a/src/qtism/common/beans/BeanParameterCollection.php b/src/qtism/common/beans/BeanParameterCollection.php index 558248433..d92130095 100644 --- a/src/qtism/common/beans/BeanParameterCollection.php +++ b/src/qtism/common/beans/BeanParameterCollection.php @@ -38,7 +38,7 @@ class BeanParameterCollection extends AbstractCollection * @param mixed $value A given value. * @throws InvalidArgumentException If $value is not an instance of BeanParameter. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof BeanParameter) { $msg = 'The BeanParameterCollection class only accepts BeanParameter objects to be stored.'; diff --git a/src/qtism/common/beans/BeanProperty.php b/src/qtism/common/beans/BeanProperty.php index 491bafad6..285233481 100644 --- a/src/qtism/common/beans/BeanProperty.php +++ b/src/qtism/common/beans/BeanProperty.php @@ -64,7 +64,7 @@ public function __construct($class, $name) * * @return string */ - public function getName() + public function getName(): string { return $this->getProperty()->getName(); } @@ -75,7 +75,7 @@ public function getName() * @param ReflectionProperty $property A ReflectionProperty object. * @throws BeanException If the given $property is not annotated with @qtism-bean-property. */ - protected function setProperty(ReflectionProperty $property) + protected function setProperty(ReflectionProperty $property): void { if (mb_strpos($property->getDocComment(), Bean::ANNOTATION_PROPERTY, 0, 'UTF-8') !== false) { $this->property = $property; @@ -90,7 +90,7 @@ protected function setProperty(ReflectionProperty $property) * * @return ReflectionProperty A ReflectionProperty object. */ - public function getProperty() + public function getProperty(): ReflectionProperty { return $this->property; } diff --git a/src/qtism/common/beans/BeanPropertyCollection.php b/src/qtism/common/beans/BeanPropertyCollection.php index aa9e9fb3d..5f93ceb7f 100644 --- a/src/qtism/common/beans/BeanPropertyCollection.php +++ b/src/qtism/common/beans/BeanPropertyCollection.php @@ -37,7 +37,7 @@ class BeanPropertyCollection extends AbstractCollection * @param mixed $value A given value. * @throws InvalidArgumentException If $value is not an instance of BeanProperty. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof BeanProperty) { $msg = 'The BeanPropertyCollection class only accepts BeanProperty objects to be stored.'; diff --git a/src/qtism/common/collections/AbstractCollection.php b/src/qtism/common/collections/AbstractCollection.php index 43972c155..2c3c57ccd 100644 --- a/src/qtism/common/collections/AbstractCollection.php +++ b/src/qtism/common/collections/AbstractCollection.php @@ -63,7 +63,7 @@ public function __construct(array $array = []) * * @param array $dataPlaceHolder An array. */ - protected function setDataPlaceHolder(array &$dataPlaceHolder) + protected function setDataPlaceHolder(array &$dataPlaceHolder): void { $this->dataPlaceHolder = $dataPlaceHolder; } @@ -73,7 +73,7 @@ protected function setDataPlaceHolder(array &$dataPlaceHolder) * * @return array The data placeholder of the collection. */ - protected function &getDataPlaceHolder() + protected function &getDataPlaceHolder(): array { return $this->dataPlaceHolder; } @@ -91,7 +91,7 @@ abstract protected function checkType($value); * * @return int The amount of values stored by the collection. */ - public function count() + public function count(): int { return count($this->dataPlaceHolder); } @@ -101,6 +101,7 @@ public function count() * * @return mixed The current element. */ + #[\ReturnTypeWillChange] public function current() { return current($this->dataPlaceHolder); @@ -109,7 +110,7 @@ public function current() /** * Move forward to the next element of the collection while iterating. */ - public function next() + public function next(): void { next($this->dataPlaceHolder); } @@ -119,6 +120,7 @@ public function next() * * @return mixed Depends on the implementation. */ + #[\ReturnTypeWillChange] public function key() { return key($this->dataPlaceHolder); @@ -129,7 +131,7 @@ public function key() * * @return bool true on success or false on failure. */ - public function valid() + public function valid(): bool { return key($this->dataPlaceHolder) !== null; } @@ -137,7 +139,7 @@ public function valid() /** * Rewind the iterator to the first element of the collection; */ - public function rewind() + public function rewind(): void { reset($this->dataPlaceHolder); } @@ -148,7 +150,7 @@ public function rewind() * @param mixed $offset An offset to check for. * @return bool Whether the offset exist. */ - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->dataPlaceHolder[$offset]); } @@ -160,6 +162,7 @@ public function offsetExists($offset) * @param mixed $offset The offset to retrieve. * @return mixed The value at specified offset. */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->dataPlaceHolder[$offset] ?? null; @@ -173,7 +176,7 @@ public function offsetGet($offset) * @param mixed $value The value to set. * @throws InvalidArgumentException If $value has not a valid type regarding the implementation. */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { $this->checkType($value); @@ -187,7 +190,7 @@ public function offsetSet($offset, $value) /** * @param mixed $offset */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->dataPlaceHolder[$offset]); } @@ -199,7 +202,7 @@ public function offsetUnset($offset) * @param bool $preserveKeys * @return array The collection as an array of data. */ - public function getArrayCopy($preserveKeys = false) + public function getArrayCopy($preserveKeys = false): array { return ($preserveKeys === true) ? $this->dataPlaceHolder : array_values($this->dataPlaceHolder); } @@ -211,7 +214,7 @@ public function getArrayCopy($preserveKeys = false) * @param mixed $value A value. * @return bool Whether the collection contains $value. */ - public function contains($value) + public function contains($value): bool { foreach (array_keys($this->dataPlaceHolder) as $key) { $data = $this->dataPlaceHolder[$key]; @@ -229,7 +232,7 @@ public function contains($value) * @param mixed $object An object. * @throws InvalidArgumentException If $object is not an 'object' type or not compliant with the typing of the collection. */ - public function attach($object) + public function attach($object): void { $this->checkType($object); @@ -248,7 +251,7 @@ public function attach($object) * @throws InvalidArgumentException If $object is not an 'object' type or not compliant with the typing of the collection. * @throws UnexpectedValueException If $object cannot be found in the collection. */ - public function detach($object) + public function detach($object): void { $this->checkType($object); @@ -277,7 +280,7 @@ public function detach($object) * @throws InvalidArgumentException If $object or $replacement are not compliant with the current collection typing. * @throws UnexpectedValueException If $object is not contained in the collection. */ - public function replace($object, $replacement) + public function replace($object, $replacement): void { $this->checkType($object); $this->checkType($replacement); @@ -310,7 +313,7 @@ public function replace($object, $replacement) * * @param mixed $object The object to remove from the collection. */ - public function remove($object) + public function remove($object): void { foreach (array_keys($this->dataPlaceHolder) as $k) { if ($this->dataPlaceHolder[$k] === $object) { @@ -324,7 +327,7 @@ public function remove($object) /** * Reset the collection to an empty one. */ - public function reset() + public function reset(): void { $a = []; $this->dataPlaceHolder = $a; @@ -335,7 +338,7 @@ public function reset() * * @return array An array of values which are the keys of the collection. */ - public function getKeys() + public function getKeys(): array { return array_keys($this->dataPlaceHolder); } @@ -346,7 +349,7 @@ public function getKeys() * @param AbstractCollection $collection * @throws InvalidArgumentException If $collection is not a subclass of the target of the call. */ - public function merge(AbstractCollection $collection) + public function merge(self $collection): void { if (is_subclass_of($collection, get_class($this)) === true || get_class($collection) === get_class($this)) { $newData = array_merge($this->dataPlaceHolder, $collection->getDataPlaceHolder()); @@ -367,7 +370,7 @@ public function merge(AbstractCollection $collection) * @param AbstractCollection $collection * @return AbstractCollection */ - public function diff(AbstractCollection $collection) + public function diff(self $collection): self { if (get_class($this) === get_class($collection)) { $newData = array_diff($this->dataPlaceHolder, $collection->getDataPlaceHolder()); @@ -385,7 +388,7 @@ public function diff(AbstractCollection $collection) * @param AbstractCollection $collection * @return AbstractCollection */ - public function intersect(AbstractCollection $collection) + public function intersect(self $collection): self { if (get_class($this) === get_class($collection)) { $newData = array_intersect($this->dataPlaceHolder, $collection->getDataPlaceHolder()); @@ -401,7 +404,7 @@ public function intersect(AbstractCollection $collection) * Reset the keys of the collection. This method is similar * in behaviour with PHP's array_values. */ - public function resetKeys() + public function resetKeys(): void { $newData = array_values($this->dataPlaceHolder); $this->setDataPlaceHolder($newData); diff --git a/src/qtism/common/collections/IdentifierCollection.php b/src/qtism/common/collections/IdentifierCollection.php index 58fc412fd..d9391a527 100644 --- a/src/qtism/common/collections/IdentifierCollection.php +++ b/src/qtism/common/collections/IdentifierCollection.php @@ -37,7 +37,7 @@ class IdentifierCollection extends StringCollection * @param mixed $value A given value. * @throws InvalidArgumentException If $value is not a valid QTI Identifier. */ - protected function checkType($value) + protected function checkType($value): void { if (!is_string($value)) { $msg = "IdentifierCollection class only accept string values, '" . gettype($value) . "' given."; @@ -55,7 +55,7 @@ protected function checkType($value) * * @return string */ - public function __toString() + public function __toString(): string { $strArray = []; $dataPlaceHolder = &$this->getDataPlaceHolder(); diff --git a/src/qtism/common/collections/IntegerCollection.php b/src/qtism/common/collections/IntegerCollection.php index 1f8e6188a..48751151b 100644 --- a/src/qtism/common/collections/IntegerCollection.php +++ b/src/qtism/common/collections/IntegerCollection.php @@ -36,7 +36,7 @@ class IntegerCollection extends AbstractCollection * @param mixed $value A given value. * @throws InvalidArgumentException If $value is not a valid integer. */ - protected function checkType($value) + protected function checkType($value): void { if (!is_int($value)) { $msg = "IntegerCollection class only accept integer values, '" . gettype($value) . "' given."; diff --git a/src/qtism/common/collections/Stack.php b/src/qtism/common/collections/Stack.php index 9201b4ee5..d13abf677 100644 --- a/src/qtism/common/collections/Stack.php +++ b/src/qtism/common/collections/Stack.php @@ -41,5 +41,6 @@ public function push($value); * * @return mixed A value. */ + #[\ReturnTypeWillChange] public function pop(); } diff --git a/src/qtism/common/collections/StringCollection.php b/src/qtism/common/collections/StringCollection.php index fb7651955..5b1216a56 100644 --- a/src/qtism/common/collections/StringCollection.php +++ b/src/qtism/common/collections/StringCollection.php @@ -36,7 +36,7 @@ class StringCollection extends AbstractCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a valid string. */ - protected function checkType($value) + protected function checkType($value): void { if (!is_string($value)) { $msg = "StringCollection class only accept string values, '" . gettype($value) . "' given."; @@ -50,7 +50,7 @@ protected function checkType($value) * @param mixed $value A string. * @return bool Whether the collection contains $value. */ - public function contains($value) + public function contains($value): bool { $data = &$this->getDataPlaceHolder(); diff --git a/src/qtism/common/datatypes/QtiBoolean.php b/src/qtism/common/datatypes/QtiBoolean.php index c2bdb0cd6..aa19593c9 100644 --- a/src/qtism/common/datatypes/QtiBoolean.php +++ b/src/qtism/common/datatypes/QtiBoolean.php @@ -38,7 +38,7 @@ class QtiBoolean extends QtiScalar * @param mixed $value A given value. * @throws InvalidArgumentException */ - protected function checkType($value) + protected function checkType($value): void { if (is_bool($value) !== true) { $msg = 'The Boolean Datatype only accepts to store boolean values.'; @@ -52,7 +52,7 @@ protected function checkType($value) * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::BOOLEAN; } @@ -63,7 +63,7 @@ public function getBaseType() * * @return int A value from the BaseType enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } @@ -74,7 +74,7 @@ public function getCardinality() * * @return string */ - public function __toString() + public function __toString(): string { return ($this->getValue() === true) ? 'true' : 'false'; } diff --git a/src/qtism/common/datatypes/QtiCoords.php b/src/qtism/common/datatypes/QtiCoords.php index 5e86f40ff..491420072 100644 --- a/src/qtism/common/datatypes/QtiCoords.php +++ b/src/qtism/common/datatypes/QtiCoords.php @@ -89,7 +89,7 @@ public function __construct($shape, array $coords = []) * @param int $shape A value from the Shape enumeration. * @throws InvalidArgumentException */ - protected function setShape($shape) + protected function setShape($shape): void { if (in_array($shape, QtiShape::asArray())) { $this->shape = $shape; @@ -104,7 +104,7 @@ protected function setShape($shape) * * @return int A value from the Shape enumeration. */ - public function getShape() + public function getShape(): int { return $this->shape; } @@ -115,7 +115,7 @@ public function getShape() * @param QtiPoint $point A QtiPoint object. * @return bool */ - public function inside(QtiPoint $point) + public function inside(QtiPoint $point): bool { if ($this->getShape() === QtiShape::DEF) { return true; @@ -185,7 +185,7 @@ public function inside(QtiPoint $point) * * @return string */ - public function __toString() + public function __toString(): string { return implode(',', $this->getDataPlaceHolder()); } @@ -197,7 +197,7 @@ public function __toString() * @param mixed $obj * @return bool */ - public function equals($obj) + public function equals($obj): bool { return $obj instanceof self && $this->getShape() === $obj->getShape() @@ -210,7 +210,7 @@ public function equals($obj) * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::COORDS; } @@ -221,7 +221,7 @@ public function getBaseType() * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } diff --git a/src/qtism/common/datatypes/QtiDatatype.php b/src/qtism/common/datatypes/QtiDatatype.php index 47e6eeeb2..6df8715b8 100644 --- a/src/qtism/common/datatypes/QtiDatatype.php +++ b/src/qtism/common/datatypes/QtiDatatype.php @@ -50,12 +50,12 @@ interface QtiDatatype extends Comparable * * @return int A value from the BaseType enumeration. */ - public function getBaseType(); + public function getBaseType(): int; /** * Get the QTI cardinality of the datatype instance. * * @return int A value from the Cardinality enumeration. */ - public function getCardinality(); + public function getCardinality(): int; } diff --git a/src/qtism/common/datatypes/QtiDirectedPair.php b/src/qtism/common/datatypes/QtiDirectedPair.php index 5a3ede17b..fe494a013 100644 --- a/src/qtism/common/datatypes/QtiDirectedPair.php +++ b/src/qtism/common/datatypes/QtiDirectedPair.php @@ -42,7 +42,7 @@ class QtiDirectedPair extends QtiPair * @param mixed $obj * @return bool */ - public function equals($obj) + public function equals($obj): bool { if (is_object($obj) && $obj instanceof self) { return $obj->getFirst() === $this->getFirst() && $obj->getSecond() === $this->getSecond(); @@ -57,7 +57,7 @@ public function equals($obj) * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::DIRECTED_PAIR; } @@ -68,7 +68,7 @@ public function getBaseType() * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } diff --git a/src/qtism/common/datatypes/QtiDuration.php b/src/qtism/common/datatypes/QtiDuration.php index a5aef8731..69e41cddd 100644 --- a/src/qtism/common/datatypes/QtiDuration.php +++ b/src/qtism/common/datatypes/QtiDuration.php @@ -45,7 +45,7 @@ class QtiDuration implements QtiDatatype * * @var string */ - const TIMEZONE = 'UTC'; + public const TIMEZONE = 'UTC'; private $refDate; @@ -108,9 +108,9 @@ public function __construct($intervalSpec) * @param DateInterval $interval * @return QtiDuration */ - public static function createFromDateInterval(DateInterval $interval) + public static function createFromDateInterval(DateInterval $interval): self { - $duration = new QtiDuration('PT0S'); + $duration = new self('PT0S'); $duration->setInterval($interval); return $duration; @@ -121,7 +121,7 @@ public static function createFromDateInterval(DateInterval $interval) * * @return DateInterval A DateInterval PHP object. */ - protected function getInterval() + protected function getInterval(): DateInterval { return $this->interval; } @@ -131,7 +131,7 @@ protected function getInterval() * * @param DateInterval $interval A DateInterval PHP object. */ - protected function setInterval(DateInterval $interval) + protected function setInterval(DateInterval $interval): void { $this->interval = $interval; } @@ -141,7 +141,7 @@ protected function setInterval(DateInterval $interval) * * @return int */ - public function getYears() + public function getYears(): int { return $this->getInterval()->y; } @@ -151,7 +151,7 @@ public function getYears() * * @return int */ - public function getMonths() + public function getMonths(): int { return $this->getInterval()->m; } @@ -162,7 +162,7 @@ public function getMonths() * @param bool $total Whether the number of days must be the total of days or simply an offset (default). * @return int */ - public function getDays($total = false) + public function getDays($total = false): int { return ($total == true) ? $this->getInterval()->days : $this->getInterval()->d; } @@ -172,7 +172,7 @@ public function getDays($total = false) * * @return int */ - public function getHours() + public function getHours(): int { return $this->getInterval()->h; } @@ -182,7 +182,7 @@ public function getHours() * * @return int */ - public function getMinutes() + public function getMinutes(): int { return $this->getInterval()->i; } @@ -193,7 +193,7 @@ public function getMinutes() * @param bool $total Whether to get the total amount of seconds, as a single integer, that represents the complete duration. * @return int The value of the total duration in seconds. */ - public function getSeconds($total = false) + public function getSeconds($total = false): int { if ($total === false) { return $this->getInterval()->s; @@ -216,7 +216,7 @@ public function getSeconds($total = false) * * @return string */ - public function __toString() + public function __toString(): string { $string = 'P'; @@ -266,12 +266,11 @@ public function __toString() * @param mixed $obj A given value. * @return bool Whether the equality is established. */ - public function equals($obj) + public function equals($obj): bool { return is_object($obj) && $obj instanceof self - && '' . $this === '' . $obj - ; + && (string)$this === (string)$obj; } /** @@ -281,7 +280,7 @@ public function equals($obj) * @param QtiDuration $duration A Duration object to compare with this one. * @return bool */ - public function shorterThan(QtiDuration $duration) + public function shorterThan(QtiDuration $duration): bool { return $this->getSeconds(true) < $duration->getSeconds(true); } @@ -293,7 +292,7 @@ public function shorterThan(QtiDuration $duration) * @param QtiDuration $duration A Duration object to compare with this one. * @return bool */ - public function longerThanOrEquals(QtiDuration $duration) + public function longerThanOrEquals(QtiDuration $duration): bool { return $this->getSeconds(true) >= $duration->getSeconds(true); } @@ -306,7 +305,7 @@ public function longerThanOrEquals(QtiDuration $duration) * @param QtiDuration|DateInterval $duration A QtiDuration or DateInterval object. * @throws Exception */ - public function add($duration) + public function add($duration): void { $d1 = $this->refDate; $d2 = clone $d1; @@ -335,7 +334,7 @@ public function add($duration) * @param QtiDuration $duration * @throws Exception */ - public function sub(QtiDuration $duration) + public function sub(QtiDuration $duration): void { if ($duration->longerThanOrEquals($this) === true) { $this->setInterval(new DateInterval('PT0S')); @@ -379,7 +378,7 @@ public function __clone() * * @return bool */ - public function isNegative() + public function isNegative(): bool { return $this->interval->invert === 0; } @@ -390,7 +389,7 @@ public function isNegative() * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::DURATION; } @@ -401,7 +400,7 @@ public function getBaseType() * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } diff --git a/src/qtism/common/datatypes/QtiFile.php b/src/qtism/common/datatypes/QtiFile.php index 5c14db06a..e9bec8e15 100644 --- a/src/qtism/common/datatypes/QtiFile.php +++ b/src/qtism/common/datatypes/QtiFile.php @@ -44,7 +44,7 @@ interface QtiFile extends QtiDatatype * * @return string */ - public function getData(); + public function getData(): string; /** * Get the MIME type of the file. This MIME type is one of the MIME @@ -57,7 +57,7 @@ public function getMimeType(); * * @return bool */ - public function hasFilename(); + public function hasFilename(): bool; /** * Get the file name of this file. If no file name is defined, @@ -65,7 +65,7 @@ public function hasFilename(); * * @return string */ - public function getFilename(); + public function getFilename(): string; /** * Get a brand new stream resource on the file. It is the responsibility of the @@ -83,5 +83,5 @@ public function getStream(); * @return string A unique identifier. * @throws RuntimeException If an error occurs while retrieving the file. */ - public function getIdentifier(); + public function getIdentifier(): string; } diff --git a/src/qtism/common/datatypes/QtiFloat.php b/src/qtism/common/datatypes/QtiFloat.php index 5d02f1045..e435f1581 100644 --- a/src/qtism/common/datatypes/QtiFloat.php +++ b/src/qtism/common/datatypes/QtiFloat.php @@ -38,7 +38,7 @@ class QtiFloat extends QtiScalar * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of Float. */ - protected function checkType($value) + protected function checkType($value): void { if (!is_float($value)) { $msg = 'The Float Datatype only accepts to store float values.'; @@ -52,7 +52,7 @@ protected function checkType($value) * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::FLOAT; } @@ -63,7 +63,7 @@ public function getBaseType() * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } @@ -71,8 +71,8 @@ public function getCardinality() /** * @return string */ - public function __toString() + public function __toString(): string { - return '' . $this->getValue(); + return (string)$this->getValue(); } } diff --git a/src/qtism/common/datatypes/QtiIdentifier.php b/src/qtism/common/datatypes/QtiIdentifier.php index 5ba1511f7..d6a508dab 100644 --- a/src/qtism/common/datatypes/QtiIdentifier.php +++ b/src/qtism/common/datatypes/QtiIdentifier.php @@ -38,7 +38,7 @@ class QtiIdentifier extends QtiString * @param mixed $value * @throws InvalidArgumentException If $value is not a string value. */ - protected function checkType($value) + protected function checkType($value): void { if (is_string($value) !== true) { $msg = 'The Identifier Datatype only accepts to store identifier values.'; @@ -55,7 +55,7 @@ protected function checkType($value) * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::IDENTIFIER; } @@ -66,7 +66,7 @@ public function getBaseType() * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } @@ -74,7 +74,7 @@ public function getCardinality() /** * @return mixed */ - public function __toString() + public function __toString(): string { return $this->getValue(); } diff --git a/src/qtism/common/datatypes/QtiIntOrIdentifier.php b/src/qtism/common/datatypes/QtiIntOrIdentifier.php index 0bf24c64b..f5d71e058 100644 --- a/src/qtism/common/datatypes/QtiIntOrIdentifier.php +++ b/src/qtism/common/datatypes/QtiIntOrIdentifier.php @@ -39,7 +39,7 @@ class QtiIntOrIdentifier extends QtiScalar * @param mixed $value * @throws InvalidArgumentException If $value is not compliant with the QTI IntOrIdentifier datatype. */ - protected function checkType($value) + protected function checkType($value): void { if (is_int($value) !== true && is_string($value) !== true) { $msg = 'The IntOrIdentifier Datatype only accepts to store identifier and integer values.'; @@ -53,7 +53,7 @@ protected function checkType($value) * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::INT_OR_IDENTIFIER; } @@ -64,7 +64,7 @@ public function getBaseType() * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } @@ -72,7 +72,7 @@ public function getCardinality() /** * @return mixed|string */ - public function __toString() + public function __toString(): string { $v = $this->getValue(); if (is_string($v)) { diff --git a/src/qtism/common/datatypes/QtiInteger.php b/src/qtism/common/datatypes/QtiInteger.php index 0c085fe10..16a6ad2bd 100644 --- a/src/qtism/common/datatypes/QtiInteger.php +++ b/src/qtism/common/datatypes/QtiInteger.php @@ -45,7 +45,7 @@ class QtiInteger extends QtiScalar * @param mixed $value * @throws InvalidArgumentException If $value is not an integer value compliant with the QTI Integer datatype. */ - protected function checkType($value) + protected function checkType($value): void { if (Utils::isQtiInteger($value) !== true) { $msg = 'The Integer Datatype only accepts to store integer values.'; @@ -59,7 +59,7 @@ protected function checkType($value) * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::INTEGER; } @@ -67,8 +67,10 @@ public function getBaseType() /** * Get the cardinality of the value. This method systematically returns * the Cardinality::SINGLE value. + * + * @return int */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } @@ -76,8 +78,8 @@ public function getCardinality() /** * @return string */ - public function __toString() + public function __toString(): string { - return '' . $this->getValue(); + return (string)$this->getValue(); } } diff --git a/src/qtism/common/datatypes/QtiPair.php b/src/qtism/common/datatypes/QtiPair.php index 928f5a501..60b1ba46d 100644 --- a/src/qtism/common/datatypes/QtiPair.php +++ b/src/qtism/common/datatypes/QtiPair.php @@ -71,7 +71,7 @@ public function __construct($first, $second) * @param string $first A QTI Identifier. * @throws InvalidArgumentException If $first is an invalid QTI Identifier. */ - public function setFirst($first) + public function setFirst($first): void { if (Format::isIdentifier($first)) { $this->first = $first; @@ -86,7 +86,7 @@ public function setFirst($first) * * @return string A QTI Identifier. */ - public function getFirst() + public function getFirst(): string { return $this->first; } @@ -97,7 +97,7 @@ public function getFirst() * @param string $second A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setSecond($second) + public function setSecond($second): void { if (Format::isIdentifier($second)) { $this->second = $second; @@ -112,7 +112,7 @@ public function setSecond($second) * * @return string A QTI Identifier. */ - public function getSecond() + public function getSecond(): string { return $this->second; } @@ -122,7 +122,7 @@ public function getSecond() * * @return string The serialized version of the Pair. */ - public function __toString() + public function __toString(): string { return $this->getFirst() . ' ' . $this->getSecond(); } @@ -135,7 +135,7 @@ public function __toString() * @param mixed $obj A value to compare. * @return bool Whether or not the equality could be established. */ - public function equals($obj) + public function equals($obj): bool { if (is_object($obj) && $obj instanceof self) { $a = [$this->getFirst(), $this->getSecond()]; @@ -153,7 +153,7 @@ public function equals($obj) * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::PAIR; } @@ -164,7 +164,7 @@ public function getBaseType() * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } diff --git a/src/qtism/common/datatypes/QtiPoint.php b/src/qtism/common/datatypes/QtiPoint.php index ca7e7accd..5fb76b099 100644 --- a/src/qtism/common/datatypes/QtiPoint.php +++ b/src/qtism/common/datatypes/QtiPoint.php @@ -72,7 +72,7 @@ public function __construct($x, $y) * @param int $x A position on the x-axis. * @throws InvalidArgumentException If $x is nto an integer value. */ - public function setX($x) + public function setX($x): void { if (is_int($x)) { $this->x = $x; @@ -87,7 +87,7 @@ public function setX($x) * * @return int A position on the x-axis. */ - public function getX() + public function getX(): int { return $this->x; } @@ -98,7 +98,7 @@ public function getX() * @param int $y A position on the y-axis. * @throws InvalidArgumentException If $y is not an integer value. */ - public function setY($y) + public function setY($y): void { if (is_int($y)) { $this->y = $y; @@ -113,7 +113,7 @@ public function setY($y) * * @return int A position on the y-axis. */ - public function getY() + public function getY(): int { return $this->y; } @@ -125,7 +125,7 @@ public function getY() * @param mixed $obj An object. * @return bool Whether or not the equality is established. */ - public function equals($obj) + public function equals($obj): bool { return (is_object($obj) && $obj instanceof self && @@ -140,7 +140,7 @@ public function equals($obj) * * @return string */ - public function __toString() + public function __toString(): string { return $this->getX() . ' ' . $this->getY(); } @@ -151,7 +151,7 @@ public function __toString() * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::POINT; } @@ -162,7 +162,7 @@ public function getBaseType() * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } diff --git a/src/qtism/common/datatypes/QtiScalar.php b/src/qtism/common/datatypes/QtiScalar.php index fdfb6e9cf..9f83584c7 100644 --- a/src/qtism/common/datatypes/QtiScalar.php +++ b/src/qtism/common/datatypes/QtiScalar.php @@ -63,7 +63,7 @@ public function __construct($value) * @param mixed $value * @throws InvalidArgumentException If $value is not compliant with the Scalar wrapper. */ - public function setValue($value) + public function setValue($value): void { $this->checkType($value); $this->value = $value; @@ -74,6 +74,7 @@ public function setValue($value) * * @return mixed */ + #[\ReturnTypeWillChange] public function getValue() { return $this->value; @@ -87,7 +88,7 @@ public function getValue() * @param mixed $obj * @return bool */ - public function equals($obj) + public function equals($obj): bool { if ($obj instanceof self) { return $obj->getValue() === $this->getValue(); diff --git a/src/qtism/common/datatypes/QtiShape.php b/src/qtism/common/datatypes/QtiShape.php index 3ace60471..6a1a90772 100644 --- a/src/qtism/common/datatypes/QtiShape.php +++ b/src/qtism/common/datatypes/QtiShape.php @@ -43,7 +43,7 @@ class QtiShape implements Enumeration * * @var int */ - const DEF = 0; + public const DEF = 0; /** * From IMS QTI: @@ -52,7 +52,7 @@ class QtiShape implements Enumeration * * @var int */ - const RECT = 1; + public const RECT = 1; /** * From IMS QTI: @@ -61,7 +61,7 @@ class QtiShape implements Enumeration * * @var int */ - const CIRCLE = 2; + public const CIRCLE = 2; /** * From IMS QTI: @@ -70,7 +70,7 @@ class QtiShape implements Enumeration * * @var int */ - const POLY = 3; + public const POLY = 3; /** * From IMS QTI: @@ -81,14 +81,14 @@ class QtiShape implements Enumeration * @var int * @deprecated */ - const ELLIPSE = 4; + public const ELLIPSE = 4; /** * Get the enumeration as an array. * * @return array An associative array. */ - public static function asArray() + public static function asArray(): array { return [ 'DEF' => self::DEF, diff --git a/src/qtism/common/datatypes/QtiString.php b/src/qtism/common/datatypes/QtiString.php index 03836e04c..1d8b8a9d9 100644 --- a/src/qtism/common/datatypes/QtiString.php +++ b/src/qtism/common/datatypes/QtiString.php @@ -38,7 +38,7 @@ class QtiString extends QtiScalar * @param mixed $value * @throws InvalidArgumentException If $value is not a valid string. */ - protected function checkType($value) + protected function checkType($value): void { if (is_string($value) !== true) { $msg = 'The String Datatype only accepts to store string values.'; @@ -52,7 +52,7 @@ protected function checkType($value) * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::STRING; } @@ -63,7 +63,7 @@ public function getBaseType() * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } @@ -78,7 +78,7 @@ public function getCardinality() * @param mixed $obj * @return bool */ - public function equals($obj) + public function equals($obj): bool { if ($obj instanceof QtiScalar) { return $obj->getValue() === $this->getValue(); @@ -90,9 +90,9 @@ public function equals($obj) } /** - * @return mixed + * @return string */ - public function __toString() + public function __toString(): string { return $this->getValue(); } diff --git a/src/qtism/common/datatypes/QtiUri.php b/src/qtism/common/datatypes/QtiUri.php index 79e978e86..74a138b17 100644 --- a/src/qtism/common/datatypes/QtiUri.php +++ b/src/qtism/common/datatypes/QtiUri.php @@ -38,7 +38,7 @@ class QtiUri extends QtiString * @param mixed $value * @throws InvalidArgumentException If $value is not a valid string. */ - protected function checkType($value) + protected function checkType($value): void { if (is_string($value) !== true) { $msg = 'The Uri Datatype only accepts to store URI values.'; @@ -52,7 +52,7 @@ protected function checkType($value) * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::URI; } @@ -63,7 +63,7 @@ public function getBaseType() * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } @@ -75,7 +75,7 @@ public function getCardinality() * * @return string */ - public function __toString() + public function __toString(): string { return $this->getValue(); } diff --git a/src/qtism/common/datatypes/files/FileHash.php b/src/qtism/common/datatypes/files/FileHash.php index f0ed1af8b..b54e1fa8a 100644 --- a/src/qtism/common/datatypes/files/FileHash.php +++ b/src/qtism/common/datatypes/files/FileHash.php @@ -39,7 +39,7 @@ class FileHash implements QtiFile, JsonSerializable * Key to use in json payload to trigger the storage of a file hash instead * of a hash. */ - const FILE_HASH_KEY = 'fileHash'; + public const FILE_HASH_KEY = 'fileHash'; /** * The id of the file on the persistent storage. @@ -116,7 +116,7 @@ public function jsonSerialize(): array * * @param string $id */ - protected function setId($id) + protected function setId($id): void { $this->id = $id; } @@ -126,7 +126,7 @@ protected function setId($id) * * @return string */ - public function getId() + public function getId(): string { return $this->id; } @@ -136,7 +136,7 @@ public function getId() * * @param string $mimeType */ - protected function setMimeType($mimeType) + protected function setMimeType($mimeType): void { $this->mimeType = $mimeType; } @@ -146,7 +146,7 @@ protected function setMimeType($mimeType) * * @return string */ - public function getMimeType() + public function getMimeType(): string { return $this->mimeType; } @@ -156,7 +156,7 @@ public function getMimeType() * * @return string */ - public function getFilename() + public function getFilename(): string { return $this->filename; } @@ -166,7 +166,7 @@ public function getFilename() * * @param string $filename */ - protected function setFilename($filename) + protected function setFilename($filename): void { $this->filename = $filename; } @@ -174,7 +174,7 @@ protected function setFilename($filename) /** * Get the sequence of bytes composing the hash of the file. */ - public function getData() + public function getData(): string { return $this->getHash(); } @@ -183,7 +183,7 @@ public function getData() * Returns nothing because the content of the file is stored externally * and thus not accessible in here. */ - public function getStream() + public function getStream(): void { } @@ -192,7 +192,7 @@ public function getStream() * * @return string */ - public function getHash() + public function getHash(): string { return $this->hash; } @@ -202,7 +202,7 @@ public function getHash() * * @param string $hash */ - protected function setHash($hash) + protected function setHash($hash): void { $this->hash = $hash; } @@ -212,7 +212,7 @@ protected function setHash($hash) * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } @@ -222,7 +222,7 @@ public function getCardinality() * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::FILE; } @@ -232,7 +232,7 @@ public function getBaseType() * * @return bool */ - public function hasFilename() + public function hasFilename(): bool { return true; } @@ -245,7 +245,7 @@ public function hasFilename() * @param mixed $obj * @return bool */ - public function equals($obj) + public function equals($obj): bool { if (!$obj instanceof self) { return false; @@ -262,7 +262,7 @@ public function equals($obj) * * @return string */ - public function getIdentifier() + public function getIdentifier(): string { return $this->getId(); } @@ -274,7 +274,7 @@ public function getIdentifier() * * @return string */ - public function __toString() + public function __toString(): string { return $this->getFilename(); } diff --git a/src/qtism/common/datatypes/files/FileManager.php b/src/qtism/common/datatypes/files/FileManager.php index 134dc81ef..b39b50fe2 100644 --- a/src/qtism/common/datatypes/files/FileManager.php +++ b/src/qtism/common/datatypes/files/FileManager.php @@ -48,7 +48,7 @@ interface FileManager * @return QtiFile * @throws FileManagerException */ - public function createFromFile($path, $mimeType, $filename = ''); + public function createFromFile($path, $mimeType, $filename = ''): QtiFile; /** * Instantiate an implementation of File which focuses @@ -61,7 +61,7 @@ public function createFromFile($path, $mimeType, $filename = ''); * @return QtiFile * @throws FileManagerException */ - public function createFromData($data, $mimeType, $filename = '', $path = null); + public function createFromData($data, $mimeType, $filename = '', $path = null): QtiFile; /** * Retrieve a previously created instance by $identifier. diff --git a/src/qtism/common/datatypes/files/FileManagerException.php b/src/qtism/common/datatypes/files/FileManagerException.php index 153eaf06e..25689edac 100644 --- a/src/qtism/common/datatypes/files/FileManagerException.php +++ b/src/qtism/common/datatypes/files/FileManagerException.php @@ -37,7 +37,7 @@ class FileManagerException extends Exception * * @var int */ - const UNKNOWN = 0; + public const UNKNOWN = 0; /** * Create a new FileManagerException object. diff --git a/src/qtism/common/datatypes/files/FileSystemFile.php b/src/qtism/common/datatypes/files/FileSystemFile.php index 13becfd81..ef779eefb 100644 --- a/src/qtism/common/datatypes/files/FileSystemFile.php +++ b/src/qtism/common/datatypes/files/FileSystemFile.php @@ -61,7 +61,7 @@ class FileSystemFile implements QtiFile * * @var int */ - const CHUNK_SIZE = 2048; + public const CHUNK_SIZE = 2048; /** * Create a new PersistentFile object. @@ -78,7 +78,7 @@ public function __construct($path) /** * @param $path */ - private function readInfo($path) + private function readInfo($path): void { // Retrieve filename and mime type. $fp = @fopen($path, 'r'); @@ -107,7 +107,7 @@ private function readInfo($path) * * @param string $path */ - protected function setPath($path) + protected function setPath($path): void { $this->path = $path; } @@ -117,7 +117,7 @@ protected function setPath($path) * * @return string */ - public function getPath() + public function getPath(): string { return $this->path; } @@ -127,7 +127,7 @@ public function getPath() * * @param string $mimeType */ - protected function setMimeType($mimeType) + protected function setMimeType($mimeType): void { $this->mimeType = $mimeType; } @@ -137,7 +137,7 @@ protected function setMimeType($mimeType) * * @return string */ - public function getMimeType() + public function getMimeType(): string { return $this->mimeType; } @@ -147,7 +147,7 @@ public function getMimeType() * * @return string */ - public function getFilename() + public function getFilename(): string { return $this->filename; } @@ -157,7 +157,7 @@ public function getFilename() * * @param string $filename */ - protected function setFilename($filename) + protected function setFilename($filename): void { $this->filename = $filename; } @@ -167,7 +167,7 @@ protected function setFilename($filename) * * @throws RuntimeException If the data cannot be retrieved. */ - public function getData() + public function getData(): string { $fp = $this->getStream(); $data = ''; @@ -215,7 +215,7 @@ public function getStream() * @return FileSystemFile * @throws RuntimeException If something wrong happens. */ - public static function createFromExistingFile($source, $destination, $mimeType, $withFilename = true) + public static function createFromExistingFile($source, $destination, $mimeType, $withFilename = true): FileSystemFile { if (is_file($source)) { if (is_readable($source)) { @@ -226,7 +226,10 @@ public static function createFromExistingFile($source, $destination, $mimeType, throw new RuntimeException($msg); } - if ((is_dir($pathinfo['dirname']) === false) && ($mkdir = @mkdir($pathinfo['dirname'], '0770', true)) === false) { + if ( + is_dir($pathinfo['dirname']) === false + && ($mkdir = @mkdir($pathinfo['dirname'], 0770, true)) === false + ) { $msg = "Unable to create destination directory at '" . $pathinfo['dirname'] . "'."; throw new RuntimeException($msg); } @@ -289,7 +292,7 @@ public static function createFromExistingFile($source, $destination, $mimeType, * @param string $filename * @return FileSystemFile */ - public static function createFromData($data, $destination, $mimeType, $filename = '') + public static function createFromData($data, $destination, $mimeType, $filename = ''): FileSystemFile { $tmp = tempnam('/tmp', 'qtism'); file_put_contents($tmp, $data); @@ -307,7 +310,7 @@ public static function createFromData($data, $destination, $mimeType, $filename * @return FileSystemFile * @throws RuntimeException If something wrong occurs while retrieving the file. */ - public static function retrieveFile($path) + public static function retrieveFile($path): FileSystemFile { return new static($path); } @@ -317,7 +320,7 @@ public static function retrieveFile($path) * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::SINGLE; } @@ -327,7 +330,7 @@ public function getCardinality() * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return BaseType::FILE; } @@ -337,7 +340,7 @@ public function getBaseType() * * @return bool */ - public function hasFilename() + public function hasFilename(): bool { return $this->getFilename() !== ''; } @@ -350,7 +353,7 @@ public function hasFilename() * @param mixed $obj * @return bool */ - public function equals($obj) + public function equals($obj): bool { if ($obj instanceof QtiFile) { if ($this->getFilename() !== $obj->getFilename()) { @@ -389,7 +392,7 @@ public function equals($obj) * * @return string */ - public function getIdentifier() + public function getIdentifier(): string { return $this->getPath(); } @@ -401,7 +404,7 @@ public function getIdentifier() * * @return string */ - public function __toString() + public function __toString(): string { return $this->getFilename(); } diff --git a/src/qtism/common/datatypes/files/FileSystemFileManager.php b/src/qtism/common/datatypes/files/FileSystemFileManager.php index 0df3cc580..b55f94702 100644 --- a/src/qtism/common/datatypes/files/FileSystemFileManager.php +++ b/src/qtism/common/datatypes/files/FileSystemFileManager.php @@ -49,7 +49,7 @@ public function __construct($storageDirectory = '') * * @param string $storageDirectory A canonical path. */ - protected function setStorageDirectory($storageDirectory) + protected function setStorageDirectory($storageDirectory): void { $this->storageDirectory = $storageDirectory; } @@ -60,7 +60,7 @@ protected function setStorageDirectory($storageDirectory) * * @return string A canonical path. */ - protected function getStorageDirectory() + protected function getStorageDirectory(): string { return $this->storageDirectory; } @@ -75,7 +75,7 @@ protected function getStorageDirectory() * @return FileSystemFile * @throws FileManagerException */ - public function createFromFile($path, $mimeType, $filename = '') + public function createFromFile($path, $mimeType, $filename = ''): FileSystemFile { $destination = $this->buildDestination(); @@ -97,7 +97,7 @@ public function createFromFile($path, $mimeType, $filename = '') * @return FileSystemFile * @throws FileManagerException */ - public function createFromData($data, $mimeType, $filename = '', $path = null) + public function createFromData($data, $mimeType, $filename = '', $path = null): FileSystemFile { $destination = $path ?: $this->buildDestination(); @@ -117,7 +117,7 @@ public function createFromData($data, $mimeType, $filename = '', $path = null) * @return FileSystemFile * @throws FileManagerException */ - public function retrieve($identifier, $filename = null) + public function retrieve($identifier, $filename = null): FileSystemFile { try { return FileSystemFile::retrieveFile($identifier); @@ -133,7 +133,7 @@ public function retrieve($identifier, $filename = null) * @param QtiFile $file * @throws FileManagerException */ - public function delete(QtiFile $file) + public function delete(QtiFile $file): void { $deletion = @unlink($file->getPath()); if ($deletion === false) { @@ -147,7 +147,7 @@ public function delete(QtiFile $file) * * @return string */ - protected function buildDestination() + protected function buildDestination(): string { return rtrim($this->getStorageDirectory(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . uniqid('qtism', true); } diff --git a/src/qtism/common/enums/BaseType.php b/src/qtism/common/enums/BaseType.php index 22c11c179..c37806267 100644 --- a/src/qtism/common/enums/BaseType.php +++ b/src/qtism/common/enums/BaseType.php @@ -45,7 +45,7 @@ class BaseType implements Enumeration * * @var int */ - const IDENTIFIER = 0; + public const IDENTIFIER = 0; /** * From IMS QTI: @@ -55,7 +55,7 @@ class BaseType implements Enumeration * * @var int */ - const BOOLEAN = 1; + public const BOOLEAN = 1; /** * From IMS QTI: @@ -65,7 +65,7 @@ class BaseType implements Enumeration * * @var int */ - const INTEGER = 2; + public const INTEGER = 2; /** * From IMS QTI: @@ -75,7 +75,7 @@ class BaseType implements Enumeration * * @var int */ - const FLOAT = 3; + public const FLOAT = 3; /** * From IMS QTI: @@ -85,7 +85,7 @@ class BaseType implements Enumeration * * @var int */ - const STRING = 4; + public const STRING = 4; /** * From IMS QTI: @@ -97,7 +97,7 @@ class BaseType implements Enumeration * * @var int */ - const POINT = 5; + public const POINT = 5; /** * From IMS QTI: @@ -107,7 +107,7 @@ class BaseType implements Enumeration * * @var int */ - const PAIR = 6; + public const PAIR = 6; /** * From IMS QTI: @@ -118,7 +118,7 @@ class BaseType implements Enumeration * * @var int */ - const DIRECTED_PAIR = 7; + public const DIRECTED_PAIR = 7; /** * From IMS QTI: @@ -131,7 +131,7 @@ class BaseType implements Enumeration * * @var int */ - const DURATION = 8; + public const DURATION = 8; /** * From IMS QTI: @@ -143,7 +143,7 @@ class BaseType implements Enumeration * * @var int */ - const FILE = 9; + public const FILE = 9; /** * From IMS QTI: @@ -152,7 +152,7 @@ class BaseType implements Enumeration * * @var int */ - const URI = 10; + public const URI = 10; /** * From IMS QTI: @@ -162,19 +162,19 @@ class BaseType implements Enumeration * * @var int */ - const INT_OR_IDENTIFIER = 11; + public const INT_OR_IDENTIFIER = 11; /** * In qtism, we consider an extra 'coords' baseType. * * @var int */ - const COORDS = 12; + public const COORDS = 12; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'IDENTIFIER' => self::IDENTIFIER, @@ -215,7 +215,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (trim(strtolower($name))) { + switch (trim(strtolower((string)$name))) { case 'identifier': return self::IDENTIFIER; break; diff --git a/src/qtism/common/enums/Cardinality.php b/src/qtism/common/enums/Cardinality.php index a310eeaf6..00b132d7f 100644 --- a/src/qtism/common/enums/Cardinality.php +++ b/src/qtism/common/enums/Cardinality.php @@ -55,33 +55,33 @@ class Cardinality implements Enumeration * * @var int */ - const SINGLE = 0; + public const SINGLE = 0; /** * The QTI multiple cardinality. * * @var int */ - const MULTIPLE = 1; + public const MULTIPLE = 1; /** * The QTI ordered cardinality. * * @var int */ - const ORDERED = 2; + public const ORDERED = 2; /** * The QTI record cardinality. * * @var int */ - const RECORD = 3; + public const RECORD = 3; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'SINGLE' => self::SINGLE, diff --git a/src/qtism/common/enums/Enumeration.php b/src/qtism/common/enums/Enumeration.php index 52d69b3e4..7b12dd708 100644 --- a/src/qtism/common/enums/Enumeration.php +++ b/src/qtism/common/enums/Enumeration.php @@ -33,7 +33,7 @@ interface Enumeration * * @return array An associative array where keys are constant names (as they appear in the code) and values are constant values. */ - public static function asArray(); + public static function asArray(): array; /** * Get a constant value by its name. If $name does not match any of the value @@ -42,6 +42,7 @@ public static function asArray(); * @param string $name The name of a constant of the enumeration. * @return int|false The value relevant to $name or false if not found. */ + #[\ReturnTypeWillChange] public static function getConstantByName($name); /** @@ -51,5 +52,6 @@ public static function getConstantByName($name); * @param int $constant A constant from the enumeration. * @return string|false The relevant name or false if not found. */ + #[\ReturnTypeWillChange] public static function getNameByConstant($constant); } diff --git a/src/qtism/common/storage/AbstractStreamAccess.php b/src/qtism/common/storage/AbstractStreamAccess.php index eae97738d..630dd53ca 100644 --- a/src/qtism/common/storage/AbstractStreamAccess.php +++ b/src/qtism/common/storage/AbstractStreamAccess.php @@ -52,7 +52,7 @@ public function __construct(IStream $stream) * * @return IStream An IStream object. */ - protected function getStream() + protected function getStream(): IStream { return $this->stream; } @@ -63,7 +63,7 @@ protected function getStream() * @param IStream $stream An IStream object. * @throws StreamAccessException If the $stream is not open yet. */ - protected function setStream(IStream $stream) + protected function setStream(IStream $stream): void { if ($stream->isOpen() === false) { $msg = 'An AbstractStreamAccess do not accept closed streams to be read.'; diff --git a/src/qtism/common/storage/BinaryStreamAccess.php b/src/qtism/common/storage/BinaryStreamAccess.php index faadda40e..bff1c6cba 100644 --- a/src/qtism/common/storage/BinaryStreamAccess.php +++ b/src/qtism/common/storage/BinaryStreamAccess.php @@ -38,7 +38,7 @@ class BinaryStreamAccess extends AbstractStreamAccess * @param IStream $stream An IStream object. * @throws StreamAccessException If the $stream is not open yet. */ - protected function setStream(IStream $stream) + protected function setStream(IStream $stream): void { if ($stream->isOpen() === false) { $msg = 'A BinaryStreamAccess do not accept closed streams to be read.'; @@ -54,7 +54,7 @@ protected function setStream(IStream $stream) * @return int * @throws BinaryStreamAccessException */ - public function readTinyInt() + public function readTinyInt(): int { try { $bin = $this->getStream()->read(1); @@ -63,6 +63,8 @@ public function readTinyInt() } catch (StreamException $e) { $this->handleBinaryStreamException($e, BinaryStreamAccessException::TINYINT); } + + return -1; } /** @@ -71,7 +73,7 @@ public function readTinyInt() * @param int $tinyInt * @throws BinaryStreamAccessException */ - public function writeTinyInt($tinyInt) + public function writeTinyInt($tinyInt): void { try { $this->getStream()->write(chr($tinyInt)); @@ -86,7 +88,7 @@ public function writeTinyInt($tinyInt) * @return int * @throws BinaryStreamAccessException */ - public function readShort() + public function readShort(): int { try { $bin = $this->getStream()->read(2); @@ -95,6 +97,8 @@ public function readShort() } catch (StreamException $e) { $this->handleBinaryStreamException($e, BinaryStreamAccessException::SHORT); } + + return -1; } /** @@ -103,7 +107,7 @@ public function readShort() * @param int $short * @throws BinaryStreamAccessException */ - public function writeShort($short) + public function writeShort($short): void { try { $this->getStream()->write(pack('S', $short)); @@ -118,15 +122,17 @@ public function writeShort($short) * @return int * @throws BinaryStreamAccessException */ - public function readInteger() + public function readInteger(): int { try { $bin = $this->getStream()->read(4); - return current(unpack('l', $bin)); + return (int)current(unpack('l', $bin)); } catch (StreamException $e) { $this->handleBinaryStreamException($e, BinaryStreamAccessException::INT); } + + return -1; } /** @@ -135,7 +141,7 @@ public function readInteger() * @param int $int * @throws BinaryStreamAccessException */ - public function writeInteger($int) + public function writeInteger($int): void { try { $this->getStream()->write(pack('l', $int)); @@ -147,10 +153,10 @@ public function writeInteger($int) /** * Read a double precision float from the current binary stream. * - * @return int + * @return float * @throws BinaryStreamAccessException */ - public function readFloat() + public function readFloat(): float { try { $bin = $this->getStream()->read(8); @@ -159,6 +165,8 @@ public function readFloat() } catch (StreamException $e) { $this->handleBinaryStreamException($e, BinaryStreamAccessException::FLOAT); } + + return 0.00; } /** @@ -167,7 +175,7 @@ public function readFloat() * @param float $float * @throws BinaryStreamAccessException */ - public function writeFloat($float) + public function writeFloat($float): void { try { $this->getStream()->write(pack('d', $float)); @@ -182,7 +190,7 @@ public function writeFloat($float) * @return bool * @throws BinaryStreamAccessException */ - public function readBoolean() + public function readBoolean(): bool { try { $int = ord($this->getStream()->read(1)); @@ -191,6 +199,8 @@ public function readBoolean() } catch (StreamException $e) { $this->handleBinaryStreamException($e, BinaryStreamAccessException::BOOLEAN); } + + return false; } /** @@ -199,7 +209,7 @@ public function readBoolean() * @param bool $boolean * @throws BinaryStreamAccessException */ - public function writeBoolean($boolean) + public function writeBoolean($boolean): void { try { $val = ($boolean === true) ? 1 : 0; @@ -215,7 +225,7 @@ public function writeBoolean($boolean) * @return string * @throws BinaryStreamAccessException */ - public function readString() + public function readString(): string { try { $binLength = $this->getStream()->read(2); @@ -225,6 +235,8 @@ public function readString() } catch (StreamException $e) { $this->handleBinaryStreamException($e, BinaryStreamAccessException::STRING); } + + return ''; } /** @@ -233,11 +245,11 @@ public function readString() * @param string $string * @throws BinaryStreamAccessException */ - public function writeString($string) + public function writeString($string): void { // $maxLen = 2^16 -1 = max val of unsigned short integer. $maxLen = 65535; - $len = strlen($string); + $len = strlen((string)$string); if ($len > $maxLen) { $len = $maxLen; @@ -257,7 +269,7 @@ public function writeString($string) * @return string A binary string. * @throws BinaryStreamAccessException */ - public function readBinary() + public function readBinary(): string { return $this->readString(); } @@ -268,7 +280,7 @@ public function readBinary() * @param string $binary * @throws BinaryStreamAccessException */ - public function writeBinary($binary) + public function writeBinary($binary): void { $this->writeString($binary); } @@ -276,10 +288,10 @@ public function writeBinary($binary) /** * Read a DateTime from the current binary stream. * - * @return DateTime A DateTime object. + * @return DateTime|null A DateTime object. * @throws BinaryStreamAccessException */ - public function readDateTime() + public function readDateTime(): ?DateTime { try { $timeStamp = current(unpack('l', $this->getStream()->read(4))); @@ -289,6 +301,8 @@ public function readDateTime() } catch (StreamException $e) { $this->handleBinaryStreamException($e, BinaryStreamAccessException::DATETIME); } + + return null; } /** @@ -297,7 +311,7 @@ public function readDateTime() * @param DateTime $dateTime A DateTime object. * @throws BinaryStreamAccessException */ - public function writeDateTime(DateTime $dateTime) + public function writeDateTime(DateTime $dateTime): void { try { $timeStamp = $dateTime->getTimestamp(); @@ -315,7 +329,7 @@ public function writeDateTime(DateTime $dateTime) * @param bool $read Whether or not the error occurred in a reading/writing context. * @throws BinaryStreamAccessException The resulting BinaryStreamAccessException. */ - protected function handleBinaryStreamException(StreamException $e, $typeError, $read = true) + protected function handleBinaryStreamException(StreamException $e, $typeError, $read = true): void { $strType = 'unknown datatype'; diff --git a/src/qtism/common/storage/BinaryStreamAccessException.php b/src/qtism/common/storage/BinaryStreamAccessException.php index 5b4c6480c..188999a8a 100644 --- a/src/qtism/common/storage/BinaryStreamAccessException.php +++ b/src/qtism/common/storage/BinaryStreamAccessException.php @@ -35,54 +35,54 @@ class BinaryStreamAccessException extends StreamAccessException * * @var int */ - const TINYINT = 2; + public const TINYINT = 2; /** * An error occurred while reading|writing a short int. * * @var int */ - const SHORT = 3; + public const SHORT = 3; /** * An error occurred while reading|writing an int. * * @var int */ - const INT = 4; + public const INT = 4; /** * An error occurred while reading|writing a float. * * @var int */ - const FLOAT = 5; + public const FLOAT = 5; /** * An error occurred while reading|writing a boolean. * * @var int */ - const BOOLEAN = 6; + public const BOOLEAN = 6; /** * An error occurred while reading|writing a string. * * @var int */ - const STRING = 7; + public const STRING = 7; /** * An error occurred while reading|writing binary data. * * @var int */ - const BINARY = 8; + public const BINARY = 8; /** * An error occurred while reading|writing a DateTime. * * @var int */ - const DATETIME = 9; + public const DATETIME = 9; } diff --git a/src/qtism/common/storage/IStream.php b/src/qtism/common/storage/IStream.php index f61fcbf8d..28d313c7b 100644 --- a/src/qtism/common/storage/IStream.php +++ b/src/qtism/common/storage/IStream.php @@ -40,7 +40,7 @@ public function open(); * * @return bool */ - public function isOpen(); + public function isOpen(): bool; /** * Write $data into the stream. @@ -49,7 +49,7 @@ public function isOpen(); * @return int The length of the written $data. * @throws StreamException If an error occurs while writing the stream. The error code will be StreamException::WRITE or StreamException::NOT_OPEN. */ - public function write($data); + public function write($data): int; /** * Close the stream. @@ -79,7 +79,7 @@ public function rewind(); * @return bool * @throws StreamException If the stream is not open. The error code will be StreamException::NOT_OPEN; */ - public function eof(); + public function eof(): bool; /** * Flushes the stream. In other words, the content of the stream is empty after diff --git a/src/qtism/common/storage/MemoryStream.php b/src/qtism/common/storage/MemoryStream.php index 2738167be..ff8bbda36 100644 --- a/src/qtism/common/storage/MemoryStream.php +++ b/src/qtism/common/storage/MemoryStream.php @@ -68,7 +68,7 @@ public function __construct($binary = '') * * @param string $binary A binary string. */ - protected function setBinary($binary) + protected function setBinary($binary): void { $this->binary = $binary; } @@ -78,7 +78,7 @@ protected function setBinary($binary) * * @return string A binary string. */ - public function getBinary() + public function getBinary(): string { return $this->binary; } @@ -88,7 +88,7 @@ public function getBinary() * * @return int The position in the stream. Position begins at 0. */ - public function getPosition() + public function getPosition(): int { return $this->position; } @@ -98,7 +98,7 @@ public function getPosition() * * @param int $position A position in the stream to be set. */ - protected function setPosition($position) + protected function setPosition($position): void { $this->position = $position; } @@ -108,7 +108,7 @@ protected function setPosition($position) * * @param int $length */ - protected function setLength($length) + protected function setLength($length): void { $this->length = $length; } @@ -118,7 +118,7 @@ protected function setLength($length) * * @return int */ - public function getLength() + public function getLength(): int { return $this->length; } @@ -126,7 +126,7 @@ public function getLength() /** * @param $i */ - protected function incrementLength($i) + protected function incrementLength($i): void { $this->length += $i; } @@ -136,7 +136,7 @@ protected function incrementLength($i) * * @param int $i The increment to be applied on the current position in the stream. */ - protected function incrementPosition($i) + protected function incrementPosition($i): void { $this->position += $i; } @@ -146,7 +146,7 @@ protected function incrementPosition($i) * * @throws MemoryStreamException If the stream is already opened. */ - public function open() + public function open(): void { if ($this->isOpen() === true) { $msg = 'The MemoryStream is already open.'; @@ -161,7 +161,7 @@ public function open() * * @throws MemoryStreamException If the stream is closed prior the call. */ - public function close() + public function close(): void { if ($this->isOpen() === false) { $msg = 'Cannot call close() a closed stream.'; @@ -178,7 +178,7 @@ public function close() * @return string The read value or an empty string if length = 0. * @throws MemoryStreamException If the read is out of the bounds of the stream e.g. EOF reach. */ - public function read($length) + public function read($length): string { if ($this->isOpen() === false) { $msg = 'Cannot read from a closed MemoryStream.'; @@ -216,7 +216,7 @@ public function read($length) * @return int The amount of written bytes. * @throws MemoryStreamException */ - public function write($data) + public function write($data): int { if ($this->isOpen() === false) { $msg = 'Cannot write in a closed MemoryStream.'; @@ -236,7 +236,7 @@ public function write($data) $this->binary = ($part1 . $data . $part2); } - $dataLen = strlen($data); + $dataLen = strlen((string)$data); $this->incrementPosition($dataLen); $this->incrementLength($dataLen); @@ -248,7 +248,7 @@ public function write($data) * * @return bool */ - public function eof() + public function eof(): bool { return $this->isOpen() === false || $this->getPosition() >= $this->getLength(); } @@ -258,7 +258,7 @@ public function eof() * * @return bool */ - public function isOpen() + public function isOpen(): bool { return $this->open; } @@ -268,7 +268,7 @@ public function isOpen() * * @throws MemoryStreamException If the binary stream is not open. */ - public function rewind() + public function rewind(): void { if ($this->isOpen() === false) { $msg = 'Cannot call rewind() on a closed MemoryStream.'; @@ -283,7 +283,7 @@ public function rewind() * * @param bool $open */ - protected function setOpen($open) + protected function setOpen($open): void { $this->open = $open; } @@ -293,7 +293,7 @@ protected function setOpen($open) * * @throws MemoryStreamException If the binary stream is closed. */ - public function flush() + public function flush(): void { if ($this->isOpen() === true) { $this->setBinary(''); diff --git a/src/qtism/common/storage/StreamAccessException.php b/src/qtism/common/storage/StreamAccessException.php index 1561f58ed..af0b982ca 100644 --- a/src/qtism/common/storage/StreamAccessException.php +++ b/src/qtism/common/storage/StreamAccessException.php @@ -37,14 +37,14 @@ class StreamAccessException extends Exception * * @var int */ - const UNKNOWN = 0; + public const UNKNOWN = 0; /** * A closed IStream object is given as the stream to be read. * * @var int */ - const NOT_OPEN = 1; + public const NOT_OPEN = 1; /** * The AbstractStreamAccess object that caused the error. @@ -72,7 +72,7 @@ public function __construct($message, AbstractStreamAccess $source, $code = 0, E * * @param AbstractStreamAccess $source An AbstractStreamAccess object. */ - protected function setSource(AbstractStreamAccess $source) + protected function setSource(AbstractStreamAccess $source): void { $this->source = $source; } @@ -82,7 +82,7 @@ protected function setSource(AbstractStreamAccess $source) * * @return AbstractStreamAccess An AbstractStreamAccess object. */ - public function getSource() + public function getSource(): AbstractStreamAccess { return $this->source; } diff --git a/src/qtism/common/storage/StreamException.php b/src/qtism/common/storage/StreamException.php index ed498fdca..90825bd4b 100644 --- a/src/qtism/common/storage/StreamException.php +++ b/src/qtism/common/storage/StreamException.php @@ -36,55 +36,55 @@ abstract class StreamException extends Exception * * @var int */ - const UNKNOWN = 0; + public const UNKNOWN = 0; /** * Error while opening a data stream. * * @var int */ - const OPEN = 1; + public const OPEN = 1; /** * Error while writing a data stream. * * @var int */ - const WRITE = 2; + public const WRITE = 2; /** * Error while closing a data stream. * * @var int */ - const CLOSE = 3; + public const CLOSE = 3; /** * Error while reading a data stream. * * @var int */ - const READ = 4; + public const READ = 4; /** * Error while reading, writing, eof, or closing * but the stream is not open. */ - const NOT_OPEN = 5; + public const NOT_OPEN = 5; /** * Error while opening the stream but it is already opened. * * @var int */ - const ALREADY_OPEN = 6; + public const ALREADY_OPEN = 6; /** * Error during a rewind call. * * @var int */ - const REWIND = 7; + public const REWIND = 7; /** * The IStream object where in the error occurred. @@ -112,7 +112,7 @@ public function __construct($message, IStream $source, $code = 0, Exception $pre * * @return IStream An IStream object. */ - public function getSource() + public function getSource(): IStream { return $this->source; } @@ -122,7 +122,7 @@ public function getSource() * * @param IStream $source An IStream object. */ - protected function setSource(IStream $source) + protected function setSource(IStream $source): void { $this->source = $source; } diff --git a/src/qtism/common/utils/Arrays.php b/src/qtism/common/utils/Arrays.php index 303aa627f..b06467ce8 100644 --- a/src/qtism/common/utils/Arrays.php +++ b/src/qtism/common/utils/Arrays.php @@ -34,7 +34,7 @@ class Arrays * @param array $array An array * @return bool */ - public static function isAssoc(array $array) + public static function isAssoc(array $array): bool { return array_keys($array) !== range(0, count($array) - 1); } diff --git a/src/qtism/common/utils/Exception.php b/src/qtism/common/utils/Exception.php index 085420efc..1292f8da7 100644 --- a/src/qtism/common/utils/Exception.php +++ b/src/qtism/common/utils/Exception.php @@ -46,7 +46,7 @@ class Exception * @param true $withClassName Whether to show the Exception class name. * @return string */ - public static function formatMessage(\Exception $e, $withClassName = true) + public static function formatMessage(\Exception $e, $withClassName = true): string { $returnValue = ''; diff --git a/src/qtism/common/utils/Reflection.php b/src/qtism/common/utils/Reflection.php index b30b37ea4..a7340aaeb 100644 --- a/src/qtism/common/utils/Reflection.php +++ b/src/qtism/common/utils/Reflection.php @@ -40,6 +40,7 @@ class Reflection * @return mixed An instance of $class * @see http://www.php.net/manual/en/reflectionclass.newinstanceargs.php#99517 The awful bug! */ + #[\ReturnTypeWillChange] public static function newInstance(ReflectionClass $class, $args = []) { if (empty($args)) { @@ -89,7 +90,7 @@ public static function shortClassName($object) * @param string $className A class name. It can be fully qualified. * @return bool */ - public static function isInstanceOf($object, $className) + public static function isInstanceOf($object, $className): bool { $givenType = get_class($object); diff --git a/src/qtism/common/utils/Time.php b/src/qtism/common/utils/Time.php index af69183e3..8c2b94c4b 100644 --- a/src/qtism/common/utils/Time.php +++ b/src/qtism/common/utils/Time.php @@ -39,7 +39,7 @@ class Time * @param DateTime $time2 * @return int a number of seconds. */ - public static function timeDiffSeconds(DateTime $time1, DateTime $time2) + public static function timeDiffSeconds(DateTime $time1, DateTime $time2): int { $interval = $time1->diff($time2); @@ -52,7 +52,7 @@ public static function timeDiffSeconds(DateTime $time1, DateTime $time2) * @param DateInterval $interval * @return int */ - public static function totalSeconds(DateInterval $interval) + public static function totalSeconds(DateInterval $interval): int { $sYears = 31536000 * $interval->y; $sMonths = 30 * 24 * 3600 * $interval->m; @@ -72,7 +72,7 @@ public static function totalSeconds(DateInterval $interval) * @param DateTime $time * @return DateTime */ - public static function toUtc(DateTime $time) + public static function toUtc(DateTime $time): DateTime { $newTime = clone $time; $newTime->setTimezone(new DateTimeZone('UTC')); diff --git a/src/qtism/common/utils/Url.php b/src/qtism/common/utils/Url.php index 22251c05c..845ce1294 100644 --- a/src/qtism/common/utils/Url.php +++ b/src/qtism/common/utils/Url.php @@ -35,7 +35,7 @@ class Url * @param string $urlComponent * @return string The trimmed URL or URL component. */ - public static function trim($urlComponent) + public static function trim($urlComponent): string { // Trim is UTF-8 safe if the second argument does not // contain multi-byte chars. @@ -49,7 +49,7 @@ public static function trim($urlComponent) * @param string $urlComponent * @return string The trimmed URL or URL component. */ - public static function ltrim($urlComponent) + public static function ltrim($urlComponent): string { return ltrim($urlComponent, "/\t\n\r\0\x0B"); } @@ -61,7 +61,7 @@ public static function ltrim($urlComponent) * @param string $urlComponent * @return string The trimmed URL or URL component. */ - public static function rtrim($urlComponent) + public static function rtrim($urlComponent): string { return rtrim($urlComponent, "/\t\n\r\0\x0B"); } @@ -72,7 +72,7 @@ public static function rtrim($urlComponent) * @param string $url * @return bool */ - public static function isRelative($url) + public static function isRelative($url): bool { return (preg_match("/^[a-z][a-z0-9+\-\.]+:(\/\/){0,1}|^\//i", $url) === 0) ? true : false; } diff --git a/src/qtism/common/utils/Version.php b/src/qtism/common/utils/Version.php index b2c2f8fcb..df5cd4463 100644 --- a/src/qtism/common/utils/Version.php +++ b/src/qtism/common/utils/Version.php @@ -54,19 +54,21 @@ class Version * @param string $version1 A version number. * @param string $version2 A version number * @param string $operator An operator. - * @return mixed + * + * @return bool + * * @throws InvalidArgumentException * @see http://semver.org Semantic Versioning */ - public static function compare($version1, $version2, $operator = null) + public static function compare($version1, $version2, $operator = null): bool { $version1 = self::sanitize($version1); $version2 = self::sanitize($version2); self::checkOperator($operator); return $operator === null - ? version_compare($version1, $version2) - : version_compare($version1, $version2, $operator); + ? (bool)version_compare($version1, $version2) + : (bool)version_compare($version1, $version2, $operator); } /** @@ -91,7 +93,7 @@ protected static function sanitize(string $version): string * @param string $version A version with major, minor and optional patch version e.g. '2.1' or '2.1.1'. * @throws InvalidArgumentException when version is not supported. */ - protected static function checkVersion(string $version) + protected static function checkVersion(string $version): void { } @@ -101,7 +103,7 @@ protected static function checkVersion(string $version) * @param string|null $operator * @throws InvalidArgumentException when the operator is not known. */ - private static function checkOperator($operator) + private static function checkOperator($operator): void { $knownOperators = ['<', 'lt', '<=', 'le', '>', 'gt', '>=', 'ge', '==', '=', 'eq', '!=', '<>', 'ne']; if ($operator !== null && !in_array($operator, $knownOperators, true)) { diff --git a/src/qtism/data/AssessmentItem.php b/src/qtism/data/AssessmentItem.php index fc627693e..ffcd4f8b7 100644 --- a/src/qtism/data/AssessmentItem.php +++ b/src/qtism/data/AssessmentItem.php @@ -226,7 +226,7 @@ public function __construct($identifier, $title, $timeDependent, $lang = '') * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false)) { $this->identifier = $identifier; @@ -242,7 +242,7 @@ public function setIdentifier($identifier) * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -253,7 +253,7 @@ public function getIdentifier() * @param string $title A title. * @throws InvalidArgumentException If $title is not a string value. */ - public function setTitle($title) + public function setTitle($title): void { if (is_string($title)) { $this->title = $title; @@ -268,7 +268,7 @@ public function setTitle($title) * * @return string A title. */ - public function getTitle() + public function getTitle(): string { return $this->title; } @@ -279,7 +279,7 @@ public function getTitle() * @param string $lang A language code. * @throws InvalidArgumentException If $lang is not a string. */ - public function setLang($lang = '') + public function setLang($lang = ''): void { if (is_string($lang)) { $this->lang = $lang; @@ -295,7 +295,7 @@ public function setLang($lang = '') * @param string $label A string with at most 256 characters. * @throws InvalidArgumentException If $label is not a string with at most 256 characters. */ - public function setLabel($label) + public function setLabel($label): void { if (Format::isString256($label) === true) { $this->label = $label; @@ -310,7 +310,7 @@ public function setLabel($label) * * @return bool */ - public function hasLabel() + public function hasLabel(): bool { return $this->getLabel() !== ''; } @@ -320,7 +320,7 @@ public function hasLabel() * * @return string A string with at most 256 characters. */ - public function getLabel() + public function getLabel(): string { return $this->label; } @@ -330,7 +330,7 @@ public function getLabel() * * @return string A language code. */ - public function getLang() + public function getLang(): string { return $this->lang; } @@ -340,7 +340,7 @@ public function getLang() * * @return bool */ - public function hasLang() + public function hasLang(): bool { $lang = $this->getLang(); @@ -353,7 +353,7 @@ public function hasLang() * @param bool $adaptive Adaptive or not. * @throws InvalidArgumentException If $adaptive is not a boolean value. */ - public function setAdaptive($adaptive) + public function setAdaptive($adaptive): void { if (is_bool($adaptive)) { $this->adaptive = $adaptive; @@ -368,7 +368,7 @@ public function setAdaptive($adaptive) * * @return bool */ - public function isAdaptive() + public function isAdaptive(): bool { return $this->adaptive; } @@ -379,7 +379,7 @@ public function isAdaptive() * @param bool $timeDependent Time dependent or not. * @throws InvalidArgumentException If $timeDependent is not a boolean value. */ - public function setTimeDependent($timeDependent) + public function setTimeDependent($timeDependent): void { if (is_bool($timeDependent)) { $this->timeDependent = $timeDependent; @@ -394,7 +394,7 @@ public function setTimeDependent($timeDependent) * * @return bool */ - public function isTimeDependent() + public function isTimeDependent(): bool { return $this->timeDependent; } @@ -405,7 +405,7 @@ public function isTimeDependent() * @param string $toolName A tool name with at most 256 characters. * @throws InvalidArgumentException If $toolName is not a string value with at most 256 characters. */ - public function setToolName($toolName) + public function setToolName($toolName): void { if (Format::isString256($toolName) === true) { $this->toolName = $toolName; @@ -420,7 +420,7 @@ public function setToolName($toolName) * * @return string */ - public function getToolName() + public function getToolName(): string { return $this->toolName; } @@ -430,7 +430,7 @@ public function getToolName() * * @return bool */ - public function hasToolName() + public function hasToolName(): bool { return $this->getToolName() !== ''; } @@ -441,7 +441,7 @@ public function hasToolName() * @param string $toolVersion A tool version with at most 256 characters. * @throws InvalidArgumentException If $toolVersion is not a string value with at most 256 characters. */ - public function setToolVersion($toolVersion) + public function setToolVersion($toolVersion): void { if (Format::isString256($toolVersion) === true) { $this->toolVersion = $toolVersion; @@ -456,7 +456,7 @@ public function setToolVersion($toolVersion) * * @return string A tool version with at most 256 characters. */ - public function getToolVersion() + public function getToolVersion(): string { return $this->toolVersion; } @@ -466,7 +466,7 @@ public function getToolVersion() * * @return bool */ - public function hasToolVersion() + public function hasToolVersion(): bool { return $this->getToolVersion() !== ''; } @@ -476,7 +476,7 @@ public function hasToolVersion() * * @param ResponseDeclarationCollection $responseDeclarations A collection of ResponseDeclaration objects */ - public function setResponseDeclarations(ResponseDeclarationCollection $responseDeclarations) + public function setResponseDeclarations(ResponseDeclarationCollection $responseDeclarations): void { $this->responseDeclarations = $responseDeclarations; } @@ -486,7 +486,7 @@ public function setResponseDeclarations(ResponseDeclarationCollection $responseD * * @return ResponseDeclarationCollection A collection of ResponseDeclaration objects. */ - public function getResponseDeclarations() + public function getResponseDeclarations(): ResponseDeclarationCollection { return $this->responseDeclarations; } @@ -496,7 +496,7 @@ public function getResponseDeclarations() * * @param OutcomeDeclarationCollection $outcomeDeclarations A collection of OutcomeDeclaration objects. */ - public function setOutcomeDeclarations(OutcomeDeclarationCollection $outcomeDeclarations) + public function setOutcomeDeclarations(OutcomeDeclarationCollection $outcomeDeclarations): void { $this->outcomeDeclarations = $outcomeDeclarations; } @@ -506,7 +506,7 @@ public function setOutcomeDeclarations(OutcomeDeclarationCollection $outcomeDecl * * @return OutcomeDeclarationCollection A collection of OutcomeDeclaration objects. */ - public function getOutcomeDeclarations() + public function getOutcomeDeclarations(): OutcomeDeclarationCollection { return $this->outcomeDeclarations; } @@ -516,7 +516,7 @@ public function getOutcomeDeclarations() * * @param TemplateDeclarationCollection $templateDeclarations A collection of TemplateDeclaration objects. */ - public function setTemplateDeclarations(TemplateDeclarationCollection $templateDeclarations) + public function setTemplateDeclarations(TemplateDeclarationCollection $templateDeclarations): void { $this->templateDeclarations = $templateDeclarations; } @@ -526,7 +526,7 @@ public function setTemplateDeclarations(TemplateDeclarationCollection $templateD * * @return TemplateDeclarationCollection A collection of TemplateDeclaration objects. */ - public function getTemplateDeclarations() + public function getTemplateDeclarations(): TemplateDeclarationCollection { return $this->templateDeclarations; } @@ -538,7 +538,7 @@ public function getTemplateDeclarations() * * @param TemplateProcessing $templateProcessing A TemplateProcessing object or null. */ - public function setTemplateProcessing(TemplateProcessing $templateProcessing = null) + public function setTemplateProcessing(TemplateProcessing $templateProcessing = null): void { $this->templateProcessing = $templateProcessing; } @@ -549,7 +549,7 @@ public function setTemplateProcessing(TemplateProcessing $templateProcessing = n * * @return TemplateProcessing A TemplateProcessing object or null. */ - public function getTemplateProcessing() + public function getTemplateProcessing(): ?TemplateProcessing { return $this->templateProcessing; } @@ -559,7 +559,7 @@ public function getTemplateProcessing() * * @return bool */ - public function hasTemplateProcessing() + public function hasTemplateProcessing(): bool { return $this->getTemplateProcessing() !== null; } @@ -569,7 +569,7 @@ public function hasTemplateProcessing() * * @param StylesheetCollection $stylesheets A collection of Stylesheet objects. */ - public function setStylesheets(StylesheetCollection $stylesheets) + public function setStylesheets(StylesheetCollection $stylesheets): void { $this->stylesheets = $stylesheets; } @@ -579,7 +579,7 @@ public function setStylesheets(StylesheetCollection $stylesheets) * * @return StylesheetCollection A collection of Stylesheet objects. */ - public function getStylesheets() + public function getStylesheets(): StylesheetCollection { return $this->stylesheets; } @@ -589,7 +589,7 @@ public function getStylesheets() * * @param ItemBody $itemBody An ItemBody object or the NULL value to state that the item has no content. */ - public function setItemBody(ItemBody $itemBody = null) + public function setItemBody(ItemBody $itemBody = null): void { $this->itemBody = $itemBody; } @@ -597,9 +597,9 @@ public function setItemBody(ItemBody $itemBody = null) /** * Get the ItemBody object representing the content body of the item. * - * @return ItemBody An ItemBody object or the NULL value if the item has no content. + * @return ItemBody|null An ItemBody object or the NULL value if the item has no content. */ - public function getItemBody() + public function getItemBody(): ?ItemBody { return $this->itemBody; } @@ -609,7 +609,7 @@ public function getItemBody() * * @return bool */ - public function hasItemBody() + public function hasItemBody(): bool { return $this->getItemBody() !== null; } @@ -617,9 +617,9 @@ public function hasItemBody() /** * Get the associated ResponseProcessing object. * - * @return ResponseProcessing A ResponseProcessing object or null if no associated response processing. + * @return ResponseProcessing|null A ResponseProcessing object or null if no associated response processing. */ - public function getResponseProcessing() + public function getResponseProcessing(): ?ResponseProcessing { return $this->responseProcessing; } @@ -629,7 +629,7 @@ public function getResponseProcessing() * * @param ResponseProcessing $responseProcessing A ResponseProcessing object or null if no associated response processing. */ - public function setResponseProcessing(ResponseProcessing $responseProcessing = null) + public function setResponseProcessing(ResponseProcessing $responseProcessing = null): void { $this->responseProcessing = $responseProcessing; } @@ -639,7 +639,7 @@ public function setResponseProcessing(ResponseProcessing $responseProcessing = n * * @return bool */ - public function hasResponseProcessing() + public function hasResponseProcessing(): bool { return $this->getResponseProcessing() !== null; } @@ -649,7 +649,7 @@ public function hasResponseProcessing() * * @param ModalFeedbackCollection $modalFeedbacks A collection of ModalFeedback objects. */ - public function setModalFeedbacks(ModalFeedbackCollection $modalFeedbacks) + public function setModalFeedbacks(ModalFeedbackCollection $modalFeedbacks): void { $this->modalFeedbacks = $modalFeedbacks; } @@ -659,7 +659,7 @@ public function setModalFeedbacks(ModalFeedbackCollection $modalFeedbacks) * * @return ModalFeedbackCollection A collection of ModalFeedback objects. */ - public function getModalFeedbacks() + public function getModalFeedbacks(): ModalFeedbackCollection { return $this->modalFeedbacks; } @@ -667,7 +667,7 @@ public function getModalFeedbacks() /** * @return array|ModalFeedbackRuleCollection */ - public function getModalFeedbackRules() + public function getModalFeedbackRules(): ModalFeedbackRuleCollection { $modalFeedbackRules = new ModalFeedbackRuleCollection(); @@ -688,7 +688,7 @@ public function getModalFeedbackRules() * * @return IdentifierCollection */ - public function getEndAttemptIdentifiers() + public function getEndAttemptIdentifiers(): IdentifierCollection { $endAttemptIdentifiers = new IdentifierCollection(); @@ -702,7 +702,7 @@ public function getEndAttemptIdentifiers() /** * @return array|ShufflingCollection */ - public function getShufflings() + public function getShufflings(): ShufflingCollection { $classNames = [ 'choiceInteraction', @@ -728,7 +728,7 @@ public function getShufflings() /** * @return array|ResponseValidityConstraintCollection */ - public function getResponseValidityConstraints() + public function getResponseValidityConstraints(): ResponseValidityConstraintCollection { $classNames = [ 'choiceInteraction', @@ -759,7 +759,7 @@ public function getResponseValidityConstraints() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'assessmentItem'; } @@ -767,7 +767,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge( $this->getResponseDeclarations()->getArrayCopy(), diff --git a/src/qtism/data/AssessmentItemRef.php b/src/qtism/data/AssessmentItemRef.php index 876d08a24..3d0dfe99c 100644 --- a/src/qtism/data/AssessmentItemRef.php +++ b/src/qtism/data/AssessmentItemRef.php @@ -110,7 +110,7 @@ public function __construct($identifier, $href, IdentifierCollection $categories * * @return string A URI. */ - public function getHref() + public function getHref(): string { return $this->href; } @@ -121,7 +121,7 @@ public function getHref() * @param string $href A URI. * @throws InvalidArgumentException If $href is not a string. */ - public function setHref($href) + public function setHref($href): void { if (is_string($href)) { $this->href = $href; @@ -136,7 +136,7 @@ public function setHref($href) * * @return IdentifierCollection A collection of QTI Identifiers. */ - public function getCategories() + public function getCategories(): IdentifierCollection { return $this->categories; } @@ -146,7 +146,7 @@ public function getCategories() * * @param IdentifierCollection $categories A collection of QTI Identifiers. */ - public function setCategories(IdentifierCollection $categories) + public function setCategories(IdentifierCollection $categories): void { $this->categories = $categories; } @@ -156,7 +156,7 @@ public function setCategories(IdentifierCollection $categories) * * @return VariableMappingCollection A collection of VariableMapping objects. */ - public function getVariableMappings() + public function getVariableMappings(): VariableMappingCollection { return $this->variableMappings; } @@ -166,7 +166,7 @@ public function getVariableMappings() * * @param VariableMappingCollection $variableMappings A collection of VariableMapping objects. */ - public function setVariableMappings(VariableMappingCollection $variableMappings) + public function setVariableMappings(VariableMappingCollection $variableMappings): void { $this->variableMappings = $variableMappings; } @@ -176,7 +176,7 @@ public function setVariableMappings(VariableMappingCollection $variableMappings) * * @return WeightCollection A collection of Weight objects. */ - public function getWeights() + public function getWeights(): WeightCollection { return $this->weights; } @@ -186,7 +186,7 @@ public function getWeights() * * @param WeightCollection $weights A collection of Weight objects. */ - public function setWeights(WeightCollection $weights) + public function setWeights(WeightCollection $weights): void { $this->weights = $weights; } @@ -197,7 +197,7 @@ public function setWeights(WeightCollection $weights) * * @return TemplateDefaultCollection A collection of TemplateDefault objects. */ - public function getTemplateDefaults() + public function getTemplateDefaults(): TemplateDefaultCollection { return $this->templateDefaults; } @@ -208,7 +208,7 @@ public function getTemplateDefaults() * * @param TemplateDefaultCollection $templateDefaults A collection of TemplateDefault objects. */ - public function setTemplateDefaults(TemplateDefaultCollection $templateDefaults) + public function setTemplateDefaults(TemplateDefaultCollection $templateDefaults): void { $this->templateDefaults = $templateDefaults; } @@ -216,7 +216,7 @@ public function setTemplateDefaults(TemplateDefaultCollection $templateDefaults) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'assessmentItemRef'; } @@ -224,7 +224,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge( parent::getComponents()->getArrayCopy(), @@ -239,7 +239,7 @@ public function getComponents() /** * @return string */ - public function __toString() + public function __toString(): string { return $this->getIdentifier(); } diff --git a/src/qtism/data/AssessmentItemRefCollection.php b/src/qtism/data/AssessmentItemRefCollection.php index 6381d6fca..84e5f2e29 100644 --- a/src/qtism/data/AssessmentItemRefCollection.php +++ b/src/qtism/data/AssessmentItemRefCollection.php @@ -36,7 +36,7 @@ class AssessmentItemRefCollection extends SectionPartCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a AssessmentItemRef object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof AssessmentItemRef) { $msg = "AssessmentItemRefCollection class only accept AssessmentItemRef objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/AssessmentSection.php b/src/qtism/data/AssessmentSection.php index d47e9f01d..58f0f59da 100644 --- a/src/qtism/data/AssessmentSection.php +++ b/src/qtism/data/AssessmentSection.php @@ -114,7 +114,7 @@ public function __construct($identifier, $title, $visible) * * @return string A title. */ - public function getTitle() + public function getTitle(): string { return $this->title; } @@ -125,7 +125,7 @@ public function getTitle() * @param string $title A title. * @throws InvalidArgumentException If $title is not a string. */ - public function setTitle($title) + public function setTitle($title): void { if (is_string($title)) { $this->title = $title; @@ -140,7 +140,7 @@ public function setTitle($title) * * @return bool true if the section is visible, false if not. */ - public function isVisible() + public function isVisible(): bool { return $this->visible; } @@ -151,7 +151,7 @@ public function isVisible() * @param bool $visible true if it must be visible, false otherwise. * @throws InvalidArgumentException If $visible is not a boolean. */ - public function setVisible($visible) + public function setVisible($visible): void { if (is_bool($visible)) { $this->visible = $visible; @@ -166,7 +166,7 @@ public function setVisible($visible) * * @return bool */ - public function mustKeepTogether() + public function mustKeepTogether(): bool { return $this->keepTogether; } @@ -177,7 +177,7 @@ public function mustKeepTogether() * @param bool $keepTogether true if the items must be kept together, false otherwise. * @throws InvalidArgumentException If $keepTogether is not a boolean. */ - public function setKeepTogether($keepTogether) + public function setKeepTogether($keepTogether): void { if (is_bool($keepTogether)) { $this->keepTogether = $keepTogether; @@ -193,7 +193,7 @@ public function setKeepTogether($keepTogether) * * @return Selection A selection rule. */ - public function getSelection() + public function getSelection(): ?Selection { return $this->selection; } @@ -203,7 +203,7 @@ public function getSelection() * * @param Selection $selection A selection rule. */ - public function setSelection(Selection $selection = null) + public function setSelection(Selection $selection = null): void { $this->selection = $selection; } @@ -213,7 +213,7 @@ public function setSelection(Selection $selection = null) * * @return bool */ - public function hasSelection() + public function hasSelection(): bool { return $this->getSelection() !== null; } @@ -224,7 +224,7 @@ public function hasSelection() * * @return Ordering An Ordering object. */ - public function getOrdering() + public function getOrdering(): ?Ordering { return $this->ordering; } @@ -234,7 +234,7 @@ public function getOrdering() * * @param Ordering $ordering An Ordering object. */ - public function setOrdering(Ordering $ordering = null) + public function setOrdering(Ordering $ordering = null): void { $this->ordering = $ordering; } @@ -244,7 +244,7 @@ public function setOrdering(Ordering $ordering = null) * * @return bool */ - public function hasOrdering() + public function hasOrdering(): bool { return $this->getOrdering() !== null; } @@ -255,7 +255,7 @@ public function hasOrdering() * * @return RubricBlockCollection A collection of RubricBlock objects. */ - public function getRubricBlocks() + public function getRubricBlocks(): RubricBlockCollection { return $this->rubricBlocks; } @@ -266,7 +266,7 @@ public function getRubricBlocks() * * @param RubricBlockCollection $rubricBlocks A collection of RubricBlock objects. */ - public function setRubricBlocks(RubricBlockCollection $rubricBlocks) + public function setRubricBlocks(RubricBlockCollection $rubricBlocks): void { $this->rubricBlocks = $rubricBlocks; } @@ -276,7 +276,7 @@ public function setRubricBlocks(RubricBlockCollection $rubricBlocks) * * @return SectionPartCollection A collection of SectionPart objects. */ - public function getSectionParts() + public function getSectionParts(): SectionPartCollection { return $this->sectionParts; } @@ -286,7 +286,7 @@ public function getSectionParts() * * @param SectionPartCollection $sectionParts A collection of SectionPart objects. */ - public function setSectionParts(SectionPartCollection $sectionParts) + public function setSectionParts(SectionPartCollection $sectionParts): void { $this->sectionParts = $sectionParts; } @@ -294,7 +294,7 @@ public function setSectionParts(SectionPartCollection $sectionParts) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'assessmentSection'; } @@ -302,7 +302,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge( parent::getComponents()->getArrayCopy(), diff --git a/src/qtism/data/AssessmentSectionCollection.php b/src/qtism/data/AssessmentSectionCollection.php index 73a69e0d7..304624a2a 100644 --- a/src/qtism/data/AssessmentSectionCollection.php +++ b/src/qtism/data/AssessmentSectionCollection.php @@ -36,7 +36,7 @@ class AssessmentSectionCollection extends SectionPartCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a AssessmentSection object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof AssessmentSection) { $msg = "AssessmentSectionCollection class only accept AssessmentSection objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/AssessmentSectionRef.php b/src/qtism/data/AssessmentSectionRef.php index 4d942e3fe..71d1d0ee6 100644 --- a/src/qtism/data/AssessmentSectionRef.php +++ b/src/qtism/data/AssessmentSectionRef.php @@ -78,7 +78,7 @@ public function __construct($identifier, $href) * * @param string $href A URI. */ - public function setHref($href) + public function setHref($href): void { $this->href = $href; } @@ -88,7 +88,7 @@ public function setHref($href) * * @return string A URI. */ - public function getHref() + public function getHref(): string { return $this->href; } @@ -96,7 +96,7 @@ public function getHref() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'assessmentSectionRef'; } diff --git a/src/qtism/data/AssessmentTest.php b/src/qtism/data/AssessmentTest.php index 5a1035aa2..ed675a285 100644 --- a/src/qtism/data/AssessmentTest.php +++ b/src/qtism/data/AssessmentTest.php @@ -165,7 +165,7 @@ public function __construct($identifier, $title, TestPartCollection $testParts = * * @return string A QTI Identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -176,7 +176,7 @@ public function getIdentifier() * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false)) { $this->identifier = $identifier; @@ -192,7 +192,7 @@ public function setIdentifier($identifier) * * @return string A title. */ - public function getTitle() + public function getTitle(): string { return $this->title; } @@ -203,7 +203,7 @@ public function getTitle() * @param string $title A title. * @throws InvalidArgumentException If $title is not a string. */ - public function setTitle($title) + public function setTitle($title): void { if (is_string($title)) { $this->title = $title; @@ -219,7 +219,7 @@ public function setTitle($title) * * @return string A tool name or empty string if not specified. */ - public function getToolName() + public function getToolName(): string { return $this->toolName; } @@ -230,7 +230,7 @@ public function getToolName() * @param string $toolName A tool name. * @throws InvalidArgumentException If $toolName is not a string. */ - public function setToolName($toolName) + public function setToolName($toolName): void { if (is_string($toolName)) { $this->toolName = $toolName; @@ -246,7 +246,7 @@ public function setToolName($toolName) * * @return string A tool version. */ - public function getToolVersion() + public function getToolVersion(): string { return $this->toolVersion; } @@ -258,7 +258,7 @@ public function getToolVersion() * @param string $toolVersion A tool version. * @throws InvalidArgumentException If $toolVersion is not a string. */ - public function setToolVersion($toolVersion) + public function setToolVersion($toolVersion): void { if (is_string($toolVersion)) { $this->toolVersion = $toolVersion; @@ -273,7 +273,7 @@ public function setToolVersion($toolVersion) * * @return OutcomeDeclarationCollection A collection of OutcomeDeclaration objects. */ - public function getOutcomeDeclarations() + public function getOutcomeDeclarations(): OutcomeDeclarationCollection { return $this->outcomeDeclarations; } @@ -283,7 +283,7 @@ public function getOutcomeDeclarations() * * @param OutcomeDeclarationCollection $outcomeDeclarations A collection of OutcomeDeclaration objects. */ - public function setOutcomeDeclarations(OutcomeDeclarationCollection $outcomeDeclarations) + public function setOutcomeDeclarations(OutcomeDeclarationCollection $outcomeDeclarations): void { $this->outcomeDeclarations = $outcomeDeclarations; } @@ -293,7 +293,7 @@ public function setOutcomeDeclarations(OutcomeDeclarationCollection $outcomeDecl * * @return TimeLimits A TimeLimits object or null value if not specified. */ - public function getTimeLimits() + public function getTimeLimits(): ?TimeLimits { return $this->timeLimits; } @@ -303,7 +303,7 @@ public function getTimeLimits() * * @param TimeLimits $timeLimits A TimeLimits object. */ - public function setTimeLimits(TimeLimits $timeLimits = null) + public function setTimeLimits(TimeLimits $timeLimits = null): void { $this->timeLimits = $timeLimits; } @@ -313,7 +313,7 @@ public function setTimeLimits(TimeLimits $timeLimits = null) * * @return TestPartCollection A collection of TestPart objects. */ - public function getTestParts() + public function getTestParts(): TestPartCollection { return $this->testParts; } @@ -323,7 +323,7 @@ public function getTestParts() * * @param TestPartCollection $testParts A collection of TestPart objects. */ - public function setTestParts(TestPartCollection $testParts) + public function setTestParts(TestPartCollection $testParts): void { $this->testParts = $testParts; } @@ -334,7 +334,7 @@ public function setTestParts(TestPartCollection $testParts) * * @return OutcomeProcessing An OutcomeProcessing object or null if not specified. */ - public function getOutcomeProcessing() + public function getOutcomeProcessing(): ?OutcomeProcessing { return $this->outcomeProcessing; } @@ -344,7 +344,7 @@ public function getOutcomeProcessing() * * @param OutcomeProcessing $outcomeProcessing An OutcomeProcessing object. */ - public function setOutcomeProcessing(OutcomeProcessing $outcomeProcessing = null) + public function setOutcomeProcessing(OutcomeProcessing $outcomeProcessing = null): void { $this->outcomeProcessing = $outcomeProcessing; } @@ -354,7 +354,7 @@ public function setOutcomeProcessing(OutcomeProcessing $outcomeProcessing = null * * @return bool */ - public function hasOutcomeProcessing() + public function hasOutcomeProcessing(): bool { return $this->getOutcomeProcessing() !== null; } @@ -364,7 +364,7 @@ public function hasOutcomeProcessing() * * @return TestFeedbackCollection A collection of TestFeedback objects. */ - public function getTestFeedbacks() + public function getTestFeedbacks(): TestFeedbackCollection { return $this->testFeedbacks; } @@ -374,7 +374,7 @@ public function getTestFeedbacks() * * @param TestFeedbackCollection A collection of TestFeedback objects. */ - public function setTestFeedbacks(TestFeedbackCollection $testFeedbacks) + public function setTestFeedbacks(TestFeedbackCollection $testFeedbacks): void { $this->testFeedbacks = $testFeedbacks; } @@ -382,7 +382,7 @@ public function setTestFeedbacks(TestFeedbackCollection $testFeedbacks) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'assessmentTest'; } @@ -390,7 +390,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge( $this->getOutcomeDeclarations()->getArrayCopy(), @@ -415,7 +415,7 @@ public function getComponents() * * @return bool */ - public function isExclusivelyLinear() + public function isExclusivelyLinear(): bool { $testParts = $this->getTestParts(); if (count($testParts) === 0) { @@ -440,7 +440,7 @@ public function isExclusivelyLinear() * * @return bool */ - public function hasTimeLimits() + public function hasTimeLimits(): bool { return $this->getTimeLimits() !== null; } @@ -467,7 +467,7 @@ public function __clone() * paths due to the new possibilities afforded by the branch. * @throws BranchRuleTargetException if backward or recursive branching is found. */ - private function addPathsWithBranches($paths, $prevItem, $targetItem, $itemidToIndex, $component) + private function addPathsWithBranches($paths, $prevItem, $targetItem, $itemidToIndex, $component): array { $newPaths = []; @@ -622,7 +622,7 @@ private function addPathsWithBranches($paths, $prevItem, $targetItem, $itemidToI * @return array of array of \qtism\data\AssessmentItemRef | array of \qtism\data\AssessmentItemRefCollection * @throws BranchRuleTargetException if branching is recursive of backward. */ - public function getPossiblePaths($asArray) + public function getPossiblePaths($asArray): array { $paths = []; @@ -800,7 +800,7 @@ public function getPossiblePaths($asArray) * possibilities given by the branch. * @throws BranchRuleTargetException if branching is recursive of backward. */ - private function branchAnalysis($branch, $component, $paths, &$succsItem, $itemidToIndex, $items, $sections, $testparts) + private function branchAnalysis($branch, $component, $paths, &$succsItem, $itemidToIndex, $items, $sections, $testparts): array { // Special cases @@ -984,7 +984,7 @@ private function branchAnalysis($branch, $component, $paths, &$succsItem, $itemi * for this AssessmentTest. * @throws BranchRuleTargetException */ - public function getShortestPaths() + public function getShortestPaths(): array { $paths = $this->getPossiblePaths(false); $minCount = PHP_INT_MAX; @@ -1015,7 +1015,7 @@ public function getShortestPaths() * for this AssessmentTest. * @throws BranchRuleTargetException */ - public function getLongestPaths() + public function getLongestPaths(): array { $paths = $this->getPossiblePaths(false); $maxCount = 0; diff --git a/src/qtism/data/BranchRuleTargetException.php b/src/qtism/data/BranchRuleTargetException.php index aa3dc6086..caa5fb8ef 100644 --- a/src/qtism/data/BranchRuleTargetException.php +++ b/src/qtism/data/BranchRuleTargetException.php @@ -37,21 +37,21 @@ class BranchRuleTargetException extends Exception implements QtiSdkPackageConten * * @var int */ - const UNKNOWN_TARGET = 0; + public const UNKNOWN_TARGET = 0; /** * The target may or will cause a recursive loop in the test. * * @var int */ - const RECURSIVE_BRANCHING = 1; + public const RECURSIVE_BRANCHING = 1; /** * The target may or will go to an item already passed. * * @var int */ - const BACKWARD_BRANCHING = 2; + public const BACKWARD_BRANCHING = 2; /** * @var QtiComponent The AssessmentTest, AssessmentSection or Assessment ItemRef whose BranchRule caused diff --git a/src/qtism/data/ExtendedAssessmentItemRef.php b/src/qtism/data/ExtendedAssessmentItemRef.php index fcde36a1a..41f89d34c 100644 --- a/src/qtism/data/ExtendedAssessmentItemRef.php +++ b/src/qtism/data/ExtendedAssessmentItemRef.php @@ -181,7 +181,7 @@ public function __construct($identifier, $href, IdentifierCollection $categories * * @param OutcomeDeclarationCollection $outcomeDeclarations A collection of OutcomeDeclaration objects. */ - public function setOutcomeDeclarations(OutcomeDeclarationCollection $outcomeDeclarations) + public function setOutcomeDeclarations(OutcomeDeclarationCollection $outcomeDeclarations): void { $this->outcomeDeclarations = $outcomeDeclarations; } @@ -191,7 +191,7 @@ public function setOutcomeDeclarations(OutcomeDeclarationCollection $outcomeDecl * * @return OutcomeDeclarationCollection A collection of OutcomeDeclaration objects. */ - public function getOutcomeDeclarations() + public function getOutcomeDeclarations(): OutcomeDeclarationCollection { return $this->outcomeDeclarations; } @@ -201,7 +201,7 @@ public function getOutcomeDeclarations() * * @param ResponseProcessing $responseProcessing A ResponseProcessing object or null if no response processing described. */ - public function setResponseProcessing(ResponseProcessing $responseProcessing = null) + public function setResponseProcessing(ResponseProcessing $responseProcessing = null): void { $this->responseProcessing = $responseProcessing; } @@ -211,7 +211,7 @@ public function setResponseProcessing(ResponseProcessing $responseProcessing = n * * @return ResponseProcessing A ResponseProcessing object or null if no response processing described. */ - public function getResponseProcessing() + public function getResponseProcessing(): ?ResponseProcessing { return $this->responseProcessing; } @@ -221,7 +221,7 @@ public function getResponseProcessing() * * @return bool */ - public function hasResponseProcessing() + public function hasResponseProcessing(): bool { return $this->getResponseProcessing() !== null; } @@ -231,7 +231,7 @@ public function hasResponseProcessing() * * @param TemplateProcessing $templateProcessing */ - public function setTemplateProcessing(TemplateProcessing $templateProcessing = null) + public function setTemplateProcessing(TemplateProcessing $templateProcessing = null): void { $this->templateProcessing = $templateProcessing; } @@ -241,7 +241,7 @@ public function setTemplateProcessing(TemplateProcessing $templateProcessing = n * * @return TemplateProcessing */ - public function getTemplateProcessing() + public function getTemplateProcessing(): ?TemplateProcessing { return $this->templateProcessing; } @@ -251,7 +251,7 @@ public function getTemplateProcessing() * * @return bool */ - public function hasTemplateProcessing() + public function hasTemplateProcessing(): bool { return $this->getTemplateProcessing() !== null; } @@ -261,7 +261,7 @@ public function hasTemplateProcessing() * * @param OutcomeDeclaration $outcomeDeclaration An OutcomeDeclaration object. */ - public function addOutcomeDeclaration(OutcomeDeclaration $outcomeDeclaration) + public function addOutcomeDeclaration(OutcomeDeclaration $outcomeDeclaration): void { $this->getOutcomeDeclarations()->attach($outcomeDeclaration); } @@ -271,7 +271,7 @@ public function addOutcomeDeclaration(OutcomeDeclaration $outcomeDeclaration) * * @param OutcomeDeclaration $outcomeDeclaration An OutcomeDeclaration object. */ - public function removeOutcomeDeclaration(OutcomeDeclaration $outcomeDeclaration) + public function removeOutcomeDeclaration(OutcomeDeclaration $outcomeDeclaration): void { $this->getOutcomeDeclarations()->detach($outcomeDeclaration); } @@ -281,7 +281,7 @@ public function removeOutcomeDeclaration(OutcomeDeclaration $outcomeDeclaration) * * @param ResponseDeclarationCollection $responseDeclarations A collection of ResponseDeclaration objects. */ - public function setResponseDeclarations(ResponseDeclarationCollection $responseDeclarations) + public function setResponseDeclarations(ResponseDeclarationCollection $responseDeclarations): void { $this->responseDeclarations = $responseDeclarations; } @@ -291,7 +291,7 @@ public function setResponseDeclarations(ResponseDeclarationCollection $responseD * * @return ResponseDeclarationCollection A collection of ResponseDeclaration objects. */ - public function getResponseDeclarations() + public function getResponseDeclarations(): ResponseDeclarationCollection { return $this->responseDeclarations; } @@ -301,7 +301,7 @@ public function getResponseDeclarations() * * @param ResponseDeclaration $responseDeclaration A ResponseDeclaration object. */ - public function addResponseDeclaration(ResponseDeclaration $responseDeclaration) + public function addResponseDeclaration(ResponseDeclaration $responseDeclaration): void { $this->getResponseDeclarations()->attach($responseDeclaration); } @@ -311,7 +311,7 @@ public function addResponseDeclaration(ResponseDeclaration $responseDeclaration) * * @param ResponseDeclaration $responseDeclaration A ResponseDeclaration object. */ - public function removeResponseDeclaration(ResponseDeclaration $responseDeclaration) + public function removeResponseDeclaration(ResponseDeclaration $responseDeclaration): void { $this->getResponseDeclarations()->detach($responseDeclaration); } @@ -321,7 +321,7 @@ public function removeResponseDeclaration(ResponseDeclaration $responseDeclarati * * @param TemplateDeclarationCollection $templateDeclarations A collection of TemplateDeclaration objects. */ - public function setTemplateDeclarations(TemplateDeclarationCollection $templateDeclarations) + public function setTemplateDeclarations(TemplateDeclarationCollection $templateDeclarations): void { $this->templateDeclarations = $templateDeclarations; } @@ -331,7 +331,7 @@ public function setTemplateDeclarations(TemplateDeclarationCollection $templateD * * @return TemplateDeclarationCollection */ - public function getTemplateDeclarations() + public function getTemplateDeclarations(): TemplateDeclarationCollection { return $this->templateDeclarations; } @@ -341,7 +341,7 @@ public function getTemplateDeclarations() * * @param TemplateDeclaration $templateDeclaration */ - public function addTemplateDeclaration(TemplateDeclaration $templateDeclaration) + public function addTemplateDeclaration(TemplateDeclaration $templateDeclaration): void { $this->templateDeclarations->attach($templateDeclaration); } @@ -351,7 +351,7 @@ public function addTemplateDeclaration(TemplateDeclaration $templateDeclaration) * * @param TemplateDeclaration $templateDeclaration */ - public function removeTemplateDeclaration(TemplateDeclaration $templateDeclaration) + public function removeTemplateDeclaration(TemplateDeclaration $templateDeclaration): void { $this->templateDeclarations->detach($templateDeclaration); } @@ -361,7 +361,7 @@ public function removeTemplateDeclaration(TemplateDeclaration $templateDeclarati * * @param ModalFeedbackRuleCollection $modalFeedbackRules */ - public function setModalFeedbackRules(ModalFeedbackRuleCollection $modalFeedbackRules) + public function setModalFeedbackRules(ModalFeedbackRuleCollection $modalFeedbackRules): void { $this->modalFeedbackRules = $modalFeedbackRules; } @@ -371,7 +371,7 @@ public function setModalFeedbackRules(ModalFeedbackRuleCollection $modalFeedback * * @return ModalFeedbackRuleCollection */ - public function getModalFeedbackRules() + public function getModalFeedbackRules(): ModalFeedbackRuleCollection { return $this->modalFeedbackRules; } @@ -381,7 +381,7 @@ public function getModalFeedbackRules() * * @param ModalFeedbackRule $modalFeedbackRule */ - public function addModalFeedbackRule(ModalFeedbackRule $modalFeedbackRule) + public function addModalFeedbackRule(ModalFeedbackRule $modalFeedbackRule): void { $this->getModalFeedbackRules()->attach($modalFeedbackRule); } @@ -391,7 +391,7 @@ public function addModalFeedbackRule(ModalFeedbackRule $modalFeedbackRule) * * @param ModalFeedbackRule $modalFeedbackRule */ - public function removeModalFeedbackRule(ModalFeedbackRule $modalFeedbackRule) + public function removeModalFeedbackRule(ModalFeedbackRule $modalFeedbackRule): void { $this->getModalFeedbackRules()->detach($modalFeedbackRule); } @@ -401,7 +401,7 @@ public function removeModalFeedbackRule(ModalFeedbackRule $modalFeedbackRule) * * @param ShufflingCollection $shufflings */ - public function setShufflings(ShufflingCollection $shufflings) + public function setShufflings(ShufflingCollection $shufflings): void { $this->shufflings = $shufflings; } @@ -411,7 +411,7 @@ public function setShufflings(ShufflingCollection $shufflings) * * @return ShufflingCollection */ - public function getShufflings() + public function getShufflings(): ShufflingCollection { return $this->shufflings; } @@ -421,7 +421,7 @@ public function getShufflings() * * @param Shuffling $shuffling */ - public function addShuffling(Shuffling $shuffling) + public function addShuffling(Shuffling $shuffling): void { $this->getShufflings()->attach($shuffling); } @@ -431,7 +431,7 @@ public function addShuffling(Shuffling $shuffling) * * @param Shuffling $shuffling */ - public function removeShuffling(Shuffling $shuffling) + public function removeShuffling(Shuffling $shuffling): void { $this->getShufflings()->detach($shuffling); } @@ -441,7 +441,7 @@ public function removeShuffling(Shuffling $shuffling) * * @return bool */ - public function isAdaptive() + public function isAdaptive(): bool { return $this->adaptive; } @@ -452,7 +452,7 @@ public function isAdaptive() * @param bool $adaptive Whether the referenced Item is adaptive. * @throws InvalidArgumentException If $adaptive is not a boolean value. */ - public function setAdaptive($adaptive) + public function setAdaptive($adaptive): void { if (is_bool($adaptive)) { $this->adaptive = $adaptive; @@ -468,7 +468,7 @@ public function setAdaptive($adaptive) * @param bool $timeDependent Whether the referenced item is time dependent. * @throws InvalidArgumentException If $timeDependent is not a boolean value. */ - public function setTimeDependent($timeDependent) + public function setTimeDependent($timeDependent): void { if (is_bool($timeDependent)) { $this->timeDependent = $timeDependent; @@ -483,7 +483,7 @@ public function setTimeDependent($timeDependent) * * @return bool */ - public function isTimeDependent() + public function isTimeDependent(): bool { return $this->timeDependent; } @@ -493,7 +493,7 @@ public function isTimeDependent() * * @param IdentifierCollection $endAttemptIdentifiers */ - public function setEndAttemptIdentifiers(IdentifierCollection $endAttemptIdentifiers) + public function setEndAttemptIdentifiers(IdentifierCollection $endAttemptIdentifiers): void { $this->endAttemptIdentifiers = $endAttemptIdentifiers; } @@ -503,7 +503,7 @@ public function setEndAttemptIdentifiers(IdentifierCollection $endAttemptIdentif * * @return IdentifierCollection */ - public function getEndAttemptIdentifiers() + public function getEndAttemptIdentifiers(): IdentifierCollection { return $this->endAttemptIdentifiers; } @@ -513,7 +513,7 @@ public function getEndAttemptIdentifiers() * * @param ResponseValidityConstraintCollection $responseValidityConstraints */ - public function setResponseValidityConstraints(ResponseValidityConstraintCollection $responseValidityConstraints) + public function setResponseValidityConstraints(ResponseValidityConstraintCollection $responseValidityConstraints): void { $this->responseValidityConstraints = $responseValidityConstraints; } @@ -523,7 +523,7 @@ public function setResponseValidityConstraints(ResponseValidityConstraintCollect * * @return ResponseValidityConstraintCollection */ - public function getResponseValidityConstraints() + public function getResponseValidityConstraints(): ResponseValidityConstraintCollection { return $this->responseValidityConstraints; } @@ -533,7 +533,7 @@ public function getResponseValidityConstraints() * * @param ResponseValidityConstraint $responseValidityConstraint */ - public function addResponseValidityConstraint(ResponseValidityConstraint $responseValidityConstraint) + public function addResponseValidityConstraint(ResponseValidityConstraint $responseValidityConstraint): void { $this->getResponseValidityConstraints()->attach($responseValidityConstraint); } @@ -543,7 +543,7 @@ public function addResponseValidityConstraint(ResponseValidityConstraint $respon * * @param ResponseValidityConstraint $responseValidityConstraint */ - public function removeResponseValidityConstraint(ResponseValidityConstraint $responseValidityConstraint) + public function removeResponseValidityConstraint(ResponseValidityConstraint $responseValidityConstraint): void { $this->getResponseValidityConstraints()->detach($responseValidityConstraint); } @@ -554,7 +554,7 @@ public function removeResponseValidityConstraint(ResponseValidityConstraint $res * @param AssessmentItemRef $assessmentItemRef An AssessmentItemRef object. * @return ExtendedAssessmentItemRef An ExtendedAssessmentItemRef object. */ - public static function createFromAssessmentItemRef(AssessmentItemRef $assessmentItemRef) + public static function createFromAssessmentItemRef(AssessmentItemRef $assessmentItemRef): ExtendedAssessmentItemRef { $identifier = $assessmentItemRef->getIdentifier(); $href = $assessmentItemRef->getHref(); @@ -575,7 +575,7 @@ public static function createFromAssessmentItemRef(AssessmentItemRef $assessment /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $components = array_merge( parent::getComponents()->getArrayCopy(), @@ -610,7 +610,7 @@ public function getComponents() * @param $title * @throws InvalidArgumentException */ - public function setTitle($title) + public function setTitle($title): void { if (is_string($title)) { $this->title = $title; @@ -626,7 +626,7 @@ public function setTitle($title) * * @return string */ - public function getTitle() + public function getTitle(): string { return $this->title; } @@ -638,7 +638,7 @@ public function getTitle() * * @return bool */ - public function hasTitle() + public function hasTitle(): bool { return !empty($this->getTitle()); } @@ -651,7 +651,7 @@ public function hasTitle() * @param $label * @throws InvalidArgumentException */ - public function setLabel($label) + public function setLabel($label): void { if (Format::isString256($label)) { $this->label = $label; @@ -667,7 +667,7 @@ public function setLabel($label) * * @return string */ - public function getLabel() + public function getLabel(): string { return $this->label; } @@ -679,7 +679,7 @@ public function getLabel() * * @return bool */ - public function hasLabel() + public function hasLabel(): bool { return !empty($this->getLabel()); } diff --git a/src/qtism/data/ExtendedAssessmentSection.php b/src/qtism/data/ExtendedAssessmentSection.php index 80ced6a58..cc6182509 100644 --- a/src/qtism/data/ExtendedAssessmentSection.php +++ b/src/qtism/data/ExtendedAssessmentSection.php @@ -60,7 +60,7 @@ public function __construct($identifier, $title, $visible) * * @param RubricBlockRefCollection $rubricBlockRefs A collection of RubricBlockRef objects. */ - public function setRubricBlockRefs(RubricBlockRefCollection $rubricBlockRefs) + public function setRubricBlockRefs(RubricBlockRefCollection $rubricBlockRefs): void { $this->rubricBlockRefs = $rubricBlockRefs; } @@ -70,7 +70,7 @@ public function setRubricBlockRefs(RubricBlockRefCollection $rubricBlockRefs) * * @return RubricBlockRefCollection A collection of RubricBlockRef objects. */ - public function getRubricBlockRefs() + public function getRubricBlockRefs(): RubricBlockRefCollection { return $this->rubricBlockRefs; } @@ -82,7 +82,7 @@ public function getRubricBlockRefs() * @param AssessmentSection $assessmentSection An AssessmentSection object. * @return ExtendedAssessmentSection An ExtendedAssessmentSection object built from $assessmentSection. */ - public static function createFromAssessmentSection(AssessmentSection $assessmentSection) + public static function createFromAssessmentSection(AssessmentSection $assessmentSection): ExtendedAssessmentSection { $extended = new static($assessmentSection->getIdentifier(), $assessmentSection->getTitle(), $assessmentSection->isVisible()); $extended->setKeepTogether($assessmentSection->mustKeepTogether()); @@ -102,7 +102,7 @@ public static function createFromAssessmentSection(AssessmentSection $assessment /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $parentComponents = parent::getComponents(); $parentComponents->merge($this->getRubricBlockRefs()); diff --git a/src/qtism/data/ExtendedAssessmentTest.php b/src/qtism/data/ExtendedAssessmentTest.php index 14bb1b996..d0b5d630b 100644 --- a/src/qtism/data/ExtendedAssessmentTest.php +++ b/src/qtism/data/ExtendedAssessmentTest.php @@ -56,7 +56,7 @@ public function __construct($identifier, $title, TestPartCollection $testParts = * * @param TestFeedbackRefCollection $testFeedbackRefs */ - public function setTestFeedbackRefs(TestFeedbackRefCollection $testFeedbackRefs) + public function setTestFeedbackRefs(TestFeedbackRefCollection $testFeedbackRefs): void { $this->testFeedbackRefs = $testFeedbackRefs; } @@ -66,7 +66,7 @@ public function setTestFeedbackRefs(TestFeedbackRefCollection $testFeedbackRefs) * * @return TestFeedbackRefCollection */ - public function getTestFeedbackRefs() + public function getTestFeedbackRefs(): TestFeedbackRefCollection { return $this->testFeedbackRefs; } @@ -76,7 +76,7 @@ public function getTestFeedbackRefs() * * @param TestFeedbackRef $testFeedbackRef */ - public function addTestFeedbackRef(TestFeedbackRef $testFeedbackRef) + public function addTestFeedbackRef(TestFeedbackRef $testFeedbackRef): void { $this->getTestFeedbackRefs()->attach($testFeedbackRef); } @@ -86,7 +86,7 @@ public function addTestFeedbackRef(TestFeedbackRef $testFeedbackRef) * * @param TestFeedbackRef $testFeedbackRef */ - public function removeTestFeedbackRef(TestFeedbackRef $testFeedbackRef) + public function removeTestFeedbackRef(TestFeedbackRef $testFeedbackRef): void { $this->getTestFeedbackRefs()->detach($testFeedbackRef); } @@ -97,7 +97,7 @@ public function removeTestFeedbackRef(TestFeedbackRef $testFeedbackRef) * @param AssessmentTest $assessmentTest * @return ExtendedAssessmentTest */ - public static function createFromAssessmentTest(AssessmentTest $assessmentTest) + public static function createFromAssessmentTest(AssessmentTest $assessmentTest): ExtendedAssessmentTest { $ref = new ExtendedAssessmentTest( $assessmentTest->getIdentifier(), @@ -118,7 +118,7 @@ public static function createFromAssessmentTest(AssessmentTest $assessmentTest) /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $components = array_merge( parent::getComponents()->getArrayCopy(), diff --git a/src/qtism/data/ExtendedTestPart.php b/src/qtism/data/ExtendedTestPart.php index 20dbce28b..826c7e9cc 100644 --- a/src/qtism/data/ExtendedTestPart.php +++ b/src/qtism/data/ExtendedTestPart.php @@ -60,7 +60,7 @@ public function __construct($identifier, SectionPartCollection $assessmentSectio * * @param TestFeedbackRefCollection $testFeedbackRefs */ - public function setTestFeedbackRefs(TestFeedbackRefCollection $testFeedbackRefs) + public function setTestFeedbackRefs(TestFeedbackRefCollection $testFeedbackRefs): void { $this->testFeedbackRefs = $testFeedbackRefs; } @@ -70,7 +70,7 @@ public function setTestFeedbackRefs(TestFeedbackRefCollection $testFeedbackRefs) * * @return TestFeedbackRefCollection */ - public function getTestFeedbackRefs() + public function getTestFeedbackRefs(): TestFeedbackRefCollection { return $this->testFeedbackRefs; } @@ -80,7 +80,7 @@ public function getTestFeedbackRefs() * * @param TestFeedbackRef $testFeedbackRef */ - public function addTestFeedbackRef(TestFeedbackRef $testFeedbackRef) + public function addTestFeedbackRef(TestFeedbackRef $testFeedbackRef): void { $this->getTestFeedbackRefs()->attach($testFeedbackRef); } @@ -90,7 +90,7 @@ public function addTestFeedbackRef(TestFeedbackRef $testFeedbackRef) * * @param TestFeedbackRef $testFeedbackRef */ - public function removeTestFeedbackRef(TestFeedbackRef $testFeedbackRef) + public function removeTestFeedbackRef(TestFeedbackRef $testFeedbackRef): void { $this->getTestFeedbackRefs()->detach($testFeedbackRef); } @@ -101,9 +101,9 @@ public function removeTestFeedbackRef(TestFeedbackRef $testFeedbackRef) * @param TestPart $testPart * @return ExtendedTestPart */ - public static function createFromTestPart(TestPart $testPart) + public static function createFromTestPart(TestPart $testPart): ExtendedTestPart { - $ref = new ExtendedTestPart( + $ref = new self( $testPart->getIdentifier(), $testPart->getAssessmentSections(), $testPart->getNavigationMode(), @@ -123,7 +123,7 @@ public static function createFromTestPart(TestPart $testPart) /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $components = array_merge( parent::getComponents()->getArrayCopy(), diff --git a/src/qtism/data/ExternalQtiComponent.php b/src/qtism/data/ExternalQtiComponent.php index bf4025378..5ca2b3a21 100644 --- a/src/qtism/data/ExternalQtiComponent.php +++ b/src/qtism/data/ExternalQtiComponent.php @@ -92,7 +92,7 @@ public function getXml(): ?SerializableDomDocument * * @param SerializableDomDocument $xml An XML Document */ - protected function setXml(SerializableDomDocument $xml) + protected function setXml(SerializableDomDocument $xml): void { $this->xml = $xml; } @@ -102,7 +102,7 @@ protected function setXml(SerializableDomDocument $xml) * * @return string */ - public function getXmlString() + public function getXmlString(): string { return $this->xmlString; } @@ -112,7 +112,7 @@ public function getXmlString() * * @param string $xmlString */ - public function setXmlString($xmlString) + public function setXmlString($xmlString): void { $this->xmlString = $xmlString; @@ -125,7 +125,7 @@ public function setXmlString($xmlString) * * @return bool */ - public function hasTargetNamespace() + public function hasTargetNamespace(): bool { return $this->getTargetNamespace() !== ''; } @@ -146,7 +146,7 @@ public function getTargetNamespace(): string * * @param string $targetNamespace A URI (Uniform Resource Locator). */ - public function setTargetNamespace($targetNamespace) + public function setTargetNamespace($targetNamespace): void { $this->targetNamespace = $targetNamespace; } @@ -155,14 +155,14 @@ public function setTargetNamespace($targetNamespace) * Method to be overloaded by subclasses to setup a default * target namespace. */ - protected function buildTargetNamespace() + protected function buildTargetNamespace(): void { } /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -170,7 +170,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'external'; } diff --git a/src/qtism/data/IAssessmentItem.php b/src/qtism/data/IAssessmentItem.php index 73050f2fa..985be7e51 100644 --- a/src/qtism/data/IAssessmentItem.php +++ b/src/qtism/data/IAssessmentItem.php @@ -52,7 +52,7 @@ public function setTimeDependent($timeDependent); * * @return bool */ - public function isTimeDependent(); + public function isTimeDependent(): bool; /** * Set whether the item is adaptive. @@ -67,14 +67,14 @@ public function setAdaptive($adaptive); * * @return bool */ - public function isAdaptive(); + public function isAdaptive(): bool; /** * Get the response declarations. * * @return ResponseDeclarationCollection A collection of ResponseDeclaration objects. */ - public function getResponseDeclarations(); + public function getResponseDeclarations(): ResponseDeclarationCollection; /** * Set the response declarations. @@ -88,7 +88,7 @@ public function setResponseDeclarations(ResponseDeclarationCollection $responseD * * @return OutcomeDeclarationCollection A collection of OutcomeDeclaration objects. */ - public function getOutcomeDeclarations(); + public function getOutcomeDeclarations(): OutcomeDeclarationCollection; /** * Set the outcome declarations. @@ -102,7 +102,7 @@ public function setOutcomeDeclarations(OutcomeDeclarationCollection $outcomeDecl * * @return TemplateDeclarationCollection $templateDeclarations */ - public function getTemplateDeclarations(); + public function getTemplateDeclarations(): TemplateDeclarationCollection; /** * Set the template declarations. @@ -116,14 +116,14 @@ public function setTemplateDeclarations(TemplateDeclarationCollection $templateD * * @return ModalFeedbackRuleCollection */ - public function getModalFeedbackRules(); + public function getModalFeedbackRules(): ModalFeedbackRuleCollection; /** * Get the associated ResponseProcessing object. * * @return ResponseProcessing A ResponseProcessing object or null if no associated response processing. */ - public function getResponseProcessing(); + public function getResponseProcessing(): ?ResponseProcessing; /** * Set the associated ResponseProcessing object. @@ -137,7 +137,7 @@ public function setResponseProcessing(ResponseProcessing $responseProcessing = n * * @return TemplateProcessing A TemplateProcessing object or null if no associated template processing. */ - public function getTemplateProcessing(); + public function getTemplateProcessing(): ?TemplateProcessing; /** * Set the associated TemplateProcessing object. @@ -151,14 +151,14 @@ public function setTemplateProcessing(TemplateProcessing $templateProcessing = n * * @return IdentifierCollection */ - public function getEndAttemptIdentifiers(); + public function getEndAttemptIdentifiers(): IdentifierCollection; /** * Get the ShufflingCollection object representing how choices are shuffled in shuffled interactions. * * @return ShufflingCollection */ - public function getShufflings(); + public function getShufflings(): ShufflingCollection; /** * Get the ResponseValidityConstraintCollection object. @@ -168,7 +168,7 @@ public function getShufflings(); * * @return ResponseValidityConstraintCollection */ - public function getResponseValidityConstraints(); + public function getResponseValidityConstraints(): ResponseValidityConstraintCollection; /** * Set the title. @@ -187,7 +187,7 @@ public function setTitle($title); * * @return string */ - public function getTitle(); + public function getTitle(): string; /** * Set the label. @@ -206,14 +206,14 @@ public function setLabel($label); * * @return string */ - public function getLabel(); + public function getLabel(): string; /** * Has a label. * * Whether or not the assessmentItem has a label. * - * @return string + * @return bool */ - public function hasLabel(); + public function hasLabel(): bool; } diff --git a/src/qtism/data/ItemSessionControl.php b/src/qtism/data/ItemSessionControl.php index 816345fba..646070d5c 100644 --- a/src/qtism/data/ItemSessionControl.php +++ b/src/qtism/data/ItemSessionControl.php @@ -163,7 +163,7 @@ class ItemSessionControl extends QtiComponent * * @return int An integer. */ - public function getMaxAttempts() + public function getMaxAttempts(): int { return $this->maxAttempts; } @@ -174,7 +174,7 @@ public function getMaxAttempts() * @param int $maxAttempts An integer. * @throws InvalidArgumentException If $maxAttempts is not an integer. */ - public function setMaxAttempts($maxAttempts) + public function setMaxAttempts($maxAttempts): void { if (is_int($maxAttempts)) { $this->maxAttempts = $maxAttempts; @@ -189,7 +189,7 @@ public function setMaxAttempts($maxAttempts) * * @return bool true if feedbacks must be shown, otherwise false. */ - public function mustShowFeedback() + public function mustShowFeedback(): bool { return $this->showFeedback; } @@ -200,7 +200,7 @@ public function mustShowFeedback() * @param bool $showFeedback true if feedbacks must be shown, otherwise false. * @throws InvalidArgumentException If $showFeedback is not a boolean value. */ - public function setShowFeedback($showFeedback) + public function setShowFeedback($showFeedback): void { if (is_bool($showFeedback)) { $this->showFeedback = $showFeedback; @@ -215,7 +215,7 @@ public function setShowFeedback($showFeedback) * * @return bool true if allowed, false if not allowed. */ - public function doesAllowReview() + public function doesAllowReview(): bool { return $this->allowReview; } @@ -227,7 +227,7 @@ public function doesAllowReview() * @param bool $allowReview true if allowed, false if not. * @throws InvalidArgumentException If $allowReview is not a boolean. */ - public function setAllowReview($allowReview) + public function setAllowReview($allowReview): void { if (is_bool($allowReview)) { $this->allowReview = $allowReview; @@ -242,7 +242,7 @@ public function setAllowReview($allowReview) * * @return bool true if the candidate can, false if not. */ - public function mustShowSolution() + public function mustShowSolution(): bool { return $this->showSolution; } @@ -253,7 +253,7 @@ public function mustShowSolution() * @param bool $showSolution true if he is provided, false if not. * @throws InvalidArgumentException If $showSolution is not a boolean. */ - public function setShowSolution($showSolution) + public function setShowSolution($showSolution): void { if (is_bool($showSolution)) { $this->showSolution = $showSolution; @@ -268,7 +268,7 @@ public function setShowSolution($showSolution) * * @return bool true if allowed, false if not. */ - public function doesAllowComment() + public function doesAllowComment(): bool { return $this->allowComment; } @@ -279,7 +279,7 @@ public function doesAllowComment() * @param bool $allowComment true if allowed, false if not. * @throws InvalidArgumentException If $allowComment is not a boolean. */ - public function setAllowComment($allowComment) + public function setAllowComment($allowComment): void { if (is_bool($allowComment)) { $this->allowComment = $allowComment; @@ -296,7 +296,7 @@ public function setAllowComment($allowComment) * * @return bool true if allowed, false if not. */ - public function doesAllowSkipping() + public function doesAllowSkipping(): bool { return $this->allowSkipping; } @@ -309,7 +309,7 @@ public function doesAllowSkipping() * @param bool $allowSkipping true if allowed, false otherwise. * @throws InvalidArgumentException If $allowSkipping is not a valid boolean. */ - public function setAllowSkipping($allowSkipping) + public function setAllowSkipping($allowSkipping): void { if (is_bool($allowSkipping)) { $this->allowSkipping = $allowSkipping; @@ -324,7 +324,7 @@ public function setAllowSkipping($allowSkipping) * * @return bool true if responses must be validated, false if not. */ - public function mustValidateResponses() + public function mustValidateResponses(): bool { return $this->validateResponses; } @@ -336,7 +336,7 @@ public function mustValidateResponses() * * @return bool */ - public function isDefault() + public function isDefault(): bool { return $this->getMaxAttempts() === 1 && $this->mustShowFeedback() === false && @@ -355,7 +355,7 @@ public function isDefault() * @param bool $validateResponses true if responses must be validated, false if not. * @throws InvalidArgumentException If $validateResponses is not a boolean. */ - public function setValidateResponses($validateResponses) + public function setValidateResponses($validateResponses): void { if (is_bool($validateResponses)) { $this->validateResponses = $validateResponses; @@ -368,7 +368,7 @@ public function setValidateResponses($validateResponses) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'itemSessionControl'; } @@ -376,7 +376,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/NavigationMode.php b/src/qtism/data/NavigationMode.php index c183cf96f..940a914f0 100644 --- a/src/qtism/data/NavigationMode.php +++ b/src/qtism/data/NavigationMode.php @@ -42,14 +42,14 @@ */ class NavigationMode implements Enumeration { - const LINEAR = 0; + public const LINEAR = 0; - const NONLINEAR = 1; + public const NONLINEAR = 1; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'LINEAR' => self::LINEAR, diff --git a/src/qtism/data/QtiComponent.php b/src/qtism/data/QtiComponent.php index eb1fb231d..a2594f821 100644 --- a/src/qtism/data/QtiComponent.php +++ b/src/qtism/data/QtiComponent.php @@ -36,14 +36,14 @@ abstract class QtiComponent * * @return string A QTI class name. */ - abstract public function getQtiClassName(); + abstract public function getQtiClassName(): string; /** * Get the direct child components of this one. * * @return QtiComponentCollection A collection of QtiComponent objects. */ - abstract public function getComponents(); + abstract public function getComponents(): QtiComponentCollection; /** * Get a QtiComponentIterator object which allows you to iterate @@ -51,7 +51,7 @@ abstract public function getComponents(); * * @return QtiComponentIterator A QtiComponentIterator object. */ - public function getIterator() + public function getIterator(): QtiComponentIterator { return new QtiComponentIterator($this); } @@ -65,7 +65,7 @@ public function getIterator() * @return QtiComponent|null A QtiComponent object or null if not found. * @throws InvalidArgumentException If $identifier is not a string. */ - public function getComponentByIdentifier($identifier, $recursive = true) + public function getComponentByIdentifier($identifier, $recursive = true): ?QtiComponent { if (!is_string($identifier)) { $msg = 'The QtiComponent::getComponentByIdentifier method only accepts a string as its '; @@ -101,7 +101,7 @@ public function getComponentByIdentifier($identifier, $recursive = true) * @return QtiComponentCollection * @throws InvalidArgumentException If $classNames is not an array nor a string value. */ - public function getComponentsByClassName($classNames, $recursive = true) + public function getComponentsByClassName($classNames, $recursive = true): QtiComponentCollection { if (!is_string($classNames) && !is_array($classNames)) { $msg = 'The QtiComponent::getComponentsByClassName method only accepts '; @@ -135,7 +135,7 @@ public function getComponentsByClassName($classNames, $recursive = true) * @param bool $recursive Whether to search recursively in contained QtiComponent objects. * @return QtiComponentCollection A QtiIdentifiableCollection or a QtiComponentCollection in case of collision. */ - public function getIdentifiableComponents($recursive = true) + public function getIdentifiableComponents($recursive = true): QtiComponentCollection { $iterator = ($recursive === true) ? $this->getIterator() : $this->getComponents(); $foundComponents = []; @@ -165,7 +165,7 @@ public function getIdentifiableComponents($recursive = true) * @param bool $recursive Whether to search recursively in contained QtiComponent objects. * @return bool */ - public function containsComponentWithClassName($classNames, $recursive = true) + public function containsComponentWithClassName($classNames, $recursive = true): bool { if (is_array($classNames) === false) { $classNames = [$classNames]; diff --git a/src/qtism/data/QtiComponentCollection.php b/src/qtism/data/QtiComponentCollection.php index 14de73568..fddb484fa 100644 --- a/src/qtism/data/QtiComponentCollection.php +++ b/src/qtism/data/QtiComponentCollection.php @@ -41,7 +41,7 @@ class QtiComponentCollection extends AbstractCollection * * @throws InvalidArgumentException If $value is not a QtiComponent object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof QtiComponent) { $msg = "QtiComponentCollection class only accept QtiComponent objects, '" . get_class($value) . "' given."; @@ -53,7 +53,7 @@ protected function checkType($value) * @param mixed $offset * @param mixed $value */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (empty($offset)) { parent::offsetSet($offset, $value); @@ -66,7 +66,7 @@ public function offsetSet($offset, $value) /** * @param mixed $offset */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { if (empty($offset)) { parent::offsetUnset($offset); diff --git a/src/qtism/data/QtiComponentIterator.php b/src/qtism/data/QtiComponentIterator.php index 366b6f283..e63fcc92d 100644 --- a/src/qtism/data/QtiComponentIterator.php +++ b/src/qtism/data/QtiComponentIterator.php @@ -136,7 +136,7 @@ public function __construct(QtiComponent $rootComponent, array $classes = []) * * @param QtiComponent $rootComponent */ - protected function setRootComponent(QtiComponent $rootComponent) + protected function setRootComponent(QtiComponent $rootComponent): void { $this->rootComponent = $rootComponent; } @@ -144,15 +144,15 @@ protected function setRootComponent(QtiComponent $rootComponent) /** * @param QtiComponent|null $currentContainer */ - protected function setCurrentContainer(QtiComponent $currentContainer = null) + protected function setCurrentContainer(QtiComponent $currentContainer = null): void { $this->currentContainer = $currentContainer; } /** - * @return QtiComponent + * @return QtiComponent|null */ - public function getCurrentContainer() + public function getCurrentContainer(): ?QtiComponent { return $this->currentContainer; } @@ -163,7 +163,7 @@ public function getCurrentContainer() * * @return QtiComponent */ - public function getRootComponent() + public function getRootComponent(): QtiComponent { return $this->rootComponent; } @@ -173,7 +173,7 @@ public function getRootComponent() * * @param QtiComponent $currentComponent */ - protected function setCurrentComponent(QtiComponent $currentComponent = null) + protected function setCurrentComponent(QtiComponent $currentComponent = null): void { $this->currentComponent = $currentComponent; } @@ -183,7 +183,7 @@ protected function setCurrentComponent(QtiComponent $currentComponent = null) * * @return QtiComponent A QtiComponent object. */ - protected function getCurrentComponent() + protected function getCurrentComponent(): ?QtiComponent { return $this->currentComponent; } @@ -193,7 +193,7 @@ protected function getCurrentComponent() * * @param array $classes An array of QTI class names. */ - protected function setClasses(array $classes) + protected function setClasses(array $classes): void { $this->classes = $classes; } @@ -203,7 +203,7 @@ protected function setClasses(array $classes) * * @return array An array of QTI class names. */ - protected function &getClasses() + protected function &getClasses(): array { return $this->classes; } @@ -214,7 +214,7 @@ protected function &getClasses() * @param QtiComponent $source From where we are coming from. * @param QtiComponentCollection $components The next components to explore. */ - protected function pushOnTrail(QtiComponent $source, QtiComponentCollection $components) + protected function pushOnTrail(QtiComponent $source, QtiComponentCollection $components): void { foreach (array_reverse($components->getArrayCopy()) as $c) { array_push($this->trail, [$source, $c]); @@ -227,7 +227,7 @@ protected function pushOnTrail(QtiComponent $source, QtiComponentCollection $com * * @return array */ - protected function popFromTrail() + protected function popFromTrail(): array { $this->trailCount--; return array_pop($this->trail); @@ -238,7 +238,7 @@ protected function popFromTrail() * * @return array An array of QtiComponent objects. */ - protected function &getTrail() + protected function &getTrail(): array { return $this->trail; } @@ -248,7 +248,7 @@ protected function &getTrail() * * @param array $trail An array of QtiComponent objects. */ - protected function setTrail(array &$trail) + protected function setTrail(array &$trail): void { $this->trail = $trail; $this->trailCount = count($trail); @@ -260,7 +260,7 @@ protected function setTrail(array &$trail) * * @param array $traversed An array of QtiComponent objects. */ - protected function setTraversed(array &$traversed) + protected function setTraversed(array &$traversed): void { $this->traversed = $traversed; } @@ -270,7 +270,7 @@ protected function setTraversed(array &$traversed) * * @param QtiComponent $component A QTIComponent object. */ - protected function markTraversed(QtiComponent $component) + protected function markTraversed(QtiComponent $component): void { array_push($this->traversed, $component); } @@ -282,7 +282,7 @@ protected function markTraversed(QtiComponent $component) * @param QtiComponent $component * @return bool */ - protected function isTraversed(QtiComponent $component) + protected function isTraversed(QtiComponent $component): bool { return in_array($component, $this->traversed, true); } @@ -292,7 +292,7 @@ protected function isTraversed(QtiComponent $component) * * @param bool $isValid */ - protected function setValid($isValid) + protected function setValid($isValid): void { $this->isValid = $isValid; } @@ -300,7 +300,7 @@ protected function setValid($isValid) /** * Rewind the iterator. */ - public function rewind() + public function rewind(): void { $trail = []; $this->setTrail($trail); @@ -344,7 +344,7 @@ public function rewind() * * @return QtiComponent A QtiComponent object. */ - public function current() + public function current(): ?QtiComponent { return $this->getCurrentComponent(); } @@ -361,7 +361,7 @@ public function current() * @return null|QtiComponent The null value if there is no parent, otherwise a QtiComponent. * @see QtiComponentIterator::current() */ - public function parent() + public function parent(): ?QtiComponent { return $this->getCurrentContainer(); } @@ -372,7 +372,7 @@ public function parent() * * @return string A QTI class name. */ - public function key() + public function key(): string { return $this->getCurrentComponent()->getQtiClassName(); } @@ -381,7 +381,7 @@ public function key() * Moves the current position to the next QtiComponent object to be * traversed. */ - public function next() + public function next(): void { if ($this->trailCount > 0) { while ($this->trailCount > 0) { @@ -416,7 +416,7 @@ public function next() * * @return bool Whether the current position is valid. */ - public function valid() + public function valid(): bool { return $this->isValid; } diff --git a/src/qtism/data/QtiDocument.php b/src/qtism/data/QtiDocument.php index 56421dfd3..cd1118369 100644 --- a/src/qtism/data/QtiDocument.php +++ b/src/qtism/data/QtiDocument.php @@ -69,7 +69,7 @@ public function __construct($versionNumber = '2.1.0', QtiComponent $documentComp * @param string $versionNumber A QTI version number e.g. '2.1.1'. * @throws InvalidArgumentException If $version is unknown regarding existing QTI versions. */ - public function setVersion(string $versionNumber) + public function setVersion(string $versionNumber): void { $this->version = QtiVersion::create($versionNumber); } @@ -89,7 +89,7 @@ public function getVersion(): string * * @param QtiComponent $documentComponent A QTI Component object. */ - public function setDocumentComponent(QtiComponent $documentComponent = null) + public function setDocumentComponent(QtiComponent $documentComponent = null): void { $this->documentComponent = $documentComponent; } @@ -99,7 +99,7 @@ public function setDocumentComponent(QtiComponent $documentComponent = null) * * @return QtiComponent */ - public function getDocumentComponent() + public function getDocumentComponent(): ?QtiComponent { return $this->documentComponent; } @@ -107,7 +107,7 @@ public function getDocumentComponent() /** * @param $url */ - protected function setUrl($url) + protected function setUrl($url): void { $this->url = $url; } @@ -115,7 +115,7 @@ protected function setUrl($url) /** * @return string */ - public function getUrl() + public function getUrl(): string { return $this->url; } diff --git a/src/qtism/data/QtiIdentifiable.php b/src/qtism/data/QtiIdentifiable.php index 5d4d0fb8c..94b387412 100644 --- a/src/qtism/data/QtiIdentifiable.php +++ b/src/qtism/data/QtiIdentifiable.php @@ -37,14 +37,14 @@ interface QtiIdentifiable extends SplSubject * * @return string A QTI Identifier. */ - public function getIdentifier(); + public function getIdentifier(): string; /** * Get the observers of the object. * * @return SplObjectStorage An SplObjectStorage object. */ - public function getObservers(); + public function getObservers(): SplObjectStorage; /** * Set the observers of the object. diff --git a/src/qtism/data/QtiIdentifiableCollection.php b/src/qtism/data/QtiIdentifiableCollection.php index 2eb769bdc..2be57d8b0 100644 --- a/src/qtism/data/QtiIdentifiableCollection.php +++ b/src/qtism/data/QtiIdentifiableCollection.php @@ -52,7 +52,7 @@ public function __construct(array $array = []) /** * @param mixed $value */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof QtiIdentifiable) { $msg = 'The QtiIdentifiable class only accepts to store QtiIdentifiable objects.'; @@ -68,7 +68,7 @@ protected function checkType($value) * @return bool * @throws OutOfRangeException If the request $offset is not a string or is empty. */ - public function offsetExists($offset) + public function offsetExists($offset): bool { if (!is_string($offset) && empty($offset) === false) { $msg = 'The requested offset must be a string.'; @@ -87,7 +87,7 @@ public function offsetExists($offset) * @return QtiIdentifiable|null The requested QtiIdentifiable object or null if no object with 'identifier' = $offset is found. * @throws OutOfRangeException If the request $offset is not a string or is empty. */ - public function offsetGet($offset) + public function offsetGet($offset): ?QtiIdentifiable { if (!is_string($offset)) { $msg = 'The requested offset must be a non-empty string.'; @@ -114,7 +114,7 @@ public function offsetGet($offset) * @throws InvalidArgumentException If $value is not a QtiIdentifiable object. * @throws OutOfRangeException If the offset is not null. */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { $this->checkType($value); @@ -141,7 +141,7 @@ public function offsetSet($offset, $value) * @param QtiIdentifiable $object A QtiIdentifiable object. * @throws InvalidArgumentException If $object is not a QtiIdentifiable object. */ - public function attach($object) + public function attach($object): void { $this->offsetSet(null, $object); } @@ -153,7 +153,7 @@ public function attach($object) * @param mixed $offset * @throws OutOfRangeException If $offset is not a string. */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { if (is_string($offset)) { $data = &$this->getDataPlaceHolder(); @@ -175,7 +175,7 @@ public function offsetUnset($offset) * @throws InvalidArgumentException If $object or $replacement are not compliant with the current collection typing. * @throws UnexpectedValueException If $object is not contained in the collection. */ - public function replace($object, $replacement) + public function replace($object, $replacement): void { $this->checkType($object); $this->checkType($replacement); @@ -214,7 +214,7 @@ public function replace($object, $replacement) * * @param SplSubject $subject */ - public function update(SplSubject $subject) + public function update(SplSubject $subject): void { // -- case 1 (QtiIdentifiable) // If it is a QtiIdentifiable, it has changed its identifier. diff --git a/src/qtism/data/QtiIdentifiableTrait.php b/src/qtism/data/QtiIdentifiableTrait.php index 09ca40b4f..0cc741b2e 100644 --- a/src/qtism/data/QtiIdentifiableTrait.php +++ b/src/qtism/data/QtiIdentifiableTrait.php @@ -43,7 +43,7 @@ trait QtiIdentifiableTrait * * @return SplObjectStorage An SplObjectStorage object. */ - public function getObservers() + public function getObservers(): SplObjectStorage { return $this->observers; } @@ -53,7 +53,7 @@ public function getObservers() * * @param SplObjectStorage $observers An SplObjectStorage object. */ - public function setObservers(SplObjectStorage $observers) + public function setObservers(SplObjectStorage $observers): void { $this->observers = $observers; } @@ -63,7 +63,7 @@ public function setObservers(SplObjectStorage $observers) * * @param SplObserver $observer An SplObserver object. */ - public function attach(SplObserver $observer) + public function attach(SplObserver $observer): void { $this->getObservers()->attach($observer); } @@ -73,7 +73,7 @@ public function attach(SplObserver $observer) * * @param SplObserver $observer An SplObserver object. */ - public function detach(SplObserver $observer) + public function detach(SplObserver $observer): void { $this->getObservers()->detach($observer); } @@ -81,7 +81,7 @@ public function detach(SplObserver $observer) /** * SplSubject::notify implementation. */ - public function notify() + public function notify(): void { foreach ($this->getObservers() as $observer) { $observer->update($this); diff --git a/src/qtism/data/SectionPart.php b/src/qtism/data/SectionPart.php index a409798e6..c3537d5f8 100644 --- a/src/qtism/data/SectionPart.php +++ b/src/qtism/data/SectionPart.php @@ -141,7 +141,7 @@ public function __construct($identifier, $required = false, $fixed = false) * * @return string A QTI Identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -152,7 +152,7 @@ public function getIdentifier() * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false)) { $this->identifier = $identifier; @@ -168,7 +168,7 @@ public function setIdentifier($identifier) * * @return bool true if must appear at least one, false if not. */ - public function isRequired() + public function isRequired(): bool { return $this->required; } @@ -179,7 +179,7 @@ public function isRequired() * @param bool $required true if it must appear at least one, otherwise false. * @throws InvalidArgumentException If $required is not a boolean. */ - public function setRequired($required) + public function setRequired($required): void { if (is_bool($required)) { $this->required = $required; @@ -194,7 +194,7 @@ public function setRequired($required) * * @return bool true if subject to shuffling, false if not. */ - public function isFixed() + public function isFixed(): bool { return $this->fixed; } @@ -205,7 +205,7 @@ public function isFixed() * @param bool $fixed true if subject to shuffling, false if not. * @throws InvalidArgumentException If $fixed is not a boolean. */ - public function setFixed($fixed) + public function setFixed($fixed): void { if (is_bool($fixed)) { $this->fixed = $fixed; @@ -220,7 +220,7 @@ public function setFixed($fixed) * * @return PreConditionCollection A collection of PreCondition objects. */ - public function getPreConditions() + public function getPreConditions(): PreConditionCollection { return $this->preConditions; } @@ -230,7 +230,7 @@ public function getPreConditions() * * @param PreConditionCollection $preConditions A collection of PreCondition objects. */ - public function setPreConditions(PreConditionCollection $preConditions) + public function setPreConditions(PreConditionCollection $preConditions): void { $this->preConditions = $preConditions; } @@ -240,7 +240,7 @@ public function setPreConditions(PreConditionCollection $preConditions) * * @return BranchRuleCollection A collection of BranchRule objects. */ - public function getBranchRules() + public function getBranchRules(): BranchRuleCollection { return $this->branchRules; } @@ -250,7 +250,7 @@ public function getBranchRules() * * @param BranchRuleCollection $branchRules A collection of BranchRule objects. */ - public function setBranchRules(BranchRuleCollection $branchRules) + public function setBranchRules(BranchRuleCollection $branchRules): void { $this->branchRules = $branchRules; } @@ -261,7 +261,7 @@ public function setBranchRules(BranchRuleCollection $branchRules) * * @return ItemSessionControl */ - public function getItemSessionControl() + public function getItemSessionControl(): ?ItemSessionControl { return $this->itemSessionControl; } @@ -271,7 +271,7 @@ public function getItemSessionControl() * * @param ItemSessionControl $itemSessionControl An ItemSessionControl object. */ - public function setItemSessionControl(ItemSessionControl $itemSessionControl = null) + public function setItemSessionControl(ItemSessionControl $itemSessionControl = null): void { $this->itemSessionControl = $itemSessionControl; } @@ -281,7 +281,7 @@ public function setItemSessionControl(ItemSessionControl $itemSessionControl = n * * @return bool */ - public function hasItemSessionControl() + public function hasItemSessionControl(): bool { return $this->getItemSessionControl() !== null; } @@ -292,7 +292,7 @@ public function hasItemSessionControl() * * @return TimeLimits A TimeLimits object. */ - public function getTimeLimits() + public function getTimeLimits(): ?TimeLimits { return $this->timeLimits; } @@ -302,7 +302,7 @@ public function getTimeLimits() * * @return bool */ - public function hasTimeLimits() + public function hasTimeLimits(): bool { return $this->getTimeLimits() !== null; } @@ -313,7 +313,7 @@ public function hasTimeLimits() * * @param TimeLimits $timeLimits A TimeLimits object. */ - public function setTimeLimits(TimeLimits $timeLimits = null) + public function setTimeLimits(TimeLimits $timeLimits = null): void { $this->timeLimits = $timeLimits; } @@ -321,7 +321,7 @@ public function setTimeLimits(TimeLimits $timeLimits = null) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'sectionPart'; } @@ -329,7 +329,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge( $this->getBranchRules()->getArrayCopy(), diff --git a/src/qtism/data/SectionPartCollection.php b/src/qtism/data/SectionPartCollection.php index 98d95f9f7..6d3c92292 100644 --- a/src/qtism/data/SectionPartCollection.php +++ b/src/qtism/data/SectionPartCollection.php @@ -36,7 +36,7 @@ class SectionPartCollection extends QtiIdentifiableCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a SectionPart object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof SectionPart) { $msg = "SectionPartCollection class only accept SectionPart objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/ShowHide.php b/src/qtism/data/ShowHide.php index 084891b65..29c1f55c3 100644 --- a/src/qtism/data/ShowHide.php +++ b/src/qtism/data/ShowHide.php @@ -30,14 +30,14 @@ */ class ShowHide implements Enumeration { - const SHOW = 0; + public const SHOW = 0; - const HIDE = 1; + public const HIDE = 1; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'SHOW' => self::SHOW, @@ -51,7 +51,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'show': return self::SHOW; break; diff --git a/src/qtism/data/Shufflable.php b/src/qtism/data/Shufflable.php index 9fd218f73..b79cf8c57 100644 --- a/src/qtism/data/Shufflable.php +++ b/src/qtism/data/Shufflable.php @@ -34,5 +34,5 @@ interface Shufflable * * @return bool */ - public function isFixed(); + public function isFixed(): bool; } diff --git a/src/qtism/data/ShufflableCollection.php b/src/qtism/data/ShufflableCollection.php index c248517db..c57c3f73f 100644 --- a/src/qtism/data/ShufflableCollection.php +++ b/src/qtism/data/ShufflableCollection.php @@ -37,7 +37,7 @@ class ShufflableCollection extends AbstractCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a Shufflable object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Shufflable) { $msg = "ShufflableCollection class only accept Shufflable objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/SubmissionMode.php b/src/qtism/data/SubmissionMode.php index 64f0d63c3..93d5c393a 100644 --- a/src/qtism/data/SubmissionMode.php +++ b/src/qtism/data/SubmissionMode.php @@ -30,14 +30,14 @@ */ class SubmissionMode implements Enumeration { - const INDIVIDUAL = 0; + public const INDIVIDUAL = 0; - const SIMULTANEOUS = 1; + public const SIMULTANEOUS = 1; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'INDIVIDUAL' => self::INDIVIDUAL, @@ -51,7 +51,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'individual': return self::INDIVIDUAL; break; diff --git a/src/qtism/data/TestFeedback.php b/src/qtism/data/TestFeedback.php index 67e7b75c1..bcce8e20e 100644 --- a/src/qtism/data/TestFeedback.php +++ b/src/qtism/data/TestFeedback.php @@ -132,7 +132,7 @@ public function __construct($identifier, $outcomeIdentifier, FlowStaticCollectio * * @return int A value of the TestFeedbackAccess enumeration. */ - public function getAccess() + public function getAccess(): int { return $this->access; } @@ -146,7 +146,7 @@ public function getAccess() * @param int $access A value of the TestFeedbackAccess enumeration. * @throws InvalidArgumentException If $access is not a value from the TestFeedbackAccess enumeration. */ - public function setAccess($access) + public function setAccess($access): void { if (in_array($access, TestFeedbackAccess::asArray(), true)) { $this->access = $access; @@ -161,7 +161,7 @@ public function setAccess($access) * * @return string A QTI Identifier. */ - public function getOutcomeIdentifier() + public function getOutcomeIdentifier(): string { return $this->outcomeIdentifier; } @@ -172,9 +172,9 @@ public function getOutcomeIdentifier() * @param string $outcomeIdentifier A QTI Identifier. * @throws InvalidArgumentException If $outcomeIdentifier is not a valid QTI Identifier. */ - public function setOutcomeIdentifier($outcomeIdentifier) + public function setOutcomeIdentifier($outcomeIdentifier): void { - if (Format::isIdentifier($outcomeIdentifier)) { + if (Format::isIdentifier((string)$outcomeIdentifier)) { $this->outcomeIdentifier = $outcomeIdentifier; } else { $msg = "'${outcomeIdentifier}' is not a valid QTI Identifier."; @@ -187,7 +187,7 @@ public function setOutcomeIdentifier($outcomeIdentifier) * * @return int A value from the ShowHide enumeration. */ - public function getShowHide() + public function getShowHide(): int { return $this->showHide; } @@ -198,7 +198,7 @@ public function getShowHide() * @param bool $showHide A value from the ShowHide enumeration. * @throws InvalidArgumentException If $showHide is not a value from the ShowHide enumeration. */ - public function setShowHide($showHide) + public function setShowHide($showHide): void { if (in_array($showHide, ShowHide::asArray(), true)) { $this->showHide = $showHide; @@ -213,7 +213,7 @@ public function setShowHide($showHide) * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -224,9 +224,9 @@ public function getIdentifier() * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { - if (Format::isIdentifier($identifier, false)) { + if (Format::isIdentifier((string)$identifier, false)) { $this->identifier = $identifier; } else { $msg = "'${identifier}' is not a valid QTI Identifier."; @@ -239,7 +239,7 @@ public function setIdentifier($identifier) * * @return string A title. */ - public function getTitle() + public function getTitle(): string { return $this->title; } @@ -250,7 +250,7 @@ public function getTitle() * @param string $title A title. * @throws InvalidArgumentException If $title is not a string. */ - public function setTitle($title) + public function setTitle($title): void { if (is_string($title)) { $this->title = $title; @@ -265,7 +265,7 @@ public function setTitle($title) * * @return FlowStaticCollection The content of the TestFeedback. */ - public function getContent() + public function getContent(): FlowStaticCollection { return $this->content; } @@ -276,7 +276,7 @@ public function getContent() * @param FlowStaticCollection $content XML markup binary stream as a string. * @throws InvalidArgumentException If $content is not a string. */ - public function setContent(FlowStaticCollection $content) + public function setContent(FlowStaticCollection $content): void { $this->content = $content; } @@ -284,7 +284,7 @@ public function setContent(FlowStaticCollection $content) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'testFeedback'; } @@ -292,7 +292,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/TestFeedbackAccess.php b/src/qtism/data/TestFeedbackAccess.php index d8166760c..2c756a7a1 100644 --- a/src/qtism/data/TestFeedbackAccess.php +++ b/src/qtism/data/TestFeedbackAccess.php @@ -30,14 +30,14 @@ */ class TestFeedbackAccess implements Enumeration { - const AT_END = 0; + public const AT_END = 0; - const DURING = 1; + public const DURING = 1; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'AT_END' => self::AT_END, @@ -51,7 +51,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'atend': return self::AT_END; break; diff --git a/src/qtism/data/TestFeedbackCollection.php b/src/qtism/data/TestFeedbackCollection.php index 32f70e727..f772252dc 100644 --- a/src/qtism/data/TestFeedbackCollection.php +++ b/src/qtism/data/TestFeedbackCollection.php @@ -36,7 +36,7 @@ class TestFeedbackCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a TestFeedback object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof TestFeedback) { $msg = "TestFeedbackCollection class only accept TestFeedback objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/TestFeedbackRef.php b/src/qtism/data/TestFeedbackRef.php index e5c29030f..1338c4b16 100644 --- a/src/qtism/data/TestFeedbackRef.php +++ b/src/qtism/data/TestFeedbackRef.php @@ -112,7 +112,7 @@ public function __construct($identifier, $outcomeIdentifier, $access, $showHide, * * @return int A value of the TestFeedbackAccess enumeration. */ - public function getAccess() + public function getAccess(): int { return $this->access; } @@ -126,7 +126,7 @@ public function getAccess() * @param int $access A value of the TestFeedbackAccess enumeration. * @throws InvalidArgumentException If $access is not a value from the TestFeedbackAccess enumeration. */ - public function setAccess($access) + public function setAccess($access): void { if (in_array($access, TestFeedbackAccess::asArray(), true)) { $this->access = $access; @@ -141,7 +141,7 @@ public function setAccess($access) * * @return string A QTI Identifier. */ - public function getOutcomeIdentifier() + public function getOutcomeIdentifier(): string { return $this->outcomeIdentifier; } @@ -152,9 +152,9 @@ public function getOutcomeIdentifier() * @param string $outcomeIdentifier A QTI Identifier. * @throws InvalidArgumentException If $outcomeIdentifier is not a valid QTI Identifier. */ - public function setOutcomeIdentifier($outcomeIdentifier) + public function setOutcomeIdentifier($outcomeIdentifier): void { - if (Format::isIdentifier($outcomeIdentifier)) { + if (Format::isIdentifier((string)$outcomeIdentifier)) { $this->outcomeIdentifier = $outcomeIdentifier; } else { $msg = "'${outcomeIdentifier}' is not a valid QTI Identifier."; @@ -167,7 +167,7 @@ public function setOutcomeIdentifier($outcomeIdentifier) * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -178,9 +178,9 @@ public function getIdentifier() * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { - if (Format::isIdentifier($identifier, false)) { + if (Format::isIdentifier((string)$identifier, false)) { $this->identifier = $identifier; } else { $msg = "'${identifier}' is not a valid QTI Identifier."; @@ -193,7 +193,7 @@ public function setIdentifier($identifier) * * @return int A value from the ShowHide enumeration. */ - public function getShowHide() + public function getShowHide(): int { return $this->showHide; } @@ -204,7 +204,7 @@ public function getShowHide() * @param bool $showHide A value from the ShowHide enumeration. * @throws InvalidArgumentException If $showHide is not a value from the ShowHide enumeration. */ - public function setShowHide($showHide) + public function setShowHide($showHide): void { if (in_array($showHide, ShowHide::asArray(), true)) { $this->showHide = $showHide; @@ -219,7 +219,7 @@ public function setShowHide($showHide) * * @return string */ - public function getHref() + public function getHref(): string { return $this->href; } @@ -229,7 +229,7 @@ public function getHref() * * @param string $href */ - public function setHref($href) + public function setHref($href): void { if (Format::isUri($href) === true) { $this->href = $href; @@ -242,7 +242,7 @@ public function setHref($href) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'testFeedbackRef'; } @@ -250,7 +250,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/TestFeedbackRefCollection.php b/src/qtism/data/TestFeedbackRefCollection.php index ae94f7aba..d09a987f8 100644 --- a/src/qtism/data/TestFeedbackRefCollection.php +++ b/src/qtism/data/TestFeedbackRefCollection.php @@ -37,7 +37,7 @@ class TestFeedbackRefCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of TestFeedbackRef. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof TestFeedbackRef) { $msg = 'A TestFeedbackRefCollection object only accepts to store TestFeedbackRef objects.'; diff --git a/src/qtism/data/TestPart.php b/src/qtism/data/TestPart.php index 56e13bc1d..2b58d5399 100644 --- a/src/qtism/data/TestPart.php +++ b/src/qtism/data/TestPart.php @@ -153,7 +153,7 @@ public function __construct($identifier, SectionPartCollection $assessmentSectio * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -164,7 +164,7 @@ public function getIdentifier() * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false)) { $this->identifier = $identifier; @@ -180,7 +180,7 @@ public function setIdentifier($identifier) * * @return int A value of the Navigation enumeration. */ - public function getNavigationMode() + public function getNavigationMode(): int { return $this->navigationMode; } @@ -191,7 +191,7 @@ public function getNavigationMode() * @param int $navigationMode A value of the Navigation enumaration. * @throws InvalidArgumentException If $navigation mode is not a value from the Navigation enumeration. */ - public function setNavigationMode($navigationMode) + public function setNavigationMode($navigationMode): void { if (in_array($navigationMode, NavigationMode::asArray())) { $this->navigationMode = $navigationMode; @@ -206,7 +206,7 @@ public function setNavigationMode($navigationMode) * * @return int A value of the SubmissionMode enumeration. */ - public function getSubmissionMode() + public function getSubmissionMode(): int { return $this->submissionMode; } @@ -217,7 +217,7 @@ public function getSubmissionMode() * @param int $submissionMode A value of the SubmissionMode enumeration. * @throws InvalidArgumentException If $submissionMode is not a value from the SubmissionMode enumeration. */ - public function setSubmissionMode($submissionMode) + public function setSubmissionMode($submissionMode): void { if (in_array($submissionMode, SubmissionMode::asArray())) { $this->submissionMode = $submissionMode; @@ -232,7 +232,7 @@ public function setSubmissionMode($submissionMode) * * @return PreConditionCollection A collection of PreCondition objects. */ - public function getPreConditions() + public function getPreConditions(): PreConditionCollection { return $this->preConditions; } @@ -242,7 +242,7 @@ public function getPreConditions() * * @param PreConditionCollection $preConditions A collection of PreCondition objects. */ - public function setPreConditions(PreConditionCollection $preConditions) + public function setPreConditions(PreConditionCollection $preConditions): void { $this->preConditions = $preConditions; } @@ -252,7 +252,7 @@ public function setPreConditions(PreConditionCollection $preConditions) * * @return BranchRuleCollection A collection of BranchRule objects. */ - public function getBranchRules() + public function getBranchRules(): BranchRuleCollection { return $this->branchRules; } @@ -262,7 +262,7 @@ public function getBranchRules() * * @param BranchRuleCollection $branchRules A collection of BranchRule objects. */ - public function setBranchRules(BranchRuleCollection $branchRules) + public function setBranchRules(BranchRuleCollection $branchRules): void { $this->branchRules = $branchRules; } @@ -273,7 +273,7 @@ public function setBranchRules(BranchRuleCollection $branchRules) * * @return ItemSessionControl An ItemSessionControl object. */ - public function getItemSessionControl() + public function getItemSessionControl(): ?ItemSessionControl { return $this->itemSessionControl; } @@ -283,7 +283,7 @@ public function getItemSessionControl() * * @param ItemSessionControl $itemSessionControl An ItemSessionControl object. */ - public function setItemSessionControl(ItemSessionControl $itemSessionControl = null) + public function setItemSessionControl(ItemSessionControl $itemSessionControl = null): void { $this->itemSessionControl = $itemSessionControl; } @@ -293,7 +293,7 @@ public function setItemSessionControl(ItemSessionControl $itemSessionControl = n * * @return bool */ - public function hasItemSessionControl() + public function hasItemSessionControl(): bool { return $this->getItemSessionControl() !== null; } @@ -304,7 +304,7 @@ public function hasItemSessionControl() * * @return TimeLimits A TimeLimits object. */ - public function getTimeLimits() + public function getTimeLimits(): ?TimeLimits { return $this->timeLimits; } @@ -315,7 +315,7 @@ public function getTimeLimits() * * @param TimeLimits $timeLimits A TimeLimits object. */ - public function setTimeLimits(TimeLimits $timeLimits = null) + public function setTimeLimits(TimeLimits $timeLimits = null): void { $this->timeLimits = $timeLimits; } @@ -325,7 +325,7 @@ public function setTimeLimits(TimeLimits $timeLimits = null) * * @return bool */ - public function hasTimeLimits() + public function hasTimeLimits(): bool { return $this->getTimeLimits() !== null; } @@ -335,7 +335,7 @@ public function hasTimeLimits() * * @return SectionPartCollection A collection of AssessmentSection and/or AssessmentSectionRef objects. */ - public function getAssessmentSections() + public function getAssessmentSections(): SectionPartCollection { return $this->assessmentSections; } @@ -346,7 +346,7 @@ public function getAssessmentSections() * @param SectionPartCollection $assessmentSections A collection of AssessmentSection and/or AssessmentSectionRef objects. * @throws InvalidArgumentException If $assessmentSections is an empty collection or contains something else than AssessmentSection and/or AssessmentSectionRef objects. */ - public function setAssessmentSections(SectionPartCollection $assessmentSections) + public function setAssessmentSections(SectionPartCollection $assessmentSections): void { if (count($assessmentSections) > 0) { // Check that we have only AssessmentSection and/ord AssessmentSectionRef objects. @@ -369,7 +369,7 @@ public function setAssessmentSections(SectionPartCollection $assessmentSections) * * @return TestFeedbackCollection A collection of TestFeedback objects. */ - public function getTestFeedbacks() + public function getTestFeedbacks(): TestFeedbackCollection { return $this->testFeedbacks; } @@ -379,7 +379,7 @@ public function getTestFeedbacks() * * @param TestFeedbackCollection $testFeedbacks A collection of TestFeedback objects. */ - public function setTestFeedbacks(TestFeedbackCollection $testFeedbacks) + public function setTestFeedbacks(TestFeedbackCollection $testFeedbacks): void { $this->testFeedbacks = $testFeedbacks; } @@ -387,7 +387,7 @@ public function setTestFeedbacks(TestFeedbackCollection $testFeedbacks) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'testPart'; } @@ -395,7 +395,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge( $this->getAssessmentSections()->getArrayCopy(), diff --git a/src/qtism/data/TestPartCollection.php b/src/qtism/data/TestPartCollection.php index f811192a9..a94fdb3e6 100644 --- a/src/qtism/data/TestPartCollection.php +++ b/src/qtism/data/TestPartCollection.php @@ -36,7 +36,7 @@ class TestPartCollection extends QtiIdentifiableCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a TestPart object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof TestPart) { $msg = "TestPartCollection class only accept TestPart objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/TimeLimits.php b/src/qtism/data/TimeLimits.php index fe36116f0..bf64db0a9 100644 --- a/src/qtism/data/TimeLimits.php +++ b/src/qtism/data/TimeLimits.php @@ -94,7 +94,7 @@ public function __construct($minTime = null, $maxTime = null, $allowLateSubmissi * * @return QtiDuration A Duration object or null if unlimited. */ - public function getMinTime() + public function getMinTime(): ?QtiDuration { return $this->minTime; } @@ -104,7 +104,7 @@ public function getMinTime() * * @return bool */ - public function hasMinTime() + public function hasMinTime(): bool { return $this->getMinTime() !== null; } @@ -114,7 +114,7 @@ public function hasMinTime() * * @param QtiDuration $minTime A Duration object or null if unlimited. */ - public function setMinTime(QtiDuration $minTime = null) + public function setMinTime(QtiDuration $minTime = null): void { // Prevent to get 0s durations stored. if ($minTime !== null && $minTime->getSeconds(true) === 0) { @@ -129,7 +129,7 @@ public function setMinTime(QtiDuration $minTime = null) * * @return QtiDuration A Duration object or null if unlimited. */ - public function getMaxTime() + public function getMaxTime(): ?QtiDuration { return $this->maxTime; } @@ -139,7 +139,7 @@ public function getMaxTime() * * @return bool */ - public function hasMaxTime() + public function hasMaxTime(): bool { return $this->getMaxTime() !== null; } @@ -149,7 +149,7 @@ public function hasMaxTime() * * @param QtiDuration $maxTime A duration object or null if unlimited. */ - public function setMaxTime(QtiDuration $maxTime = null) + public function setMaxTime(QtiDuration $maxTime = null): void { // Prevent to get 0s durations stored. if ($maxTime !== null && $maxTime->getSeconds(true) === 0) { @@ -165,7 +165,7 @@ public function setMaxTime(QtiDuration $maxTime = null) * * @return bool true if the candidate's response should still be accepted, false if not. */ - public function doesAllowLateSubmission() + public function doesAllowLateSubmission(): bool { return $this->allowLateSubmission; } @@ -177,7 +177,7 @@ public function doesAllowLateSubmission() * @param bool $allowLateSubmission true if the candidate's response should still be accepted, false if not. * @throws InvalidArgumentException If $allowLateSubmission is not a boolean. */ - public function setAllowLateSubmission($allowLateSubmission) + public function setAllowLateSubmission($allowLateSubmission): void { if (is_bool($allowLateSubmission)) { $this->allowLateSubmission = $allowLateSubmission; @@ -190,7 +190,7 @@ public function setAllowLateSubmission($allowLateSubmission) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'timeLimits'; } @@ -198,7 +198,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/Utils.php b/src/qtism/data/Utils.php index 16760bd90..37e888f99 100644 --- a/src/qtism/data/Utils.php +++ b/src/qtism/data/Utils.php @@ -39,7 +39,7 @@ class Utils * @param AssessmentSectionCollection $sections The collection of all sections in this AssessmentTest. * @return AssessmentSection|null The parent of the AssessmentSection set as parameter, if any. */ - private static function checkRecursion($component, $sections) + private static function checkRecursion($component, $sections): ?AssessmentSection { $sectparent = null; @@ -67,11 +67,11 @@ private static function checkRecursion($component, $sections) * comes. * @param QtiComponent $component The QtiComponent targeted by a branch. * @param AssessmentSectionCollection $sections The collection of all sections in this AssessmentTest. - * @return AssessmentItem|null The first AssessmentItem that will be prompted if a branch targets the + * @return AssessmentItemRef|null The first AssessmentItem that will be prompted if a branch targets the * QtiComponent set as parameter. Returns null, if there are no more AssessmentItem because the end of the test * has been reached. */ - public static function getFirstItem($test, $component, $sections) + public static function getFirstItem($test, $component, $sections): ?AssessmentItemRef { $currentCmp = $component; $visitedNodes = []; @@ -185,11 +185,11 @@ public static function getFirstItem($test, $component, $sections) * starts. * @param QtiComponent $component The QtiComponent with a BranchRule. * @param AssessmentSectionCollection $sections The collection of all sections in this AssessmentTest. - * @return AssessmentItem|null The last AssessmentItem that will be prompted before taking a BranchRule + * @return AssessmentItemRef|null The last AssessmentItem that will be prompted before taking a BranchRule * in the QtiComponent set as parameter. Returns null, if there are no more AssessmentItem because the begin of the * test has been reached. */ - public static function getLastItem($test, $component, $sections) + public static function getLastItem($test, $component, $sections): ?AssessmentItemRef { $currentCmp = $component; // $sections = null; diff --git a/src/qtism/data/View.php b/src/qtism/data/View.php index 62ca4de80..42bd8696b 100644 --- a/src/qtism/data/View.php +++ b/src/qtism/data/View.php @@ -30,24 +30,24 @@ */ class View implements Enumeration { - const AUTHOR = 0; + public const AUTHOR = 0; - const CANDIDATE = 1; + public const CANDIDATE = 1; - const PROCTOR = 2; + public const PROCTOR = 2; - const SCORER = 3; + public const SCORER = 3; - const TEST_CONSTRUCTOR = 4; + public const TEST_CONSTRUCTOR = 4; - const TUTOR = 5; + public const TUTOR = 5; /** * Get the possible values of the enumaration as an array. * * @return array An array of integer constants. */ - public static function asArray() + public static function asArray(): array { return [ 'AUTHOR' => self::AUTHOR, diff --git a/src/qtism/data/ViewCollection.php b/src/qtism/data/ViewCollection.php index a547963f8..862c1d323 100644 --- a/src/qtism/data/ViewCollection.php +++ b/src/qtism/data/ViewCollection.php @@ -37,7 +37,7 @@ class ViewCollection extends IntegerCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a valid View enumeration value. */ - protected function checkType($value) + protected function checkType($value): void { if (!in_array($value, View::asArray())) { $msg = "The ViewsCollection class only accept View enumeration values, '${value}' given."; diff --git a/src/qtism/data/XInclude.php b/src/qtism/data/XInclude.php index 0961a2156..06f5e1ac7 100644 --- a/src/qtism/data/XInclude.php +++ b/src/qtism/data/XInclude.php @@ -46,7 +46,7 @@ public function __construct($xmlString) * * @return string */ - public function getHref() + public function getHref(): string { $xml = $this->getXml(); return $xml->documentElement->getAttribute('href'); @@ -55,12 +55,12 @@ public function getHref() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'include'; } - protected function buildTargetNamespace() + protected function buildTargetNamespace(): void { $this->setTargetNamespace('http://www.w3.org/2001/XInclude'); } diff --git a/src/qtism/data/content/AtomicBlock.php b/src/qtism/data/content/AtomicBlock.php index 35596aa0a..22c70ff5c 100644 --- a/src/qtism/data/content/AtomicBlock.php +++ b/src/qtism/data/content/AtomicBlock.php @@ -57,7 +57,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @param InlineCollection $content A collection of Inline objects. */ - public function setContent(InlineCollection $content) + public function setContent(InlineCollection $content): void { $this->content = $content; } @@ -67,7 +67,7 @@ public function setContent(InlineCollection $content) * * @return InlineCollection */ - public function getContent() + public function getContent(): InlineCollection { return $this->content; } @@ -77,7 +77,7 @@ public function getContent() * * @return InlineCollection A collection of Inline objects. */ - public function getComponents() + public function getComponents(): InlineCollection { return $this->getContent(); } diff --git a/src/qtism/data/content/AtomicInline.php b/src/qtism/data/content/AtomicInline.php index e61eeee9a..bdf4c6a0a 100644 --- a/src/qtism/data/content/AtomicInline.php +++ b/src/qtism/data/content/AtomicInline.php @@ -51,7 +51,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @return QtiComponentCollection An empty QtiComponentCollection. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/content/BlockCollection.php b/src/qtism/data/content/BlockCollection.php index 7cc2ba549..1bad733d6 100644 --- a/src/qtism/data/content/BlockCollection.php +++ b/src/qtism/data/content/BlockCollection.php @@ -38,7 +38,7 @@ class BlockCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an Block object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Block) { $msg = 'BlockCollection objects only accept to store Block objects.'; diff --git a/src/qtism/data/content/BlockStaticCollection.php b/src/qtism/data/content/BlockStaticCollection.php index 9ea878e84..40c1b43a1 100644 --- a/src/qtism/data/content/BlockStaticCollection.php +++ b/src/qtism/data/content/BlockStaticCollection.php @@ -37,7 +37,7 @@ class BlockStaticCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of BlockStatic. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof BlockStatic) { $msg = 'BlockStaticCollection objects only accept BlockStatic objects to be stored.'; diff --git a/src/qtism/data/content/BodyElement.php b/src/qtism/data/content/BodyElement.php index c903d5e02..800330fcd 100644 --- a/src/qtism/data/content/BodyElement.php +++ b/src/qtism/data/content/BodyElement.php @@ -175,7 +175,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @return string A QTI identifier. */ - public function getId() + public function getId(): string { return $this->id; } @@ -186,7 +186,7 @@ public function getId() * @param string $id A QTI Identifier. * @throws InvalidArgumentException If $id is not a valid QTI identifier. */ - public function setId($id = '') + public function setId($id = ''): void { if (is_string($id) && (empty($id) || Format::isIdentifier($id, false) === true)) { $this->id = $id; @@ -201,7 +201,7 @@ public function setId($id = '') * * @return bool */ - public function hasId() + public function hasId(): bool { return $this->getId() !== ''; } @@ -211,7 +211,7 @@ public function hasId() * * @return string One or more class names separated by spaces. */ - public function getClass() + public function getClass(): string { return $this->class; } @@ -222,7 +222,7 @@ public function getClass() * @param string $class One or more class names separated by spaces. * @throws InvalidArgumentException If $class does not represent valid class name(s). */ - public function setClass($class = '') + public function setClass($class = ''): void { if (!is_string($class)) { $msg = 'The "class" argument must be a valid class name, "' . gettype($class) . '" given'; @@ -244,7 +244,7 @@ public function setClass($class = '') * * @return bool */ - public function hasClass() + public function hasClass(): bool { return $this->getClass() !== ''; } @@ -254,7 +254,7 @@ public function hasClass() * * @return string An RFC3066 language. */ - public function getLang() + public function getLang(): string { return $this->lang; } @@ -264,7 +264,7 @@ public function getLang() * * @param string $lang An RFC3066 language. */ - public function setLang($lang = '') + public function setLang($lang = ''): void { $this->lang = $lang; } @@ -274,7 +274,7 @@ public function setLang($lang = '') * * @return bool */ - public function hasLang() + public function hasLang(): bool { return $this->getLang() !== ''; } @@ -284,7 +284,7 @@ public function hasLang() * * @return string A string of 256 characters maximum. */ - public function getLabel() + public function getLabel(): string { return $this->label; } @@ -295,7 +295,7 @@ public function getLabel() * @param string $label A string of 256 characters maximum. * @throws InvalidArgumentException If $label is not or a string or contains more than 256 characters. */ - public function setLabel($label = '') + public function setLabel($label = ''): void { if (Format::isString256($label) === true) { $this->label = $label; @@ -310,7 +310,7 @@ public function setLabel($label = '') * * @return bool */ - public function hasLabel() + public function hasLabel(): bool { return $this->getLabel() !== ''; } @@ -321,7 +321,7 @@ public function hasLabel() * @param int $dir A value from the Direction enumeration. * @throws InvalidArgumentException If $dir is not a value from the Direction enumeration. */ - public function setDir($dir) + public function setDir($dir): void { if (in_array($dir, Direction::asArray(), true)) { $this->dir = $dir; @@ -336,7 +336,7 @@ public function setDir($dir) * * @return int A value from the Direction enumeration. */ - public function getDir() + public function getDir(): int { return $this->dir; } @@ -345,7 +345,7 @@ public function getDir() * @param string $ariaControls * @throws InvalidArgumentException */ - public function setAriaControls(string $ariaControls) + public function setAriaControls(string $ariaControls): void { if ($ariaControls !== '' && !Format::isAriaIdRefs($ariaControls)) { $msg = "'${ariaControls}' is not a valid value for attribute 'aria-controls'."; @@ -358,7 +358,7 @@ public function setAriaControls(string $ariaControls) /** * @return string */ - public function getAriaControls() + public function getAriaControls(): string { return $this->ariaControls; } @@ -366,7 +366,7 @@ public function getAriaControls() /** * @return bool */ - public function hasAriaControls() + public function hasAriaControls(): bool { return $this->ariaControls !== ''; } @@ -388,7 +388,7 @@ public function setAriaDescribedBy(string $ariaDescribedBy): void /** * @return string */ - public function getAriaDescribedBy() + public function getAriaDescribedBy(): string { return $this->ariaDescribedBy; } @@ -396,7 +396,7 @@ public function getAriaDescribedBy() /** * @return bool */ - public function hasAriaDescribedBy() + public function hasAriaDescribedBy(): bool { return $this->ariaDescribedBy !== ''; } @@ -418,7 +418,7 @@ public function setAriaFlowTo(string $ariaFlowTo): void /** * @return string */ - public function getAriaFlowTo() + public function getAriaFlowTo(): string { return $this->ariaFlowTo; } @@ -426,7 +426,7 @@ public function getAriaFlowTo() /** * @return bool */ - public function hasAriaFlowTo() + public function hasAriaFlowTo(): bool { return $this->ariaFlowTo !== ''; } @@ -448,7 +448,7 @@ public function setAriaLabelledBy(string $ariaLabelledBy): void /** * @return string */ - public function getAriaLabelledBy() + public function getAriaLabelledBy(): string { return $this->ariaLabelledBy; } @@ -456,7 +456,7 @@ public function getAriaLabelledBy() /** * @return bool */ - public function hasAriaLabelledBy() + public function hasAriaLabelledBy(): bool { return $this->ariaLabelledBy !== ''; } @@ -478,7 +478,7 @@ public function setAriaOwns(string $ariaOwns): void /** * @return string */ - public function getAriaOwns() + public function getAriaOwns(): string { return $this->ariaOwns; } @@ -486,7 +486,7 @@ public function getAriaOwns() /** * @return bool */ - public function hasAriaOwns() + public function hasAriaOwns(): bool { return $this->ariaOwns !== ''; } @@ -495,7 +495,7 @@ public function hasAriaOwns() * @param string $ariaLevel * @throws InvalidArgumentException */ - public function setAriaLevel(string $ariaLevel) + public function setAriaLevel(string $ariaLevel): void { if ($ariaLevel !== '' && !Format::isAriaLevel($ariaLevel)) { $msg = "'${ariaLevel}' is not a valid value for attribute 'aria-level'."; @@ -508,7 +508,7 @@ public function setAriaLevel(string $ariaLevel) /** * @return string */ - public function getAriaLevel() + public function getAriaLevel(): string { return $this->ariaLevel; } @@ -516,7 +516,7 @@ public function getAriaLevel() /** * @return bool */ - public function hasAriaLevel() + public function hasAriaLevel(): bool { return $this->ariaLevel !== ''; } @@ -536,8 +536,9 @@ public function setAriaLive(int $ariaLive): void } /** - * @return int + * @return int|false */ + #[\ReturnTypeWillChange] public function getAriaLive() { return $this->ariaLive; @@ -546,7 +547,7 @@ public function getAriaLive() /** * @return bool */ - public function hasAriaLive() + public function hasAriaLive(): bool { return $this->ariaLive !== false; } @@ -555,7 +556,7 @@ public function hasAriaLive() * @param int $ariaOrientation A value from the AriaOrientation enumeration or false for no orientation. * @throws InvalidArgumentException */ - public function setAriaOrientation($ariaOrientation) + public function setAriaOrientation($ariaOrientation): void { if ($ariaOrientation === false || in_array($ariaOrientation, AriaOrientation::asArray(), true)) { $this->ariaOrientation = $ariaOrientation; @@ -577,7 +578,7 @@ public function getAriaOrientation() /** * @return bool */ - public function hasAriaOrientation() + public function hasAriaOrientation(): bool { return $this->ariaOrientation !== false; } @@ -586,7 +587,7 @@ public function hasAriaOrientation() * @param $ariaLabel * @throws InvalidArgumentException */ - public function setAriaLabel($ariaLabel) + public function setAriaLabel($ariaLabel): void { if (!is_string($ariaLabel)) { $val = (is_object($ariaLabel)) ? ('instance of ' . get_class($ariaLabel)) : $ariaLabel; @@ -601,7 +602,7 @@ public function setAriaLabel($ariaLabel) /** * @return string */ - public function getAriaLabel() + public function getAriaLabel(): string { return $this->ariaLabel; } @@ -609,7 +610,7 @@ public function getAriaLabel() /** * @return bool */ - public function hasAriaLabel() + public function hasAriaLabel(): bool { return $this->ariaLabel !== ''; } @@ -618,7 +619,7 @@ public function hasAriaLabel() * @param bool $ariaHidden * @throws InvalidArgumentException */ - public function setAriaHidden($ariaHidden) + public function setAriaHidden($ariaHidden): void { if (!is_bool($ariaHidden)) { $val = (is_object($ariaHidden)) ? ('instance of ' . get_class($ariaHidden)) : $ariaHidden; @@ -633,7 +634,7 @@ public function setAriaHidden($ariaHidden) /** * @return bool */ - public function getAriaHidden() + public function getAriaHidden(): bool { return $this->ariaHidden; } @@ -641,7 +642,7 @@ public function getAriaHidden() /** * @return bool */ - public function hasAriaHidden() + public function hasAriaHidden(): bool { return $this->ariaHidden !== false; } diff --git a/src/qtism/data/content/Direction.php b/src/qtism/data/content/Direction.php index fd81317b6..a611c1997 100644 --- a/src/qtism/data/content/Direction.php +++ b/src/qtism/data/content/Direction.php @@ -37,26 +37,26 @@ class Direction implements Enumeration * * @var int */ - const AUTO = 0; + public const AUTO = 0; /** * Left To Right direction. * * @var int */ - const LTR = 1; + public const LTR = 1; /** * Right to Left direction. * * @var int */ - const RTL = 2; + public const RTL = 2; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'AUTO' => self::AUTO, @@ -71,7 +71,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'auto': return self::AUTO; break; diff --git a/src/qtism/data/content/FeedbackBlock.php b/src/qtism/data/content/FeedbackBlock.php index 88dfa0a54..817146363 100644 --- a/src/qtism/data/content/FeedbackBlock.php +++ b/src/qtism/data/content/FeedbackBlock.php @@ -109,7 +109,7 @@ public function __construct($outcomeIdentifier, $identifier, $showHide = ShowHid * @param string $outcomeIdentifier A QTI identifier. * @throws InvalidArgumentException If $outcomeIdentifier is an invalid identifier. */ - public function setOutcomeIdentifier($outcomeIdentifier) + public function setOutcomeIdentifier($outcomeIdentifier): void { if (Format::isIdentifier($outcomeIdentifier, false) === true) { $this->outcomeIdentifier = $outcomeIdentifier; @@ -124,7 +124,7 @@ public function setOutcomeIdentifier($outcomeIdentifier) * * @return string a QTI identifier. */ - public function getOutcomeIdentifier() + public function getOutcomeIdentifier(): string { return $this->outcomeIdentifier; } @@ -136,7 +136,7 @@ public function getOutcomeIdentifier() * * @param int A value from the ShowHide enumeration. */ - public function setShowHide($showHide) + public function setShowHide($showHide): void { if (in_array($showHide, ShowHide::asArray(), true)) { $this->showHide = $showHide; @@ -151,7 +151,7 @@ public function setShowHide($showHide) * * @return int A value from the ShowHide enumeration. */ - public function getShowHide() + public function getShowHide(): int { return $this->showHide; } @@ -162,7 +162,7 @@ public function getShowHide() * @param string $identifier A QTI identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false) === true) { $this->identifier = $identifier; @@ -177,7 +177,7 @@ public function setIdentifier($identifier) * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -187,7 +187,7 @@ public function getIdentifier() * * @param FlowCollection $content A collection of FlowStatic objects. */ - public function setContent(FlowCollection $content) + public function setContent(FlowCollection $content): void { $this->content = $content; } @@ -197,7 +197,7 @@ public function setContent(FlowCollection $content) * * @return FlowCollection */ - public function getContent() + public function getContent(): FlowCollection { return $this->content; } @@ -205,7 +205,7 @@ public function getContent() /** * @return FlowCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -213,7 +213,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'feedbackBlock'; } diff --git a/src/qtism/data/content/FeedbackElement.php b/src/qtism/data/content/FeedbackElement.php index 48c5e1744..4991c0d30 100644 --- a/src/qtism/data/content/FeedbackElement.php +++ b/src/qtism/data/content/FeedbackElement.php @@ -55,7 +55,7 @@ public function setOutcomeIdentifier($outcomeIdentifier); * * @return string A QTI Identifier. */ - public function getOutcomeIdentifier(); + public function getOutcomeIdentifier(): string; /** * Set how the visibility of the feedbackElement is controlled. @@ -70,7 +70,7 @@ public function setShowHide($showHide); * * @return int A value from the ShowHide enumeration. */ - public function getShowHide(); + public function getShowHide(): int; /** * Set the identifier typed value that determines the visibility of the feedback in conjunction @@ -87,5 +87,5 @@ public function setIdentifier($identifier); * * @return string A QTI identifier. */ - public function getIdentifier(); + public function getIdentifier(): string; } diff --git a/src/qtism/data/content/FeedbackInline.php b/src/qtism/data/content/FeedbackInline.php index 8b77e3ece..4cc4279cc 100644 --- a/src/qtism/data/content/FeedbackInline.php +++ b/src/qtism/data/content/FeedbackInline.php @@ -97,7 +97,7 @@ public function __construct($outcomeIdentifier, $identifier, $showHide = ShowHid * @param string $outcomeIdentifier A QTI identifier. * @throws InvalidArgumentException If $outcomeIdentifier is not a valid QTI identifier. */ - public function setOutcomeIdentifier($outcomeIdentifier) + public function setOutcomeIdentifier($outcomeIdentifier): void { if (Format::isIdentifier($outcomeIdentifier, false) === true) { $this->outcomeIdentifier = $outcomeIdentifier; @@ -112,7 +112,7 @@ public function setOutcomeIdentifier($outcomeIdentifier) * * @return string A QTI identifier. */ - public function getOutcomeIdentifier() + public function getOutcomeIdentifier(): string { return $this->outcomeIdentifier; } @@ -125,7 +125,7 @@ public function getOutcomeIdentifier() * @param int $showHide A value from the ShowHide enumeration. * @throws InvalidArgumentException If $showHide is not a value from the ShowHide enumeration. */ - public function setShowHide($showHide) + public function setShowHide($showHide): void { if (in_array($showHide, ShowHide::asArray())) { $this->showHide = $showHide; @@ -140,7 +140,7 @@ public function setShowHide($showHide) * * @return int A value from the ShowHide enumeration. */ - public function getShowHide() + public function getShowHide(): int { return $this->showHide; } @@ -151,7 +151,7 @@ public function getShowHide() * @param string $identifier A QTI identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false) === true) { $this->identifier = $identifier; @@ -166,7 +166,7 @@ public function setIdentifier($identifier) * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -174,7 +174,7 @@ public function getIdentifier() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'feedbackInline'; } diff --git a/src/qtism/data/content/Flow.php b/src/qtism/data/content/Flow.php index 53cea3378..ec05510fc 100644 --- a/src/qtism/data/content/Flow.php +++ b/src/qtism/data/content/Flow.php @@ -48,12 +48,12 @@ public function setXmlBase($base = ''); * * @return string A URI or an empty string if no base is set. */ - public function getXmlBase(); + public function getXmlBase(): string; /** * Whether or not a value is defined for the xml:base attribute. * * @return bool */ - public function hasXmlBase(); + public function hasXmlBase(): bool; } diff --git a/src/qtism/data/content/FlowCollection.php b/src/qtism/data/content/FlowCollection.php index 9ee06ef02..b2b7147f9 100644 --- a/src/qtism/data/content/FlowCollection.php +++ b/src/qtism/data/content/FlowCollection.php @@ -38,7 +38,7 @@ class FlowCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a Flow object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Flow) { $msg = 'FlowCollection objects only accept to store Flow objects, "' . get_class($value) . '" given'; diff --git a/src/qtism/data/content/FlowStaticCollection.php b/src/qtism/data/content/FlowStaticCollection.php index 9df8e2a52..1f3304e4f 100644 --- a/src/qtism/data/content/FlowStaticCollection.php +++ b/src/qtism/data/content/FlowStaticCollection.php @@ -37,7 +37,7 @@ class FlowStaticCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a FlowStatic object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof FlowStatic) { $msg = 'FlowStaticCollection objects only accept to store FlowStatic objects.'; diff --git a/src/qtism/data/content/FlowTrait.php b/src/qtism/data/content/FlowTrait.php index 43fbc040c..2e08d1095 100644 --- a/src/qtism/data/content/FlowTrait.php +++ b/src/qtism/data/content/FlowTrait.php @@ -50,7 +50,7 @@ trait FlowTrait * @param string $xmlBase A URI. * @throws InvalidArgumentException if $base is not a valid URI nor an empty string. */ - public function setXmlBase($xmlBase = '') + public function setXmlBase($xmlBase = ''): void { if (is_string($xmlBase) && (empty($xmlBase) || Format::isUri($xmlBase))) { $this->xmlBase = $xmlBase; @@ -65,7 +65,7 @@ public function setXmlBase($xmlBase = '') * * @return string An empty string or a URI. */ - public function getXmlBase() + public function getXmlBase(): string { return $this->xmlBase; } @@ -74,7 +74,7 @@ public function getXmlBase() * Does the element have a XmlBase? * @return bool */ - public function hasXmlBase() + public function hasXmlBase(): bool { return $this->getXmlBase() !== ''; } diff --git a/src/qtism/data/content/InfoControl.php b/src/qtism/data/content/InfoControl.php index 944bec350..a9bae16d3 100644 --- a/src/qtism/data/content/InfoControl.php +++ b/src/qtism/data/content/InfoControl.php @@ -75,7 +75,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @param FlowStaticCollection $content A collection of FlowStatic objects. */ - public function setContent(FlowStaticCollection $content) + public function setContent(FlowStaticCollection $content): void { $this->content = $content; } @@ -85,7 +85,7 @@ public function setContent(FlowStaticCollection $content) * * @return FlowStaticCollection A collection of FlowStatic objects. */ - public function getContent() + public function getContent(): FlowStaticCollection { return $this->content; } @@ -96,7 +96,7 @@ public function getContent() * @param string $title The title of the InfoControl. * @throws InvalidArgumentException If $title is not a string. */ - public function setTitle($title) + public function setTitle($title): void { if (is_string($title)) { $this->title = $title; @@ -111,7 +111,7 @@ public function setTitle($title) * * @return string The title of the InfoControl. */ - public function getTitle() + public function getTitle(): string { return $this->title; } @@ -119,7 +119,7 @@ public function getTitle() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'infoControl'; } @@ -127,7 +127,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection($this->getContent()->getArrayCopy()); } diff --git a/src/qtism/data/content/InlineCollection.php b/src/qtism/data/content/InlineCollection.php index 9f3f698e7..48bb21266 100644 --- a/src/qtism/data/content/InlineCollection.php +++ b/src/qtism/data/content/InlineCollection.php @@ -38,7 +38,7 @@ class InlineCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an Inline object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Inline) { $msg = 'InlineCollection objects only accept to store Inline objects.'; diff --git a/src/qtism/data/content/InlineStaticCollection.php b/src/qtism/data/content/InlineStaticCollection.php index 3161d8046..5f667862a 100644 --- a/src/qtism/data/content/InlineStaticCollection.php +++ b/src/qtism/data/content/InlineStaticCollection.php @@ -39,7 +39,7 @@ class InlineStaticCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof InlineStatic) { $msg = 'InlineStaticCollection objects only accept to store InlineStatic objects.'; diff --git a/src/qtism/data/content/ItemBody.php b/src/qtism/data/content/ItemBody.php index a98cad91b..2225f8597 100644 --- a/src/qtism/data/content/ItemBody.php +++ b/src/qtism/data/content/ItemBody.php @@ -77,7 +77,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @param BlockCollection $content The collection of blocks composing the itemBody. */ - public function setContent(BlockCollection $content) + public function setContent(BlockCollection $content): void { $this->content = $content; } @@ -87,7 +87,7 @@ public function setContent(BlockCollection $content) * * @return BlockCollection */ - public function getContent() + public function getContent(): BlockCollection { return $this->content; } @@ -97,7 +97,7 @@ public function getContent() * * @return BlockCollection A collection of Block objects. */ - public function getComponents() + public function getComponents(): BlockCollection { return $this->getContent(); } @@ -105,7 +105,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'itemBody'; } diff --git a/src/qtism/data/content/Math.php b/src/qtism/data/content/Math.php index ca413b67a..6a2c0a802 100644 --- a/src/qtism/data/content/Math.php +++ b/src/qtism/data/content/Math.php @@ -49,12 +49,12 @@ public function __construct($xmlString) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'math'; } - protected function buildTargetNamespace() + protected function buildTargetNamespace(): void { $this->setTargetNamespace('http://www.w3.org/1998/Math/MathML'); } diff --git a/src/qtism/data/content/ModalFeedback.php b/src/qtism/data/content/ModalFeedback.php index b9057358d..ea470aca7 100644 --- a/src/qtism/data/content/ModalFeedback.php +++ b/src/qtism/data/content/ModalFeedback.php @@ -127,7 +127,7 @@ public function __construct($outcomeIdentifier, $identifier, FlowStaticCollectio * @param string $outcomeIdentifier A valid QTI identifier. * @throws InvalidArgumentException If $outcomeIdentifier is not a valid QTI identifier. */ - public function setOutcomeIdentifier($outcomeIdentifier) + public function setOutcomeIdentifier($outcomeIdentifier): void { if (Format::isIdentifier($outcomeIdentifier, false) === true) { $this->outcomeIdentifier = $outcomeIdentifier; @@ -143,7 +143,7 @@ public function setOutcomeIdentifier($outcomeIdentifier) * * @return string A QTI identifier. */ - public function getOutcomeIdentifier() + public function getOutcomeIdentifier(): string { return $this->outcomeIdentifier; } @@ -154,7 +154,7 @@ public function getOutcomeIdentifier() * @param int $showHide A value from the ShowHide enumeration. * @throws InvalidArgumentException If $showHide is not a value from the ShowHide enumeration. */ - public function setShowHide($showHide) + public function setShowHide($showHide): void { if (in_array($showHide, ShowHide::asArray(), true)) { $this->showHide = $showHide; @@ -169,7 +169,7 @@ public function setShowHide($showHide) * * @return int A value from the ShowHide enumeration. */ - public function getShowHide() + public function getShowHide(): int { return $this->showHide; } @@ -181,7 +181,7 @@ public function getShowHide() * @param string $identifier A QTI identifier * @throws InvalidArgumentException If $identifier is not a valid QTI identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false) === true) { $this->identifier = $identifier; @@ -197,7 +197,7 @@ public function setIdentifier($identifier) * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -207,7 +207,7 @@ public function getIdentifier() * * @param string $title A title. */ - public function setTitle($title) + public function setTitle($title): void { $this->title = $title; } @@ -217,7 +217,7 @@ public function setTitle($title) * * @return string A title. */ - public function getTitle() + public function getTitle(): string { return $this->title; } @@ -227,7 +227,7 @@ public function getTitle() * * @return bool */ - public function hasTitle() + public function hasTitle(): bool { return $this->getTitle() !== ''; } @@ -237,7 +237,7 @@ public function hasTitle() * * @param FlowStaticCollection $content A collection of FlowStatic objects. */ - public function setContent(FlowStaticCollection $content) + public function setContent(FlowStaticCollection $content): void { $this->content = $content; } @@ -247,7 +247,7 @@ public function setContent(FlowStaticCollection $content) * * @return FlowStaticCollection A collection of FlowStatic objects. */ - public function getContent() + public function getContent(): FlowStaticCollection { return $this->content; } @@ -255,7 +255,7 @@ public function getContent() /** * @return FlowStaticCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -263,7 +263,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'modalFeedback'; } diff --git a/src/qtism/data/content/ModalFeedbackCollection.php b/src/qtism/data/content/ModalFeedbackCollection.php index ee3288f85..2a4fefe20 100644 --- a/src/qtism/data/content/ModalFeedbackCollection.php +++ b/src/qtism/data/content/ModalFeedbackCollection.php @@ -37,7 +37,7 @@ class ModalFeedbackCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of ModalFeedback. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof ModalFeedback) { $msg = 'ModalFeedbackCollection only accept to store ModalFeedback objects.'; diff --git a/src/qtism/data/content/ModalFeedbackRule.php b/src/qtism/data/content/ModalFeedbackRule.php index 84ee945a2..bfd911f68 100644 --- a/src/qtism/data/content/ModalFeedbackRule.php +++ b/src/qtism/data/content/ModalFeedbackRule.php @@ -91,9 +91,9 @@ public function __construct($outcomeIdentifier, $showHide, $identifier, $title = * @param string $identifier A QTI identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { - if (Format::isIdentifier($identifier, false) === true) { + if (Format::isIdentifier((string)$identifier, false) === true) { $this->identifier = $identifier; } else { $msg = "The 'identifier' argument must be a valid QTI identifier, '" . $identifier . "' given."; @@ -106,7 +106,7 @@ public function setIdentifier($identifier) * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -118,9 +118,9 @@ public function getIdentifier() * @param string $outcomeIdentifier A QTI identifier. * @throws InvalidArgumentException If $outcomeIdentifier is not a valid QTI identifier. */ - public function setOutcomeIdentifier($outcomeIdentifier) + public function setOutcomeIdentifier($outcomeIdentifier): void { - if (Format::isIdentifier($outcomeIdentifier, false) === true) { + if (Format::isIdentifier((string)$outcomeIdentifier, false) === true) { $this->outcomeIdentifier = $outcomeIdentifier; } else { $msg = "The 'outcomeIdentifier' argument must be a valid QTI identifier, '" . $outcomeIdentifier . "' given."; @@ -134,7 +134,7 @@ public function setOutcomeIdentifier($outcomeIdentifier) * * @return string A QTI identifier. */ - public function getOutcomeIdentifier() + public function getOutcomeIdentifier(): string { return $this->outcomeIdentifier; } @@ -145,7 +145,7 @@ public function getOutcomeIdentifier() * @param int $showHide A value from the ShowHide enumeration. * @throws InvalidArgumentException If $showHide is not a value from the ShowHide enumeration. */ - public function setShowHide($showHide) + public function setShowHide($showHide): void { if (in_array($showHide, ShowHide::asArray(), true)) { $this->showHide = $showHide; @@ -160,7 +160,7 @@ public function setShowHide($showHide) * * @return int A value from the ShowHide enumeration. */ - public function getShowHide() + public function getShowHide(): int { return $this->showHide; } @@ -173,7 +173,7 @@ public function getShowHide() * @param string $title * @throws InvalidArgumentException If $title is not a string. */ - public function setTitle($title) + public function setTitle($title): void { if (is_string($title)) { $this->title = $title; @@ -188,7 +188,7 @@ public function setTitle($title) * * @return string */ - public function getTitle() + public function getTitle(): string { return $this->title; } @@ -198,7 +198,7 @@ public function getTitle() * * @return bool */ - public function hasTitle() + public function hasTitle(): bool { return $this->getTitle() !== ''; } @@ -206,7 +206,7 @@ public function hasTitle() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -214,7 +214,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'modalFeedbackRule'; } diff --git a/src/qtism/data/content/ModalFeedbackRuleCollection.php b/src/qtism/data/content/ModalFeedbackRuleCollection.php index 2e1f6d331..a9657b6b6 100644 --- a/src/qtism/data/content/ModalFeedbackRuleCollection.php +++ b/src/qtism/data/content/ModalFeedbackRuleCollection.php @@ -37,7 +37,7 @@ class ModalFeedbackRuleCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of ModalFeedbackRule. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof ModalFeedbackRule) { $msg = 'A RubricBlockRefCollection object only accepts to store ModalFeedbackRule objects.'; diff --git a/src/qtism/data/content/ObjectFlowCollection.php b/src/qtism/data/content/ObjectFlowCollection.php index 531cf4605..703b1001d 100644 --- a/src/qtism/data/content/ObjectFlowCollection.php +++ b/src/qtism/data/content/ObjectFlowCollection.php @@ -37,7 +37,7 @@ class ObjectFlowCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an ObjectFlow object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof ObjectFlow) { $msg = 'ObjectFlowCollection objects only accepts ObjectFlow objects to be stored.'; diff --git a/src/qtism/data/content/PrintedVariable.php b/src/qtism/data/content/PrintedVariable.php index dc2056401..25be9354f 100644 --- a/src/qtism/data/content/PrintedVariable.php +++ b/src/qtism/data/content/PrintedVariable.php @@ -190,7 +190,7 @@ public function __construct($identifier, $id = '', $class = '', $lang = '', $lab * @param string $identifier A valid QTI identifier. * @throws InvalidArgumentException If the given $identifier is invalid. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false) === true) { $this->identifier = $identifier; @@ -205,7 +205,7 @@ public function setIdentifier($identifier) * * @return string A valid QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -218,7 +218,7 @@ public function getIdentifier() * @throws InvalidArgumentException If $format is not a string with at most 256 characters. * @see http://www.imsglobal.org/question/qtiv2p1/imsqti_infov2p1.html#section10074 */ - public function setFormat($format) + public function setFormat($format): void { if (Format::isString256($format) === true) { $this->format = $format; @@ -235,7 +235,7 @@ public function setFormat($format) * @return string A string with at most 256 characters. * @see http://www.imsglobal.org/question/qtiv2p1/imsqti_infov2p1.html#section10074 */ - public function getFormat() + public function getFormat(): string { return $this->format; } @@ -245,7 +245,7 @@ public function getFormat() * * @return bool */ - public function hasFormat() + public function hasFormat(): bool { return $this->getFormat() !== ''; } @@ -257,7 +257,7 @@ public function hasFormat() * @param bool $powerForm * @throws InvalidArgumentException If $powerForm is not a boolean value. */ - public function setPowerForm($powerForm) + public function setPowerForm($powerForm): void { if (is_bool($powerForm)) { $this->powerForm = $powerForm; @@ -273,7 +273,7 @@ public function setPowerForm($powerForm) * * @return bool */ - public function mustPowerForm() + public function mustPowerForm(): bool { return $this->powerForm; } @@ -284,9 +284,9 @@ public function mustPowerForm() * @param int|string $base A base to use for conversion as an integer or a variable reference. * @throws InvalidArgumentException If $base is not an integer nor a variable reference. */ - public function setBase($base) + public function setBase($base): void { - if (is_int($base) || Format::isVariableRef($base) === true) { + if (is_int($base) || Format::isVariableRef((string)$base) === true) { $this->base = $base; } else { $msg = "The 'base' argument must be an integer or a variable reference, '" . $base . "' given."; @@ -311,9 +311,9 @@ public function getBase() * @param int|string $index An integer or variable reference. * @throws InvalidArgumentException If $index is not an integer nor a variable reference. */ - public function setIndex($index) + public function setIndex($index): void { - if (is_int($index) || Format::isVariableRef($index) === true) { + if (is_int($index) || Format::isVariableRef((string)$index) === true) { $this->index = $index; } else { $msg = "The 'index' argument must be an integer or a variable reference, '" . $index . "' given."; @@ -337,7 +337,7 @@ public function getIndex() * * @return bool */ - public function hasIndex() + public function hasIndex(): bool { return is_string($this->index) || $this->index >= 0; } @@ -365,7 +365,7 @@ public function setDelimiter(string $delimiter): void * * @return string A non-empty string with at least 256 characters. */ - public function getDelimiter() + public function getDelimiter(): string { return $this->delimiter; } @@ -393,7 +393,7 @@ public function setField(string $field): void * * @return string A string with at most 256 characters. */ - public function getField() + public function getField(): string { return $this->field; } @@ -403,7 +403,7 @@ public function getField() * * @return bool */ - public function hasField() + public function hasField(): bool { $field = $this->getField(); @@ -433,7 +433,7 @@ public function setMappingIndicator(string $mappingIndicator): void * * @return string A non-empty string with at most 256 characters. */ - public function getMappingIndicator() + public function getMappingIndicator(): string { return $this->mappingIndicator; } @@ -441,7 +441,7 @@ public function getMappingIndicator() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -449,7 +449,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'printedVariable'; } diff --git a/src/qtism/data/content/RubricBlock.php b/src/qtism/data/content/RubricBlock.php index dbfaf660a..ab9c0a675 100644 --- a/src/qtism/data/content/RubricBlock.php +++ b/src/qtism/data/content/RubricBlock.php @@ -95,7 +95,7 @@ public function __construct(ViewCollection $views, $id = '', $class = '', $lang * * @return ViewCollection A collection of values that belong to the View enumeration. */ - public function getViews() + public function getViews(): ViewCollection { return $this->views; } @@ -106,7 +106,7 @@ public function getViews() * @param ViewCollection $views A collection of values that belong to the View enumeration. * @throws InvalidArgumentException If $views is an empty collection. */ - public function setViews(ViewCollection $views) + public function setViews(ViewCollection $views): void { if (count($views) > 0) { $this->views = $views; @@ -122,7 +122,7 @@ public function setViews(ViewCollection $views) * * @return string The use or an empty string (''). */ - public function getUse() + public function getUse(): string { return $this->use; } @@ -134,7 +134,7 @@ public function getUse() * @param string $use A use. * @throws InvalidArgumentException If $use is not a string. */ - public function setUse($use) + public function setUse($use): void { if (is_string($use)) { $this->use = $use; @@ -149,7 +149,7 @@ public function setUse($use) * * @return StylesheetCollection A collection of stylesheet references. */ - public function getStylesheets() + public function getStylesheets(): StylesheetCollection { return $this->stylesheets; } @@ -159,7 +159,7 @@ public function getStylesheets() * * @param StylesheetCollection $stylesheets A collection of stylesheet references. */ - public function setStylesheets(StylesheetCollection $stylesheets) + public function setStylesheets(StylesheetCollection $stylesheets): void { $this->stylesheets = $stylesheets; } @@ -167,7 +167,7 @@ public function setStylesheets(StylesheetCollection $stylesheets) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'rubricBlock'; } @@ -175,7 +175,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $components = $this->getContent(); @@ -187,7 +187,7 @@ public function getComponents() * * @param FlowStaticCollection $content A collection of FlowStatic objects. */ - public function setContent(FlowStaticCollection $content) + public function setContent(FlowStaticCollection $content): void { $this->content = $content; } @@ -197,7 +197,7 @@ public function setContent(FlowStaticCollection $content) * * @return FlowStaticCollection */ - public function getContent() + public function getContent(): FlowStaticCollection { return $this->content; } diff --git a/src/qtism/data/content/RubricBlockCollection.php b/src/qtism/data/content/RubricBlockCollection.php index 3ef3ef3b3..2a8d2a606 100644 --- a/src/qtism/data/content/RubricBlockCollection.php +++ b/src/qtism/data/content/RubricBlockCollection.php @@ -37,7 +37,7 @@ class RubricBlockCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a RubricBlock object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof RubricBlock) { $msg = "RubricBlockCollection class only accept RubricBlock objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/content/RubricBlockRef.php b/src/qtism/data/content/RubricBlockRef.php index 1b3abb1f8..62e1de681 100644 --- a/src/qtism/data/content/RubricBlockRef.php +++ b/src/qtism/data/content/RubricBlockRef.php @@ -77,7 +77,7 @@ public function __construct($identifier, $href) * @param string $identifier A QTI identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false) === true) { $this->identifier = $identifier; @@ -92,7 +92,7 @@ public function setIdentifier($identifier) * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -103,7 +103,7 @@ public function getIdentifier() * @param string $href A URI. * @throws InvalidArgumentException If $href is not a valid URI. */ - public function setHref($href) + public function setHref($href): void { if (Format::isUri($href) === true) { $this->href = $href; @@ -118,7 +118,7 @@ public function setHref($href) * * @return string A URI. */ - public function getHref() + public function getHref(): string { return $this->href; } @@ -126,7 +126,7 @@ public function getHref() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -134,7 +134,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'rubricBlockRef'; } diff --git a/src/qtism/data/content/RubricBlockRefCollection.php b/src/qtism/data/content/RubricBlockRefCollection.php index 969b27868..5434389b0 100644 --- a/src/qtism/data/content/RubricBlockRefCollection.php +++ b/src/qtism/data/content/RubricBlockRefCollection.php @@ -38,7 +38,7 @@ class RubricBlockRefCollection extends QtiIdentifiableCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of RubricBlockRef. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof RubricBlockRef) { $msg = 'A RubricBlockRefCollection object only accepts to store RubricBlockRef objects.'; diff --git a/src/qtism/data/content/SimpleBlock.php b/src/qtism/data/content/SimpleBlock.php index 382b98591..a0c062f7b 100644 --- a/src/qtism/data/content/SimpleBlock.php +++ b/src/qtism/data/content/SimpleBlock.php @@ -57,7 +57,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @return BlockCollection A collection of Block objects. */ - public function getComponents() + public function getComponents(): BlockCollection { return $this->getContent(); } @@ -67,7 +67,7 @@ public function getComponents() * * @param BlockCollection $content A collection of Block objects. */ - public function setContent(BlockCollection $content) + public function setContent(BlockCollection $content): void { $this->content = $content; } @@ -77,7 +77,7 @@ public function setContent(BlockCollection $content) * * @return BlockCollection */ - public function getContent() + public function getContent(): BlockCollection { return $this->content; } diff --git a/src/qtism/data/content/SimpleInline.php b/src/qtism/data/content/SimpleInline.php index baf6b0514..ebed96afe 100644 --- a/src/qtism/data/content/SimpleInline.php +++ b/src/qtism/data/content/SimpleInline.php @@ -61,7 +61,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @return InlineCollection A collection of Inline components. */ - public function getComponents() + public function getComponents(): InlineCollection { return $this->getContent(); } @@ -71,7 +71,7 @@ public function getComponents() * * @param InlineCollection $content A collection of Inline components. */ - public function setContent(InlineCollection $content) + public function setContent(InlineCollection $content): void { $this->content = $content; } @@ -81,7 +81,7 @@ public function setContent(InlineCollection $content) * * @return InlineCollection */ - public function getContent() + public function getContent(): InlineCollection { return $this->content; } diff --git a/src/qtism/data/content/Stylesheet.php b/src/qtism/data/content/Stylesheet.php index 739a31604..24a574e70 100644 --- a/src/qtism/data/content/Stylesheet.php +++ b/src/qtism/data/content/Stylesheet.php @@ -95,7 +95,7 @@ public function __construct($href, $type = 'text/css', $media = 'screen', $title * * @return string */ - public function getHref() + public function getHref(): string { return $this->href; } @@ -106,7 +106,7 @@ public function getHref() * @param string $href An hypertext reference (as a URI). * @throws InvalidArgumentException If $href is not a string. */ - public function setHref($href) + public function setHref($href): void { if (is_string($href)) { $this->href = $href; @@ -121,7 +121,7 @@ public function setHref($href) * * @return string A mime-type. */ - public function getType() + public function getType(): string { return $this->type; } @@ -132,7 +132,7 @@ public function getType() * @param string $type A mime-type. * @throws InvalidArgumentException If $type is not a string. */ - public function setType($type) + public function setType($type): void { if (is_string($type)) { $this->type = $type; @@ -147,7 +147,7 @@ public function setType($type) * * @return string A media. */ - public function getMedia() + public function getMedia(): string { return $this->media; } @@ -158,7 +158,7 @@ public function getMedia() * @param string $media A media. * @throws InvalidArgumentException If $media is not a string. */ - public function setMedia($media) + public function setMedia($media): void { if (is_string($media)) { $this->media = $media; @@ -173,7 +173,7 @@ public function setMedia($media) * * @return bool */ - public function hasMedia() + public function hasMedia(): bool { return $this->getMedia() !== ''; } @@ -183,7 +183,7 @@ public function hasMedia() * * @return string A title or an empty string if not specified. */ - public function getTitle() + public function getTitle(): string { return $this->title; } @@ -194,7 +194,7 @@ public function getTitle() * @param string $title A title. * @throws InvalidArgumentException If $title is not a string. */ - public function setTitle($title) + public function setTitle($title): void { if (is_string($title)) { $this->title = $title; @@ -209,7 +209,7 @@ public function setTitle($title) * * @return bool */ - public function hasTitle() + public function hasTitle(): bool { return $this->getTitle() !== ''; } @@ -217,7 +217,7 @@ public function hasTitle() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'stylesheet'; } @@ -225,7 +225,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/content/StylesheetCollection.php b/src/qtism/data/content/StylesheetCollection.php index d93c349d5..35a1e9d88 100644 --- a/src/qtism/data/content/StylesheetCollection.php +++ b/src/qtism/data/content/StylesheetCollection.php @@ -37,7 +37,7 @@ class StylesheetCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a Stylesheet object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Stylesheet) { $msg = "StylesheetCollection class only accept Stylesheet objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/content/TemplateBlock.php b/src/qtism/data/content/TemplateBlock.php index cc39a307a..308695edf 100644 --- a/src/qtism/data/content/TemplateBlock.php +++ b/src/qtism/data/content/TemplateBlock.php @@ -65,7 +65,7 @@ public function __construct($identifier, $templateIdentifier, $id = '', $class = * * @param FlowStaticCollection $content A collection of BlockStatic objects. */ - public function setContent(FlowStaticCollection $content) + public function setContent(FlowStaticCollection $content): void { $this->content = $content; } @@ -75,7 +75,7 @@ public function setContent(FlowStaticCollection $content) * * @return FlowStaticCollection A collection of BlockStatic objects. */ - public function getContent() + public function getContent(): FlowStaticCollection { return $this->content; } @@ -83,7 +83,7 @@ public function getContent() /** * @return FlowStaticCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -91,7 +91,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'templateBlock'; } diff --git a/src/qtism/data/content/TemplateElement.php b/src/qtism/data/content/TemplateElement.php index fd9c05110..16a076d88 100644 --- a/src/qtism/data/content/TemplateElement.php +++ b/src/qtism/data/content/TemplateElement.php @@ -84,7 +84,7 @@ public function __construct($templateIdentifier, $identifier, $id = '', $class = * @param string $templateIdentifier A QTI identifier. * @throws InvalidArgumentException If $templateIdentifier is not a valid QTI identifier. */ - public function setTemplateIdentifier($templateIdentifier) + public function setTemplateIdentifier($templateIdentifier): void { if (Format::isIdentifier($templateIdentifier, false) === true) { $this->templateIdentifier = $templateIdentifier; @@ -99,7 +99,7 @@ public function setTemplateIdentifier($templateIdentifier) * * @return string A QTI identifier. */ - public function getTemplateIdentifier() + public function getTemplateIdentifier(): string { return $this->templateIdentifier; } @@ -110,7 +110,7 @@ public function getTemplateIdentifier() * @param int $showHide A value from the ShowHide enumeration. * @throws InvalidArgumentException If $showHide is not a value from the ShowHide enumeration. */ - public function setShowHide($showHide) + public function setShowHide($showHide): void { if (in_array($showHide, ShowHide::asArray(), true)) { $this->showHide = $showHide; @@ -125,7 +125,7 @@ public function setShowHide($showHide) * * @return int A value from the ShowHide enumeration. */ - public function getShowHide() + public function getShowHide(): int { return $this->showHide; } @@ -135,7 +135,7 @@ public function getShowHide() * * @return bool */ - public function mustShow() + public function mustShow(): bool { return $this->showHide === ShowHide::SHOW; } @@ -145,7 +145,7 @@ public function mustShow() * * @return bool */ - public function mustHide() + public function mustHide(): bool { return $this->showHide === ShowHide::HIDE; } @@ -156,7 +156,7 @@ public function mustHide() * @param string $identifier A QTI identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false) === true) { $this->identifier = $identifier; @@ -169,7 +169,7 @@ public function setIdentifier($identifier) /** * @return string */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } diff --git a/src/qtism/data/content/TemplateInline.php b/src/qtism/data/content/TemplateInline.php index 6be6fdcc0..2a4ece5a0 100644 --- a/src/qtism/data/content/TemplateInline.php +++ b/src/qtism/data/content/TemplateInline.php @@ -72,7 +72,7 @@ public function __construct($templateIdentifier, $identifier, $id = '', $class = * * @param InlineStaticCollection $content A collection of InlineStatic objects. */ - public function setContent(InlineStaticCollection $content) + public function setContent(InlineStaticCollection $content): void { $this->content = $content; } @@ -82,7 +82,7 @@ public function setContent(InlineStaticCollection $content) * * @return InlineStaticCollection A collection of InlineStatic objects. */ - public function getContent() + public function getContent(): InlineStaticCollection { return $this->content; } @@ -93,7 +93,7 @@ public function getContent() * @param string $xmlBase A URI. * @throws InvalidArgumentException if $base is not a valid URI nor an empty string. */ - public function setXmlBase($xmlBase = '') + public function setXmlBase($xmlBase = ''): void { if (is_string($xmlBase) && (empty($xmlBase) || Format::isUri($xmlBase))) { $this->xmlBase = $xmlBase; @@ -108,7 +108,7 @@ public function setXmlBase($xmlBase = '') * * @return string An empty string or a URI. */ - public function getXmlBase() + public function getXmlBase(): string { return $this->xmlBase; } @@ -116,7 +116,7 @@ public function getXmlBase() /** * @return bool */ - public function hasXmlBase() + public function hasXmlBase(): bool { return $this->getXmlBase() !== ''; } @@ -124,7 +124,7 @@ public function hasXmlBase() /** * @return InlineStaticCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -132,7 +132,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'templateInline'; } diff --git a/src/qtism/data/content/TextOrVariableCollection.php b/src/qtism/data/content/TextOrVariableCollection.php index 6b37d7f73..bef3ba5ed 100644 --- a/src/qtism/data/content/TextOrVariableCollection.php +++ b/src/qtism/data/content/TextOrVariableCollection.php @@ -37,7 +37,7 @@ class TextOrVariableCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of TextOrVariable. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof TextOrVariable) { $msg = 'TextOrVariableCollection objects only accept to store TextOrVariable objects.'; diff --git a/src/qtism/data/content/TextRun.php b/src/qtism/data/content/TextRun.php index e41cd6228..946050b15 100644 --- a/src/qtism/data/content/TextRun.php +++ b/src/qtism/data/content/TextRun.php @@ -60,7 +60,7 @@ public function __construct($content) * * @param string $content A string value. */ - public function setContent($content) + public function setContent($content): void { $this->content = $content; } @@ -70,7 +70,7 @@ public function setContent($content) * * @return string A string value. */ - public function getContent() + public function getContent(): string { return $this->content; } @@ -78,7 +78,7 @@ public function getContent() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -86,7 +86,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'textRun'; } diff --git a/src/qtism/data/content/enums/AriaLive.php b/src/qtism/data/content/enums/AriaLive.php index 06bd421af..7ffafe904 100644 --- a/src/qtism/data/content/enums/AriaLive.php +++ b/src/qtism/data/content/enums/AriaLive.php @@ -35,17 +35,17 @@ class AriaLive implements Enumeration /** * @var int */ - const OFF = 0; + public const OFF = 0; /** * @var int */ - const POLITE = 1; + public const POLITE = 1; /** * @var int */ - const ASSERTIVE = 2; + public const ASSERTIVE = 2; /** * As Array @@ -55,7 +55,7 @@ class AriaLive implements Enumeration * * @return int[] */ - public static function asArray() + public static function asArray(): array { return [ 'OFF' => self::OFF, diff --git a/src/qtism/data/content/enums/AriaOrientation.php b/src/qtism/data/content/enums/AriaOrientation.php index 43f51f807..bc2feda18 100644 --- a/src/qtism/data/content/enums/AriaOrientation.php +++ b/src/qtism/data/content/enums/AriaOrientation.php @@ -35,12 +35,12 @@ class AriaOrientation implements Enumeration /** * @var int */ - const HORIZONTAL = 0; + public const HORIZONTAL = 0; /** * @var int */ - const VERTICAL = 1; + public const VERTICAL = 1; /** * As Array @@ -50,7 +50,7 @@ class AriaOrientation implements Enumeration * * @return int[] */ - public static function asArray() + public static function asArray(): array { return [ 'HORIZONTAL' => self::HORIZONTAL, diff --git a/src/qtism/data/content/interactions/AssociableChoice.php b/src/qtism/data/content/interactions/AssociableChoice.php index 3d209e14a..1969b443a 100644 --- a/src/qtism/data/content/interactions/AssociableChoice.php +++ b/src/qtism/data/content/interactions/AssociableChoice.php @@ -41,7 +41,7 @@ interface AssociableChoice * * @return IdentifierCollection */ - public function getMatchGroup(); + public function getMatchGroup(): IdentifierCollection; /** * Set the set of choices that this choice may be associated with. diff --git a/src/qtism/data/content/interactions/AssociableHotspot.php b/src/qtism/data/content/interactions/AssociableHotspot.php index 79476d7a4..6fcae9c5a 100644 --- a/src/qtism/data/content/interactions/AssociableHotspot.php +++ b/src/qtism/data/content/interactions/AssociableHotspot.php @@ -64,7 +64,7 @@ class AssociableHotspot extends Choice implements AssociableChoice, Hotspot * * The shape of the hotspot. * - * @var QtiShape + * @var int * @qtism-bean-property */ private $shape; @@ -132,7 +132,7 @@ public function __construct($identifier, $matchMax, $shape, QtiCoords $coords, $ * @param int $matchMax A positive (>= 0) integer. * @throws InvalidArgumentException If $matchMax is not a positive integer. */ - public function setMatchMax($matchMax) + public function setMatchMax($matchMax): void { if (is_int($matchMax) && $matchMax >= 0) { $this->matchMax = $matchMax; @@ -147,7 +147,7 @@ public function setMatchMax($matchMax) * * @return int A positive integer. */ - public function getMatchMax() + public function getMatchMax(): int { return $this->matchMax; } @@ -158,7 +158,7 @@ public function getMatchMax() * @param int $matchMin A positive (>= 0) integer. * @throws InvalidArgumentException If $matchMin is not a positive integer. */ - public function setMatchMin($matchMin) + public function setMatchMin($matchMin): void { if (is_int($matchMin) && $matchMin >= 0) { $this->matchMin = $matchMin; @@ -173,7 +173,7 @@ public function setMatchMin($matchMin) * * @return int */ - public function getMatchMin() + public function getMatchMin(): int { return $this->matchMin; } @@ -183,7 +183,7 @@ public function getMatchMin() * * @param int $shape A value from the Shape enumeration. */ - public function setShape($shape) + public function setShape($shape): void { if (in_array($shape, QtiShape::asArray(), true)) { $this->shape = $shape; @@ -194,11 +194,9 @@ public function setShape($shape) } /** - * Get the shape of the associableHotspot. - * - * @return QtiShape A Shape object. + * @inheritDoc */ - public function getShape() + public function getShape(): int { return $this->shape; } @@ -208,7 +206,7 @@ public function getShape() * * @param QtiCoords $coords A Coords object. */ - public function setCoords(QtiCoords $coords) + public function setCoords(QtiCoords $coords): void { $this->coords = $coords; } @@ -218,7 +216,7 @@ public function setCoords(QtiCoords $coords) * * @return QtiCoords A Coords object. */ - public function getCoords() + public function getCoords(): QtiCoords { return $this->coords; } @@ -229,7 +227,7 @@ public function getCoords() * @param string $hotspotLabel A string with at most 256 characters. * @throws InvalidArgumentException If $hotspotLabel has more than 256 characters. */ - public function setHotspotLabel($hotspotLabel) + public function setHotspotLabel($hotspotLabel): void { if (Format::isString256($hotspotLabel) === true) { $this->hotspotLabel = $hotspotLabel; @@ -244,7 +242,7 @@ public function setHotspotLabel($hotspotLabel) * * @return string A string with at most 256 characters. */ - public function getHotspotLabel() + public function getHotspotLabel(): string { return $this->hotspotLabel; } @@ -254,7 +252,7 @@ public function getHotspotLabel() * * @return bool */ - public function hasHotspotLabel() + public function hasHotspotLabel(): bool { return $this->getHotspotLabel() !== ''; } @@ -262,7 +260,7 @@ public function hasHotspotLabel() /** * @param IdentifierCollection $matchGroup */ - public function setMatchGroup(IdentifierCollection $matchGroup) + public function setMatchGroup(IdentifierCollection $matchGroup): void { $this->matchGroup = $matchGroup; } @@ -270,7 +268,7 @@ public function setMatchGroup(IdentifierCollection $matchGroup) /** * @return IdentifierCollection */ - public function getMatchGroup() + public function getMatchGroup(): IdentifierCollection { return $this->matchGroup; } @@ -278,7 +276,7 @@ public function getMatchGroup() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -286,7 +284,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'associableHotspot'; } diff --git a/src/qtism/data/content/interactions/AssociableHotspotCollection.php b/src/qtism/data/content/interactions/AssociableHotspotCollection.php index dd7a143d8..e749bd94a 100644 --- a/src/qtism/data/content/interactions/AssociableHotspotCollection.php +++ b/src/qtism/data/content/interactions/AssociableHotspotCollection.php @@ -38,7 +38,7 @@ class AssociableHotspotCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of AssociableHotspot. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof AssociableHotspot) { $msg = 'AssociableHotspotCollection objects only accepts to store AssociableHotspot objects.'; diff --git a/src/qtism/data/content/interactions/AssociateInteraction.php b/src/qtism/data/content/interactions/AssociateInteraction.php index f25e1592d..9817fa70c 100644 --- a/src/qtism/data/content/interactions/AssociateInteraction.php +++ b/src/qtism/data/content/interactions/AssociateInteraction.php @@ -112,7 +112,7 @@ public function __construct($responseIdentifier, SimpleAssociableChoiceCollectio * @param bool $shuffle * @throws InvalidArgumentException If $shuffle is not a boolean value. */ - public function setShuffle($shuffle) + public function setShuffle($shuffle): void { if (is_bool($shuffle)) { $this->shuffle = $shuffle; @@ -128,7 +128,7 @@ public function setShuffle($shuffle) * * @return bool */ - public function mustShuffle() + public function mustShuffle(): bool { return $this->shuffle; } @@ -140,7 +140,7 @@ public function mustShuffle() * @param int $maxAssociations A positive (>= 0) integer. * @throws InvalidArgumentException If $maxAssociations is not a positive integer. */ - public function setMaxAssociations($maxAssociations) + public function setMaxAssociations($maxAssociations): void { if (is_int($maxAssociations) && $maxAssociations >= 0) { $this->maxAssociations = $maxAssociations; @@ -156,7 +156,7 @@ public function setMaxAssociations($maxAssociations) * * @return int A positive (>= 0) integer. */ - public function getMaxAssociations() + public function getMaxAssociations(): int { return $this->maxAssociations; } @@ -166,7 +166,7 @@ public function getMaxAssociations() * * @return bool */ - public function hasMaxAssociations() + public function hasMaxAssociations(): bool { return $this->maxAssociations > 0; } @@ -178,7 +178,7 @@ public function hasMaxAssociations() * @param int $minAssociations A positive (>= 0) integer. * @throws InvalidArgumentException If $minAssociations is not a positive integer or if $minAssociations is not less than or equal to the limit imposed by 'maxAssociations'. */ - public function setMinAssociations($minAssociations) + public function setMinAssociations($minAssociations): void { if (is_int($minAssociations) && $minAssociations >= 0) { if ($this->hasMaxAssociations() === true && $minAssociations > $this->getMaxAssociations()) { @@ -199,7 +199,7 @@ public function setMinAssociations($minAssociations) * * @return int A positive (>= 0) integer. */ - public function getMinAssociations() + public function getMinAssociations(): int { return $this->minAssociations; } @@ -209,7 +209,7 @@ public function getMinAssociations() * * @return bool */ - public function hasMinAssociations() + public function hasMinAssociations(): bool { return $this->getMinAssociations() > 0; } @@ -220,7 +220,7 @@ public function hasMinAssociations() * @param SimpleAssociableChoiceCollection $simpleAssociableChoices A collection of at least one SimpleAssociableChoice object. * @throws InvalidArgumentException If $simpleAssociableChoices is empty. */ - public function setSimpleAssociableChoices(SimpleAssociableChoiceCollection $simpleAssociableChoices) + public function setSimpleAssociableChoices(SimpleAssociableChoiceCollection $simpleAssociableChoices): void { if (count($simpleAssociableChoices) > 0) { $this->simpleAssociableChoices = $simpleAssociableChoices; @@ -235,7 +235,7 @@ public function setSimpleAssociableChoices(SimpleAssociableChoiceCollection $sim * * @return SimpleAssociableChoiceCollection A collection of at least one SimpleAssociableChoice. */ - public function getSimpleAssociableChoices() + public function getSimpleAssociableChoices(): SimpleAssociableChoiceCollection { return $this->simpleAssociableChoices; } @@ -243,7 +243,7 @@ public function getSimpleAssociableChoices() /** * @return ResponseValidityConstraint */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ResponseValidityConstraint { $responseValidityConstraint = new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -268,7 +268,7 @@ public function getResponseValidityConstraint() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $parentComponents = parent::getComponents(); @@ -278,7 +278,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'associateInteraction'; } diff --git a/src/qtism/data/content/interactions/BlockInteraction.php b/src/qtism/data/content/interactions/BlockInteraction.php index b186b9e56..797b09624 100644 --- a/src/qtism/data/content/interactions/BlockInteraction.php +++ b/src/qtism/data/content/interactions/BlockInteraction.php @@ -67,9 +67,9 @@ public function __construct($responseIdentifier, $id = '', $class = '', $lang = /** * Get the prompt for the interaction. * - * @return Prompt + * @return Prompt|null */ - public function getPrompt() + public function getPrompt(): ?Prompt { return $this->prompt; } @@ -79,7 +79,7 @@ public function getPrompt() * * @param Prompt $prompt */ - public function setPrompt($prompt = null) + public function setPrompt($prompt = null): void { $this->prompt = $prompt; } @@ -89,7 +89,7 @@ public function setPrompt($prompt = null) * * @return bool */ - public function hasPrompt() + public function hasPrompt(): bool { return $this->getPrompt() !== null; } @@ -97,7 +97,7 @@ public function hasPrompt() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $array = []; if ($this->hasPrompt() === true) { diff --git a/src/qtism/data/content/interactions/Choice.php b/src/qtism/data/content/interactions/Choice.php index 870bc1bb0..9f8185280 100644 --- a/src/qtism/data/content/interactions/Choice.php +++ b/src/qtism/data/content/interactions/Choice.php @@ -118,7 +118,7 @@ public function __construct($identifier, $id = '', $class = '', $lang = '', $lab * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -129,7 +129,7 @@ public function getIdentifier() * @param string $identifier A QTI identifier. * @throws InvalidArgumentException If the given $identifier is not valid. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false) === true) { $this->identifier = $identifier; @@ -145,7 +145,7 @@ public function setIdentifier($identifier) * @param bool $fixed * @throws InvalidArgumentException If $fixed is not a boolean value. */ - public function setFixed($fixed) + public function setFixed($fixed): void { if (is_bool($fixed)) { $this->fixed = $fixed; @@ -160,7 +160,7 @@ public function setFixed($fixed) * * @return bool */ - public function isFixed() + public function isFixed(): bool { return $this->fixed; } @@ -171,9 +171,9 @@ public function isFixed() * @param string $templateIdentifier An empty string if no identifier is provided or a QTI identifier. * @throws InvalidArgumentException If the given $templateIdentifier is not a valid QTI identifier. */ - public function setTemplateIdentifier($templateIdentifier) + public function setTemplateIdentifier($templateIdentifier): void { - if (is_string($templateIdentifier) && (empty($templateIdentifier)) || Format::isIdentifier($templateIdentifier, false) === true) { + if (is_string($templateIdentifier) && (empty($templateIdentifier)) || Format::isIdentifier((string)$templateIdentifier, false) === true) { $this->templateIdentifier = $templateIdentifier; } else { $msg = "The 'templateIdentifier' must be an empty string or a valid QTI identifier, '" . gettype($templateIdentifier) . "' given."; @@ -186,7 +186,7 @@ public function setTemplateIdentifier($templateIdentifier) * * @return string A QTI identifier or an empty string if no identifier provided. */ - public function getTemplateIdentifier() + public function getTemplateIdentifier(): string { return $this->templateIdentifier; } @@ -196,7 +196,7 @@ public function getTemplateIdentifier() * * @return bool */ - public function hasTemplateIdentifier() + public function hasTemplateIdentifier(): bool { return $this->getTemplateIdentifier() !== ''; } @@ -207,7 +207,7 @@ public function hasTemplateIdentifier() * @param int $showHide A value from the ShowHide enumeration. * @throws InvalidArgumentException If $showHide is not a value from the ShowHide enumeration. */ - public function setShowHide($showHide) + public function setShowHide($showHide): void { if (in_array($showHide, ShowHide::asArray())) { $this->showHide = $showHide; @@ -222,7 +222,7 @@ public function setShowHide($showHide) * * @return int A value from the ShowHide enumeration. */ - public function getShowHide() + public function getShowHide(): int { return $this->showHide; } diff --git a/src/qtism/data/content/interactions/ChoiceInteraction.php b/src/qtism/data/content/interactions/ChoiceInteraction.php index 9e6f07b8d..37fc833d8 100644 --- a/src/qtism/data/content/interactions/ChoiceInteraction.php +++ b/src/qtism/data/content/interactions/ChoiceInteraction.php @@ -122,7 +122,7 @@ public function __construct($responseIdentifier, SimpleChoiceCollection $simpleC * @param SimpleChoiceCollection $simpleChoices A collection of SimpleChoice objects. * @throws InvalidArgumentException If $simpleChoices is empty. */ - public function setSimpleChoices(SimpleChoiceCollection $simpleChoices) + public function setSimpleChoices(SimpleChoiceCollection $simpleChoices): void { if (count($simpleChoices) > 0) { $this->simpleChoices = $simpleChoices; @@ -137,7 +137,7 @@ public function setSimpleChoices(SimpleChoiceCollection $simpleChoices) * * @return SimpleChoiceCollection A collection of at least one SimpleChoice object. */ - public function getSimpleChoices() + public function getSimpleChoices(): SimpleChoiceCollection { return $this->simpleChoices; } @@ -149,7 +149,7 @@ public function getSimpleChoices() * @param bool $shuffle * @throws InvalidArgumentException If $shuffle is not a boolean value. */ - public function setShuffle($shuffle) + public function setShuffle($shuffle): void { if (is_bool($shuffle)) { $this->shuffle = $shuffle; @@ -165,7 +165,7 @@ public function setShuffle($shuffle) * * @return bool */ - public function mustShuffle() + public function mustShuffle(): bool { return $this->shuffle; } @@ -176,7 +176,7 @@ public function mustShuffle() * @param int $maxChoices A positive (>= 0) integer. * @throws InvalidArgumentException If $maxChoices is not a positive integer. */ - public function setMaxChoices($maxChoices) + public function setMaxChoices($maxChoices): void { if (is_int($maxChoices) && $maxChoices >= 0) { $this->maxChoices = $maxChoices; @@ -191,7 +191,7 @@ public function setMaxChoices($maxChoices) * * @return int A strictly positive (> 0) integer. */ - public function getMaxChoices() + public function getMaxChoices(): int { return $this->maxChoices; } @@ -204,7 +204,7 @@ public function getMaxChoices() * @param int $minChoices A positive (>= 0) integer. * @throws InvalidArgumentException If $minChoices is not a positive (>= 0) integer. */ - public function setMinChoices($minChoices) + public function setMinChoices($minChoices): void { if (is_int($minChoices) && $minChoices >= 0) { $this->minChoices = $minChoices; @@ -219,7 +219,7 @@ public function setMinChoices($minChoices) * * @return int A positive (> 0) integer. */ - public function getMinChoices() + public function getMinChoices(): int { return $this->minChoices; } @@ -230,7 +230,7 @@ public function getMinChoices() * @param int $orientation A value from the Orientation enumeration. * @throws InvalidArgumentException If $orientation is not a value from the Orientation enumeration. */ - public function setOrientation($orientation) + public function setOrientation($orientation): void { if (in_array($orientation, Orientation::asArray(), true)) { $this->orientation = $orientation; @@ -245,7 +245,7 @@ public function setOrientation($orientation) * * @return int A value from the Orientation enumeration. */ - public function getOrientation() + public function getOrientation(): int { return $this->orientation; } @@ -253,7 +253,7 @@ public function getOrientation() /** * @return ResponseValidityConstraint */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ResponseValidityConstraint { return new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -265,7 +265,7 @@ public function getResponseValidityConstraint() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'choiceInteraction'; } @@ -273,7 +273,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $parentComponents = parent::getComponents(); diff --git a/src/qtism/data/content/interactions/CustomInteraction.php b/src/qtism/data/content/interactions/CustomInteraction.php index 680a6fe7f..43de3e6c1 100644 --- a/src/qtism/data/content/interactions/CustomInteraction.php +++ b/src/qtism/data/content/interactions/CustomInteraction.php @@ -78,7 +78,7 @@ public function __construct($responseIdentifier, $xmlString, $id = '', $class = /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'customInteraction'; } @@ -88,7 +88,7 @@ public function getQtiClassName() * * @return string */ - public function getXmlString() + public function getXmlString(): string { return $this->xmlString; } @@ -98,7 +98,7 @@ public function getXmlString() * * @param string $xmlString */ - public function setXmlString($xmlString) + public function setXmlString($xmlString): void { $this->xmlString = $xmlString; if ($this->externalComponent !== null) { @@ -122,7 +122,7 @@ public function getXml(): ?SerializableDomDocument * * @param ExternalQtiComponent $externalComponent */ - private function setExternalComponent(ExternalQtiComponent $externalComponent) + private function setExternalComponent(ExternalQtiComponent $externalComponent): void { $this->externalComponent = $externalComponent; } @@ -132,7 +132,7 @@ private function setExternalComponent(ExternalQtiComponent $externalComponent) * * @return ExternalQtiComponent */ - private function getExternalComponent() + private function getExternalComponent(): ExternalQtiComponent { return $this->externalComponent; } @@ -140,7 +140,7 @@ private function getExternalComponent() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/content/interactions/DrawingInteraction.php b/src/qtism/data/content/interactions/DrawingInteraction.php index 8186f324b..bc1c6c5c3 100644 --- a/src/qtism/data/content/interactions/DrawingInteraction.php +++ b/src/qtism/data/content/interactions/DrawingInteraction.php @@ -71,7 +71,7 @@ public function __construct($responseIdentifier, ObjectElement $object, $id = '' * * @param ObjectElement $object An ObjectElement object representing an image. */ - public function setObject(ObjectElement $object) + public function setObject(ObjectElement $object): void { $this->object = $object; } @@ -81,7 +81,7 @@ public function setObject(ObjectElement $object) * * @return ObjectElement An ObjectElement object representing an image. */ - public function getObject() + public function getObject(): ObjectElement { return $this->object; } @@ -89,7 +89,7 @@ public function getObject() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $parentComponents = parent::getComponents(); @@ -99,7 +99,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'drawingInteraction'; } diff --git a/src/qtism/data/content/interactions/EndAttemptInteraction.php b/src/qtism/data/content/interactions/EndAttemptInteraction.php index 48d7f8862..77d819bc9 100644 --- a/src/qtism/data/content/interactions/EndAttemptInteraction.php +++ b/src/qtism/data/content/interactions/EndAttemptInteraction.php @@ -81,7 +81,7 @@ public function __construct($responseIdentifier, $title, $id = '', $class = '', * @param string $title A string. * @throws InvalidArgumentException If $title is not a string. */ - public function setTitle($title) + public function setTitle($title): void { if (is_string($title)) { $this->title = $title; @@ -97,7 +97,7 @@ public function setTitle($title) * * @return string A non-empty string. */ - public function getTitle() + public function getTitle(): string { return $this->title; } @@ -105,7 +105,7 @@ public function getTitle() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -113,7 +113,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'endAttemptInteraction'; } diff --git a/src/qtism/data/content/interactions/ExtendedTextInteraction.php b/src/qtism/data/content/interactions/ExtendedTextInteraction.php index 43199dbf3..8a0446ecb 100644 --- a/src/qtism/data/content/interactions/ExtendedTextInteraction.php +++ b/src/qtism/data/content/interactions/ExtendedTextInteraction.php @@ -184,7 +184,7 @@ public function __construct($responseIdentifier, $id = '', $class = '', $lang = * @param int $base A positive (>= 0) integer. * @throws InvalidArgumentException If $base is not a positive integer. */ - public function setBase($base) + public function setBase($base): void { if (is_int($base) && $base >= 0) { $this->base = $base; @@ -200,7 +200,7 @@ public function setBase($base) * * @return int A positive (>= 0) integer. */ - public function getBase() + public function getBase(): int { return $this->base; } @@ -213,7 +213,7 @@ public function getBase() * @param string $stringIdentifier A QTI Identifier or an empty string. * @throws InvalidArgumentException If $stringIdentifier is not a valid QTIIdentifier nor an empty string. */ - public function setStringIdentifier($stringIdentifier) + public function setStringIdentifier($stringIdentifier): void { if (Format::isIdentifier($stringIdentifier, false) === true || (is_string($stringIdentifier) && empty($stringIdentifier))) { $this->stringIdentifier = $stringIdentifier; @@ -230,7 +230,7 @@ public function setStringIdentifier($stringIdentifier) * * @return string A QTI identifier or an empty string. */ - public function getStringIdentifier() + public function getStringIdentifier(): string { return $this->stringIdentifier; } @@ -240,7 +240,7 @@ public function getStringIdentifier() * * @return bool */ - public function hasStringIdentifier() + public function hasStringIdentifier(): bool { return $this->getStringIdentifier() !== ''; } @@ -252,7 +252,7 @@ public function hasStringIdentifier() * @param int|null $expectedLength A non-negative integer (>= 0) or null to unset expectedLength. * @throws InvalidArgumentException If $expectedLength is not a non-negative integer nor null. */ - public function setExpectedLength($expectedLength) + public function setExpectedLength($expectedLength): void { if ($expectedLength !== null && (!is_int($expectedLength) || $expectedLength < 0)) { $given = is_int($expectedLength) @@ -272,9 +272,9 @@ public function setExpectedLength($expectedLength) * * @return int|null A non-negative integer (>= 0) or null if undefined. */ - public function getExpectedLength() + public function getExpectedLength(): int { - return $this->expectedLength; + return $this->expectedLength ?? -1; } /** @@ -282,9 +282,9 @@ public function getExpectedLength() * * @return bool */ - public function hasExpectedLength() + public function hasExpectedLength(): bool { - return $this->getExpectedLength() !== null; + return $this->getExpectedLength() !== null && $this->getExpectedLength() >= 0; } /** @@ -294,7 +294,7 @@ public function hasExpectedLength() * @param string $patternMask An XML Schema 2 regular expression or an empty string. * @throws InvalidArgumentException If $patternMask is not a string value. */ - public function setPatternMask($patternMask) + public function setPatternMask($patternMask): void { if (is_string($patternMask)) { $this->patternMask = $patternMask; @@ -311,7 +311,7 @@ public function setPatternMask($patternMask) * * @return string An XML Schema 2 regular expression or an empty string. */ - public function getPatternMask() + public function getPatternMask(): string { return $this->patternMask; } @@ -321,7 +321,7 @@ public function getPatternMask() * * @return bool */ - public function hasPatternMask() + public function hasPatternMask(): bool { return $this->getPatternMask() !== ''; } @@ -333,7 +333,7 @@ public function hasPatternMask() * @param string $placeholderText A placeholder text or an empty string. * @throws InvalidArgumentException If $placeholderText is not a string value. */ - public function setPlaceholderText($placeholderText) + public function setPlaceholderText($placeholderText): void { if (is_string($placeholderText)) { $this->placeholderText = $placeholderText; @@ -349,7 +349,7 @@ public function setPlaceholderText($placeholderText) * * @return string A placeholder text or an empty string. */ - public function getPlaceholderText() + public function getPlaceholderText(): string { return $this->placeholderText; } @@ -359,7 +359,7 @@ public function getPlaceholderText() * * @return bool */ - public function hasPlaceholderText() + public function hasPlaceholderText(): bool { return $this->getPlaceholderText() !== ''; } @@ -371,7 +371,7 @@ public function hasPlaceholderText() * @param int $maxStrings A strictly positive (> 0) integer or -1. * @throws InvalidArgumentException If $maxStrings is not a strictly positive integer nor -1. */ - public function setMaxStrings($maxStrings) + public function setMaxStrings($maxStrings): void { if (is_int($maxStrings) && ($maxStrings > 0 || $maxStrings === -1)) { $this->maxStrings = $maxStrings; @@ -387,7 +387,7 @@ public function setMaxStrings($maxStrings) * * @return int A strictly positive (> 0) integer or -1. */ - public function getMaxStrings() + public function getMaxStrings(): int { return $this->maxStrings; } @@ -397,7 +397,7 @@ public function getMaxStrings() * * @return bool */ - public function hasMaxStrings() + public function hasMaxStrings(): bool { return $this->getMaxStrings() !== -1; } @@ -408,7 +408,7 @@ public function hasMaxStrings() * @param string $minStrings A positive (>= 0) integer. * @throws InvalidArgumentException If $minStrings is not a positive integer. */ - public function setMinStrings($minStrings) + public function setMinStrings($minStrings): void { if (is_int($minStrings) && $minStrings >= 0) { $this->minStrings = $minStrings; @@ -423,7 +423,7 @@ public function setMinStrings($minStrings) * * @return int A positive (>= 0) integer. */ - public function getMinStrings() + public function getMinStrings(): int { return $this->minStrings; } @@ -435,7 +435,7 @@ public function getMinStrings() * @param int|null $expectedLines A non-negative integer (>= 0) or null. * @throws InvalidArgumentException If $expectedLines is not a non-negative integer nor null. */ - public function setExpectedLines($expectedLines) + public function setExpectedLines($expectedLines): void { if ($expectedLines !== null && (!is_int($expectedLines) || $expectedLines < 0)) { $given = is_int($expectedLines) @@ -455,7 +455,7 @@ public function setExpectedLines($expectedLines) * * @return int|null A non-negative integer (>= 0) or null if undefined. */ - public function getExpectedLines() + public function getExpectedLines(): ?int { return $this->expectedLines; } @@ -465,7 +465,7 @@ public function getExpectedLines() * * @return bool */ - public function hasExpectedLines() + public function hasExpectedLines(): bool { return $this->getExpectedLines() !== null; } @@ -476,7 +476,7 @@ public function hasExpectedLines() * @param int $format A value from the TextFormat enumeration. * @throws InvalidArgumentException If $format is not a value from the TextFormat enumeration. */ - public function setFormat($format) + public function setFormat($format): void { if (in_array($format, TextFormat::asArray())) { $this->format = $format; @@ -491,7 +491,7 @@ public function setFormat($format) * * @return int A value from the TextFormat enumeration. */ - public function getFormat() + public function getFormat(): int { return $this->format; } @@ -499,7 +499,7 @@ public function getFormat() /** * @return ResponseValidityConstraint */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ResponseValidityConstraint { return new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -512,7 +512,7 @@ public function getResponseValidityConstraint() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return parent::getComponents(); } @@ -520,7 +520,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'extendedTextInteraction'; } diff --git a/src/qtism/data/content/interactions/Gap.php b/src/qtism/data/content/interactions/Gap.php index f74b38ada..f87708e31 100644 --- a/src/qtism/data/content/interactions/Gap.php +++ b/src/qtism/data/content/interactions/Gap.php @@ -83,7 +83,7 @@ public function __construct($identifier, $required = false, $id = '', $class = ' * @param bool $required * @throws InvalidArgumentException If $required is not a boolean value. */ - public function setRequired($required) + public function setRequired($required): void { if (is_bool($required)) { $this->required = $required; @@ -106,7 +106,7 @@ public function isRequired() /** * @param IdentifierCollection $matchGroup */ - public function setMatchGroup(IdentifierCollection $matchGroup) + public function setMatchGroup(IdentifierCollection $matchGroup): void { $this->matchGroup = $matchGroup; } @@ -114,7 +114,7 @@ public function setMatchGroup(IdentifierCollection $matchGroup) /** * @return IdentifierCollection */ - public function getMatchGroup() + public function getMatchGroup(): IdentifierCollection { return $this->matchGroup; } @@ -122,7 +122,7 @@ public function getMatchGroup() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -130,7 +130,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'gap'; } diff --git a/src/qtism/data/content/interactions/GapChoice.php b/src/qtism/data/content/interactions/GapChoice.php index db46f5f05..6e2ba382d 100644 --- a/src/qtism/data/content/interactions/GapChoice.php +++ b/src/qtism/data/content/interactions/GapChoice.php @@ -97,7 +97,7 @@ public function __construct($identifier, $matchMax, $id = '', $class = '', $lang * @param int $matchMax A postive (>= 0) integer. * @throws InvalidArgumentException If $matchMax is not a positive integer. */ - public function setMatchMax($matchMax) + public function setMatchMax($matchMax): void { if (is_int($matchMax) && $matchMax >= 0) { $this->matchMax = $matchMax; @@ -112,7 +112,7 @@ public function setMatchMax($matchMax) * * @return int A positive (>= 0) integer. */ - public function getMatchMax() + public function getMatchMax(): int { return $this->matchMax; } @@ -123,7 +123,7 @@ public function getMatchMax() * @param int $matchMin A positive (>= 0) integer. * @throws InvalidArgumentException If $matchMin is not a positive integer. */ - public function setMatchMin($matchMin) + public function setMatchMin($matchMin): void { if (is_int($matchMin) && $matchMin >= 0) { $this->matchMin = $matchMin; @@ -138,7 +138,7 @@ public function setMatchMin($matchMin) * * @return int A positive (>= 0) integer. */ - public function getMatchMin() + public function getMatchMin(): int { return $this->matchMin; } @@ -146,7 +146,7 @@ public function getMatchMin() /** * @param IdentifierCollection $matchGroup */ - public function setMatchGroup(IdentifierCollection $matchGroup) + public function setMatchGroup(IdentifierCollection $matchGroup): void { $this->matchGroup = $matchGroup; } @@ -154,7 +154,7 @@ public function setMatchGroup(IdentifierCollection $matchGroup) /** * @return IdentifierCollection */ - public function getMatchGroup() + public function getMatchGroup(): IdentifierCollection { return $this->matchGroup; } diff --git a/src/qtism/data/content/interactions/GapChoiceCollection.php b/src/qtism/data/content/interactions/GapChoiceCollection.php index df8312264..ff84f5320 100644 --- a/src/qtism/data/content/interactions/GapChoiceCollection.php +++ b/src/qtism/data/content/interactions/GapChoiceCollection.php @@ -38,7 +38,7 @@ class GapChoiceCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of GapChoice. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof GapChoice) { $msg = 'GapChoiceCollection objects only accept to store GapChoice objects.'; diff --git a/src/qtism/data/content/interactions/GapImg.php b/src/qtism/data/content/interactions/GapImg.php index 0aa30fa82..70a096795 100644 --- a/src/qtism/data/content/interactions/GapImg.php +++ b/src/qtism/data/content/interactions/GapImg.php @@ -79,7 +79,7 @@ public function __construct($identifier, $matchMax, ObjectElement $object, $id = * @param string $objectLabel A label for the image. * @throws InvalidArgumentException If $objectLabel is not a string value. */ - public function setObjectLabel($objectLabel) + public function setObjectLabel($objectLabel): void { if (is_string($objectLabel)) { $this->objectLabel = $objectLabel; @@ -95,7 +95,7 @@ public function setObjectLabel($objectLabel) * * @return string A label for the image. */ - public function getObjectLabel() + public function getObjectLabel(): string { return $this->objectLabel; } @@ -105,7 +105,7 @@ public function getObjectLabel() * * @return bool */ - public function hasObjectLabel() + public function hasObjectLabel(): bool { return $this->getObjectLabel() !== ''; } @@ -115,7 +115,7 @@ public function hasObjectLabel() * * @param ObjectElement $object An ObjectElement object. */ - public function setObject(ObjectElement $object) + public function setObject(ObjectElement $object): void { $this->object = $object; } @@ -125,7 +125,7 @@ public function setObject(ObjectElement $object) * * @return ObjectElement An ObjectElement object. */ - public function getObject() + public function getObject(): ObjectElement { return $this->object; } @@ -133,7 +133,7 @@ public function getObject() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection([$this->getObject()]); } @@ -141,7 +141,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'gapImg'; } diff --git a/src/qtism/data/content/interactions/GapImgCollection.php b/src/qtism/data/content/interactions/GapImgCollection.php index d25dd5b8f..f6334310f 100644 --- a/src/qtism/data/content/interactions/GapImgCollection.php +++ b/src/qtism/data/content/interactions/GapImgCollection.php @@ -37,7 +37,7 @@ class GapImgCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of GapImg. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof GapImg) { $msg = 'GapImgCollection objects only accept to store GapImg objects.'; diff --git a/src/qtism/data/content/interactions/GapMatchInteraction.php b/src/qtism/data/content/interactions/GapMatchInteraction.php index bfb485650..36cffdde1 100644 --- a/src/qtism/data/content/interactions/GapMatchInteraction.php +++ b/src/qtism/data/content/interactions/GapMatchInteraction.php @@ -107,7 +107,7 @@ public function __construct($responseIdentifier, GapChoiceCollection $gapChoices * @param bool $shuffle A boolean value. * @throws InvalidArgumentException If $shuffle is not a boolean value. */ - public function setShuffle($shuffle) + public function setShuffle($shuffle): void { if (is_bool($shuffle)) { $this->shuffle = $shuffle; @@ -123,7 +123,7 @@ public function setShuffle($shuffle) * * @return bool */ - public function mustShuffle() + public function mustShuffle(): bool { return $this->shuffle; } @@ -134,7 +134,7 @@ public function mustShuffle() * @param GapChoiceCollection $gapChoices A collection of at least one GapChoice object. * @throws InvalidArgumentException If $gapChoices is empty. */ - public function setGapChoices(GapChoiceCollection $gapChoices) + public function setGapChoices(GapChoiceCollection $gapChoices): void { if (count($gapChoices) > 0) { $this->gapChoices = $gapChoices; @@ -149,7 +149,7 @@ public function setGapChoices(GapChoiceCollection $gapChoices) * * @return GapChoiceCollection A collection of at least one GapChoice object. */ - public function getGapChoices() + public function getGapChoices(): GapChoiceCollection { return $this->gapChoices; } @@ -160,7 +160,7 @@ public function getGapChoices() * @param BlockStaticCollection $content A collection of at least one BlockStatic object. * @throws InvalidArgumentException If $content is empty. */ - public function setContent(BlockStaticCollection $content) + public function setContent(BlockStaticCollection $content): void { if (count($content) > 0) { $this->content = $content; @@ -175,7 +175,7 @@ public function setContent(BlockStaticCollection $content) * * @return BlockStaticCollection A collection of at least one BlockStatic object. */ - public function getContent() + public function getContent(): BlockStaticCollection { return $this->content; } @@ -183,7 +183,7 @@ public function getContent() /** * @return ResponseValidityConstraint|null */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ?ResponseValidityConstraint { $responseValidityConstraint = new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -207,7 +207,7 @@ public function getResponseValidityConstraint() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $parentComponents = parent::getComponents(); @@ -217,7 +217,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'gapMatchInteraction'; } diff --git a/src/qtism/data/content/interactions/GapText.php b/src/qtism/data/content/interactions/GapText.php index 4b0fb01e6..d02de1708 100644 --- a/src/qtism/data/content/interactions/GapText.php +++ b/src/qtism/data/content/interactions/GapText.php @@ -65,7 +65,7 @@ public function __construct($identifier, $matchMax, $id = '', $class = '', $lang * * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -75,7 +75,7 @@ public function getComponents() * * @param QtiComponentCollection $content */ - public function setContent(QtiComponentCollection $content) + public function setContent(QtiComponentCollection $content): void { $this->content = $content; } @@ -85,7 +85,7 @@ public function setContent(QtiComponentCollection $content) * * @return QtiComponentCollection */ - public function getContent() + public function getContent(): QtiComponentCollection { return $this->content; } @@ -93,7 +93,7 @@ public function getContent() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'gapText'; } diff --git a/src/qtism/data/content/interactions/GraphicAssociateInteraction.php b/src/qtism/data/content/interactions/GraphicAssociateInteraction.php index 453b5c9f4..7f1f25a6b 100644 --- a/src/qtism/data/content/interactions/GraphicAssociateInteraction.php +++ b/src/qtism/data/content/interactions/GraphicAssociateInteraction.php @@ -106,7 +106,7 @@ public function __construct($responseIdentifier, ObjectElement $object, Associab * @param AssociableHotspotCollection $associableHotspots A collection of at least 1 AssociableHotspot object. * @throws InvalidArgumentException If $associableHotspots is empty. */ - public function setAssociableHotspots(AssociableHotspotCollection $associableHotspots) + public function setAssociableHotspots(AssociableHotspotCollection $associableHotspots): void { if (count($associableHotspots) > 0) { $this->associableHotspots = $associableHotspots; @@ -121,7 +121,7 @@ public function setAssociableHotspots(AssociableHotspotCollection $associableHot * * @return AssociableHotspotCollection A collection of AssociableHotspot objects. */ - public function getAssociableHotspots() + public function getAssociableHotspots(): AssociableHotspotCollection { return $this->associableHotspots; } @@ -133,7 +133,7 @@ public function getAssociableHotspots() * @param int $maxAssociations A positive (>= 0) integer. * @throws InvalidArgumentException If $maxAssociations is not a positive integer. */ - public function setMaxAssociations($maxAssociations) + public function setMaxAssociations($maxAssociations): void { if (is_int($maxAssociations) && $maxAssociations >= 0) { $this->maxAssociations = $maxAssociations; @@ -149,7 +149,7 @@ public function setMaxAssociations($maxAssociations) * * @return int $maxAssociations A positive (>= 0) integer. */ - public function getMaxAssociations() + public function getMaxAssociations(): int { return $this->maxAssociations; } @@ -161,7 +161,7 @@ public function getMaxAssociations() * @param int $minAssociations A positive (>= 0) integer. * @throws InvalidArgumentException If $minAssociations is not a positive integer or if $minAssociations is not less than or equal to the limit imposed by maxAssociations. */ - public function setMinAssociations($minAssociations) + public function setMinAssociations($minAssociations): void { if (is_int($minAssociations) && $minAssociations >= 0) { if ($minAssociations > $this->getMaxAssociations()) { @@ -182,7 +182,7 @@ public function setMinAssociations($minAssociations) * * @return int A positive (>= 0) integer. */ - public function getMinAssociations() + public function getMinAssociations(): int { return $this->minAssociations; } @@ -190,7 +190,7 @@ public function getMinAssociations() /** * @return ResponseValidityConstraint|null */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ?ResponseValidityConstraint { $responseValidityConstraint = new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -214,7 +214,7 @@ public function getResponseValidityConstraint() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(array_merge([$this->getObject()], $this->getAssociableHotspots()->getArrayCopy())); } @@ -222,7 +222,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'graphicAssociateInteraction'; } diff --git a/src/qtism/data/content/interactions/GraphicGapMatchInteraction.php b/src/qtism/data/content/interactions/GraphicGapMatchInteraction.php index 2b4adddca..d9b4d1cb7 100644 --- a/src/qtism/data/content/interactions/GraphicGapMatchInteraction.php +++ b/src/qtism/data/content/interactions/GraphicGapMatchInteraction.php @@ -101,7 +101,7 @@ public function __construct($responseIdentifier, ObjectElement $object, GapImgCo * @param GapImgCollection $gapImgs A collection of GapImg objects. * @throws InvalidArgumentException If $gapImgs is empty. */ - public function setGapImgs(GapImgCollection $gapImgs) + public function setGapImgs(GapImgCollection $gapImgs): void { if (count($gapImgs) > 0) { $this->gapImgs = $gapImgs; @@ -116,7 +116,7 @@ public function setGapImgs(GapImgCollection $gapImgs) * * @return GapImgCollection A collection of GapImg objects. */ - public function getGapImgs() + public function getGapImgs(): GapImgCollection { return $this->gapImgs; } @@ -127,7 +127,7 @@ public function getGapImgs() * @param AssociableHotspotCollection $associableHotspots A collection of AssociableHotspot objects. * @throws InvalidArgumentException If $associableHotspots is empty. */ - public function setAssociableHotspots(AssociableHotspotCollection $associableHotspots) + public function setAssociableHotspots(AssociableHotspotCollection $associableHotspots): void { if (count($associableHotspots) > 0) { $this->associableHotspots = $associableHotspots; @@ -142,7 +142,7 @@ public function setAssociableHotspots(AssociableHotspotCollection $associableHot * * @return AssociableHotspotCollection A collection of AssociableHotspot objects. */ - public function getAssociableHotspots() + public function getAssociableHotspots(): AssociableHotspotCollection { return $this->associableHotspots; } @@ -150,7 +150,7 @@ public function getAssociableHotspots() /** * @return ResponseValidityConstraint|null */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ?ResponseValidityConstraint { $responseValidityConstraint = new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -174,7 +174,7 @@ public function getResponseValidityConstraint() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $prompt = $this->getPrompt(); $components = $prompt @@ -194,7 +194,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'graphicGapMatchInteraction'; } diff --git a/src/qtism/data/content/interactions/GraphicInteraction.php b/src/qtism/data/content/interactions/GraphicInteraction.php index 787892f43..488482d49 100644 --- a/src/qtism/data/content/interactions/GraphicInteraction.php +++ b/src/qtism/data/content/interactions/GraphicInteraction.php @@ -64,7 +64,7 @@ public function __construct($responseIdentifier, ObjectElement $object, $id = '' * * @param ObjectElement $object An ObjectElement object. */ - public function setObject(ObjectElement $object) + public function setObject(ObjectElement $object): void { $this->object = $object; } @@ -74,7 +74,7 @@ public function setObject(ObjectElement $object) * * @return ObjectElement An ObjectElement object. */ - public function getObject() + public function getObject(): ObjectElement { return $this->object; } diff --git a/src/qtism/data/content/interactions/GraphicOrderInteraction.php b/src/qtism/data/content/interactions/GraphicOrderInteraction.php index dc9c923b9..653d3c41b 100644 --- a/src/qtism/data/content/interactions/GraphicOrderInteraction.php +++ b/src/qtism/data/content/interactions/GraphicOrderInteraction.php @@ -114,7 +114,7 @@ public function __construct($responseIdentifier, ObjectElement $object, HotspotC * @param HotspotChoiceCollection $hotspotChoices A collection of HotspotChoice objects. * @throws InvalidArgumentException If the given $hotspotChoices collection is empty. */ - public function setHotspotChoices(HotspotChoiceCollection $hotspotChoices) + public function setHotspotChoices(HotspotChoiceCollection $hotspotChoices): void { if (count($hotspotChoices) > 0) { $this->hotspotChoices = $hotspotChoices; @@ -129,7 +129,7 @@ public function setHotspotChoices(HotspotChoiceCollection $hotspotChoices) * * @return HotspotChoiceCollection A collection of HotspotChoice objects. */ - public function getHotspotChoices() + public function getHotspotChoices(): HotspotChoiceCollection { return $this->hotspotChoices; } @@ -141,7 +141,7 @@ public function getHotspotChoices() * @param int $minChoices A strictly negative or positive integer. * @throws InvalidArgumentException If $minChoice is not a strictly negative or positive integer. */ - public function setMinChoices($minChoices) + public function setMinChoices($minChoices): void { if (is_int($minChoices) && $minChoices !== 0) { if ($minChoices > count($this->getHotspotChoices())) { @@ -162,7 +162,7 @@ public function setMinChoices($minChoices) * * @return int A strictly negative or positive integer. */ - public function getMinChoices() + public function getMinChoices(): int { return $this->minChoices; } @@ -172,7 +172,7 @@ public function getMinChoices() * * @return bool */ - public function hasMinChoices() + public function hasMinChoices(): bool { return $this->getMinChoices() > -1; } @@ -184,7 +184,7 @@ public function hasMinChoices() * @param int $maxChoices A strictly negative or positive integer. * @throws InvalidArgumentException If $maxChoices is not a strictly negative or positive integer. */ - public function setMaxChoices($maxChoices) + public function setMaxChoices($maxChoices): void { if (is_int($maxChoices) && $maxChoices !== 0) { if ($this->getMinChoices() > 0 && $maxChoices < $this->getMinChoices()) { @@ -205,7 +205,7 @@ public function setMaxChoices($maxChoices) * * @return int A strictly negative or positive integer. */ - public function getMaxChoices() + public function getMaxChoices(): int { return $this->maxChoices; } @@ -215,7 +215,7 @@ public function getMaxChoices() * * @return bool */ - public function hasMaxChoices() + public function hasMaxChoices(): bool { return $this->getMaxChoices() > -1; } @@ -223,7 +223,7 @@ public function hasMaxChoices() /** * @return ResponseValidityConstraint */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ResponseValidityConstraint { return new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -235,7 +235,7 @@ public function getResponseValidityConstraint() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(array_merge([$this->getObject()], $this->getHotspotChoices()->getArrayCopy())); } @@ -243,7 +243,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'graphicOrderInteraction'; } diff --git a/src/qtism/data/content/interactions/Hotspot.php b/src/qtism/data/content/interactions/Hotspot.php index 26f39ce12..bd2df4eb8 100644 --- a/src/qtism/data/content/interactions/Hotspot.php +++ b/src/qtism/data/content/interactions/Hotspot.php @@ -45,9 +45,9 @@ public function setShape($shape); /** * Get the shape of the hotspot. * - * @return int A Shape object. + * @return int A value from the Shape enumeration. */ - public function getShape(); + public function getShape(): int; /** * Set the coords of the hotspot. @@ -61,7 +61,7 @@ public function setCoords(QtiCoords $coords); * * @return QtiCoords A Coords object. */ - public function getCoords(); + public function getCoords(): QtiCoords; /** * Set the alternative text for this hotspot. @@ -76,7 +76,7 @@ public function setHotspotLabel($hotspotLabel); * * @return string A string with a maximum of 256 characters. */ - public function getHotspotLabel(); + public function getHotspotLabel(): string; /** * Whether or not a value is defined for the hotspotLabel @@ -84,5 +84,5 @@ public function getHotspotLabel(); * * @return bool */ - public function hasHotspotLabel(); + public function hasHotspotLabel(): bool; } diff --git a/src/qtism/data/content/interactions/HotspotChoice.php b/src/qtism/data/content/interactions/HotspotChoice.php index 0d737ffab..8f183f19c 100644 --- a/src/qtism/data/content/interactions/HotspotChoice.php +++ b/src/qtism/data/content/interactions/HotspotChoice.php @@ -90,7 +90,7 @@ public function __construct($identifier, $shape, QtiCoords $coords, $id = '', $c * * @param int $shape A value from the Shape enumeration. */ - public function setShape($shape) + public function setShape($shape): void { if (in_array($shape, QtiShape::asArray())) { $this->shape = $shape; @@ -101,11 +101,9 @@ public function setShape($shape) } /** - * Get the shape of the associableHotspot. - * - * @return QtiShape A Shape object. + * @inheritDoc */ - public function getShape() + public function getShape(): int { return $this->shape; } @@ -115,7 +113,7 @@ public function getShape() * * @param QtiCoords $coords A QtiCoords object. */ - public function setCoords(QtiCoords $coords) + public function setCoords(QtiCoords $coords): void { $this->coords = $coords; } @@ -125,7 +123,7 @@ public function setCoords(QtiCoords $coords) * * @return QtiCoords A QtiCoords object. */ - public function getCoords() + public function getCoords(): QtiCoords { return $this->coords; } @@ -136,7 +134,7 @@ public function getCoords() * @param string $hotspotLabel A string with at most 256 characters. * @throws InvalidArgumentException If $hotspotLabel has more than 256 characters. */ - public function setHotspotLabel($hotspotLabel) + public function setHotspotLabel($hotspotLabel): void { if (Format::isString256($hotspotLabel) === true) { $this->hotspotLabel = $hotspotLabel; @@ -151,7 +149,7 @@ public function setHotspotLabel($hotspotLabel) * * @return string A string with at most 256 characters. */ - public function getHotspotLabel() + public function getHotspotLabel(): string { return $this->hotspotLabel; } @@ -161,7 +159,7 @@ public function getHotspotLabel() * * @return bool */ - public function hasHotspotLabel() + public function hasHotspotLabel(): bool { return $this->getHotspotLabel() !== ''; } @@ -172,7 +170,7 @@ public function hasHotspotLabel() * * @return QtiComponentCollection An empty collection. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -180,7 +178,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'hotspotChoice'; } diff --git a/src/qtism/data/content/interactions/HotspotChoiceCollection.php b/src/qtism/data/content/interactions/HotspotChoiceCollection.php index 616e68a5f..8aa14d76e 100644 --- a/src/qtism/data/content/interactions/HotspotChoiceCollection.php +++ b/src/qtism/data/content/interactions/HotspotChoiceCollection.php @@ -38,7 +38,7 @@ class HotspotChoiceCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of HotspotChoice. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof HotspotChoice) { $msg = 'HotspotChoiceCollection objects only accept to store HotspotChoice objects.'; diff --git a/src/qtism/data/content/interactions/HotspotInteraction.php b/src/qtism/data/content/interactions/HotspotInteraction.php index d1d69c79d..493ec88bb 100644 --- a/src/qtism/data/content/interactions/HotspotInteraction.php +++ b/src/qtism/data/content/interactions/HotspotInteraction.php @@ -107,7 +107,7 @@ public function __construct($responseIdentifier, ObjectElement $object, HotspotC * @param int $maxChoices A positive (>= 0) integer. * @throws InvalidArgumentException If $maxChoices is not a positive integer. */ - public function setMaxChoices($maxChoices) + public function setMaxChoices($maxChoices): void { if (is_int($maxChoices) && $maxChoices >= 0) { $this->maxChoices = $maxChoices; @@ -123,7 +123,7 @@ public function setMaxChoices($maxChoices) * * @return int A positive (>= 0) integer. */ - public function getMaxChoices() + public function getMaxChoices(): int { return $this->maxChoices; } @@ -135,7 +135,7 @@ public function getMaxChoices() * @param int $minChoices A positive (>= 0) integer. * @throws InvalidArgumentException If $minChoices is not a positive integer. */ - public function setMinChoices($minChoices) + public function setMinChoices($minChoices): void { if (is_int($minChoices) && $minChoices >= 0) { $this->minChoices = $minChoices; @@ -151,7 +151,7 @@ public function setMinChoices($minChoices) * * @return int A positive (>= 0) integer. */ - public function getMinChoices() + public function getMinChoices(): int { return $this->minChoices; } @@ -162,7 +162,7 @@ public function getMinChoices() * @param HotspotChoiceCollection $hotspotChoices A collection of HotspotChoice objects. * @throws InvalidArgumentException If the given collection is empty. */ - public function setHotspotChoices(HotspotChoiceCollection $hotspotChoices) + public function setHotspotChoices(HotspotChoiceCollection $hotspotChoices): void { if (count($hotspotChoices) > 0) { $this->hotspotChoices = $hotspotChoices; @@ -177,7 +177,7 @@ public function setHotspotChoices(HotspotChoiceCollection $hotspotChoices) * * @return HotspotChoiceCollection A collection of HotspotChoice objects. */ - public function getHotspotChoices() + public function getHotspotChoices(): HotspotChoiceCollection { return $this->hotspotChoices; } @@ -185,7 +185,7 @@ public function getHotspotChoices() /** * @return ResponseValidityConstraint|null */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ?ResponseValidityConstraint { return new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -197,7 +197,7 @@ public function getResponseValidityConstraint() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $array = []; if ($this->hasPrompt() === true) { @@ -212,7 +212,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'hotspotInteraction'; } diff --git a/src/qtism/data/content/interactions/Hottext.php b/src/qtism/data/content/interactions/Hottext.php index 5da267998..d1983e67f 100644 --- a/src/qtism/data/content/interactions/Hottext.php +++ b/src/qtism/data/content/interactions/Hottext.php @@ -75,7 +75,7 @@ public function __construct($identifier, $id = '', $class = '', $lang = '', $lab * * @param InlineStaticCollection $content A collection of InlineStatic objects. */ - public function setContent(InlineStaticCollection $content) + public function setContent(InlineStaticCollection $content): void { $this->content = $content; } @@ -85,7 +85,7 @@ public function setContent(InlineStaticCollection $content) * * @return InlineStaticCollection */ - public function getContent() + public function getContent(): InlineStaticCollection { return $this->content; } @@ -93,7 +93,7 @@ public function getContent() /** * @return InlineStaticCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -101,7 +101,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'hottext'; } diff --git a/src/qtism/data/content/interactions/HottextInteraction.php b/src/qtism/data/content/interactions/HottextInteraction.php index a234960b1..b40f452d1 100644 --- a/src/qtism/data/content/interactions/HottextInteraction.php +++ b/src/qtism/data/content/interactions/HottextInteraction.php @@ -106,7 +106,7 @@ public function __construct($responseIdentifier, BlockStaticCollection $content, * @param int $maxChoices A positive integer. * @throws InvalidArgumentException If $maxChoices is not a positive integer. */ - public function setMaxChoices($maxChoices) + public function setMaxChoices($maxChoices): void { if (is_int($maxChoices) && $maxChoices >= 0) { $this->maxChoices = $maxChoices; @@ -122,7 +122,7 @@ public function setMaxChoices($maxChoices) * * @return int A positive (>= 0) integer. */ - public function getMaxChoices() + public function getMaxChoices(): int { return $this->maxChoices; } @@ -133,7 +133,7 @@ public function getMaxChoices() * @param int $minChoices A positive (>= 0) integer. * @throws InvalidArgumentException If $minChoices is not a positive integer or does not respect the limits imposed by maxChoices. */ - public function setMinChoices($minChoices) + public function setMinChoices($minChoices): void { if (is_int($minChoices) && $minChoices > 0) { if ($this->maxChoices > 0 && $minChoices > $this->maxChoices) { @@ -155,7 +155,7 @@ public function setMinChoices($minChoices) * * @return int A positive (>= 0) integer. */ - public function getMinChoices() + public function getMinChoices(): int { return $this->minChoices; } @@ -166,7 +166,7 @@ public function getMinChoices() * @param BlockStaticCollection $content A collection of at least one BlockStatic object. * @throws InvalidArgumentException If $content is empty. */ - public function setContent(BlockStaticCollection $content) + public function setContent(BlockStaticCollection $content): void { if (count($content) > 0) { $this->content = $content; @@ -181,7 +181,7 @@ public function setContent(BlockStaticCollection $content) * * @return BlockStaticCollection A collection of at least one BlockStatic object. */ - public function getContent() + public function getContent(): BlockStaticCollection { return $this->content; } @@ -189,7 +189,7 @@ public function getContent() /** * @return ResponseValidityConstraint|null */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ?ResponseValidityConstraint { return new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -201,7 +201,7 @@ public function getResponseValidityConstraint() /** * @return BlockStaticCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -209,7 +209,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'hottextInteraction'; } diff --git a/src/qtism/data/content/interactions/InlineChoice.php b/src/qtism/data/content/interactions/InlineChoice.php index d9e728fbb..5ee645c62 100644 --- a/src/qtism/data/content/interactions/InlineChoice.php +++ b/src/qtism/data/content/interactions/InlineChoice.php @@ -64,7 +64,7 @@ public function __construct($identifier, $id = '', $class = '', $lang = '', $lab * * @param TextOrVariableCollection $content A collection of TextOrVariable objects. */ - public function setContent(TextOrVariableCollection $content) + public function setContent(TextOrVariableCollection $content): void { $this->content = $content; } @@ -74,7 +74,7 @@ public function setContent(TextOrVariableCollection $content) * * @return TextOrVariableCollection A collection of TextOrVariable objects. */ - public function getContent() + public function getContent(): TextOrVariableCollection { return $this->content; } @@ -82,7 +82,7 @@ public function getContent() /** * @return TextOrVariableCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->content; } @@ -90,7 +90,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'inlineChoice'; } diff --git a/src/qtism/data/content/interactions/InlineChoiceCollection.php b/src/qtism/data/content/interactions/InlineChoiceCollection.php index 78e223de8..e52cc70ce 100644 --- a/src/qtism/data/content/interactions/InlineChoiceCollection.php +++ b/src/qtism/data/content/interactions/InlineChoiceCollection.php @@ -37,7 +37,7 @@ class InlineChoiceCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of InlineChoice. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof InlineChoice) { $msg = 'InlineChoiceCollection objects only accept InlineChoice objects to be stored.'; diff --git a/src/qtism/data/content/interactions/InlineChoiceInteraction.php b/src/qtism/data/content/interactions/InlineChoiceInteraction.php index 1eedda844..7d673a79d 100644 --- a/src/qtism/data/content/interactions/InlineChoiceInteraction.php +++ b/src/qtism/data/content/interactions/InlineChoiceInteraction.php @@ -104,7 +104,7 @@ public function __construct($responseIdentifier, InlineChoiceCollection $content * @param bool $shuffle * @throws InvalidArgumentException If $shuffle is not a boolean value. */ - public function setShuffle($shuffle) + public function setShuffle($shuffle): void { if (is_bool($shuffle)) { $this->shuffle = $shuffle; @@ -119,7 +119,7 @@ public function setShuffle($shuffle) * * @return bool */ - public function mustShuffle() + public function mustShuffle(): bool { return $this->shuffle; } @@ -130,7 +130,7 @@ public function mustShuffle() * @param bool $required * @throws InvalidArgumentException If $required is not a boolean value. */ - public function setRequired($required) + public function setRequired($required): void { if (is_bool($required)) { $this->required = $required; @@ -145,7 +145,7 @@ public function setRequired($required) * * @return bool */ - public function isRequired() + public function isRequired(): bool { return $this->required; } @@ -156,7 +156,7 @@ public function isRequired() * @param InlineChoiceCollection $content A collection of at least one InlineChoice object. * @throws InvalidArgumentException If $content is empty. */ - public function setContent(InlineChoiceCollection $content) + public function setContent(InlineChoiceCollection $content): void { if (count($content) > 0) { $this->content = $content; @@ -171,7 +171,7 @@ public function setContent(InlineChoiceCollection $content) * * @return InlineChoiceCollection A collection of at least one InlineChoice object. */ - public function getContent() + public function getContent(): InlineChoiceCollection { return $this->content; } @@ -179,7 +179,7 @@ public function getContent() /** * @return ResponseValidityConstraint|null */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ?ResponseValidityConstraint { return new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -191,7 +191,7 @@ public function getResponseValidityConstraint() /** * @return InlineChoiceCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -199,7 +199,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'inlineChoiceInteraction'; } diff --git a/src/qtism/data/content/interactions/Interaction.php b/src/qtism/data/content/interactions/Interaction.php index 8c34639ab..81b48e40a 100644 --- a/src/qtism/data/content/interactions/Interaction.php +++ b/src/qtism/data/content/interactions/Interaction.php @@ -89,9 +89,9 @@ public function __construct($responseIdentifier, $id = '', $class = '', $lang = * @param string $responseIdentifier A QTI identifier. * @throws InvalidArgumentException If $responseIdentifier is not a valid QTI identifier. */ - public function setResponseIdentifier($responseIdentifier) + public function setResponseIdentifier($responseIdentifier): void { - if (Format::isIdentifier($responseIdentifier, false) === true) { + if (Format::isIdentifier((string)$responseIdentifier, false) === true) { $this->responseIdentifier = $responseIdentifier; } else { $msg = "The 'responseIdentifier' argument must be a valid QTI identifier."; @@ -104,7 +104,7 @@ public function setResponseIdentifier($responseIdentifier) * * @return string A QTI identifier. */ - public function getResponseIdentifier() + public function getResponseIdentifier(): string { return $this->responseIdentifier; } @@ -117,7 +117,7 @@ public function getResponseIdentifier() * * @return ResponseValidityConstraint|null A ResponseValidityConstraint object or a null value if there is not response validity constraint bound to the interaction's response variable. */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ?ResponseValidityConstraint { return null; } diff --git a/src/qtism/data/content/interactions/MatchInteraction.php b/src/qtism/data/content/interactions/MatchInteraction.php index 65abd0890..98b456065 100644 --- a/src/qtism/data/content/interactions/MatchInteraction.php +++ b/src/qtism/data/content/interactions/MatchInteraction.php @@ -98,7 +98,7 @@ public function __construct($responseIdentifier, SimpleMatchSetCollection $simpl * @param bool $shuffle A boolean value. * @throws InvalidArgumentException If $shuffle is not a boolean value. */ - public function setShuffle($shuffle) + public function setShuffle($shuffle): void { if (is_bool($shuffle)) { $this->shuffle = $shuffle; @@ -113,7 +113,7 @@ public function setShuffle($shuffle) * * @return bool */ - public function mustShuffle() + public function mustShuffle(): bool { return $this->shuffle; } @@ -125,7 +125,7 @@ public function mustShuffle() * @param int $maxAssociations A positive (>= 0) integer. * @throws InvalidArgumentException If $maxAssociations is not a positive integer. */ - public function setMaxAssociations($maxAssociations) + public function setMaxAssociations($maxAssociations): void { if (is_int($maxAssociations) && $maxAssociations >= 0) { $this->maxAssociations = $maxAssociations; @@ -141,7 +141,7 @@ public function setMaxAssociations($maxAssociations) * * @return int A positive (>= 0) integer */ - public function getMaxAssociations() + public function getMaxAssociations(): int { return $this->maxAssociations; } @@ -152,7 +152,7 @@ public function getMaxAssociations() * * @return bool */ - public function hasMaxAssociations() + public function hasMaxAssociations(): bool { return $this->getMaxAssociations() > 0; } @@ -164,7 +164,7 @@ public function hasMaxAssociations() * @param int $minAssociations A positive (>= 0) integer. * @throws InvalidArgumentException If $minAssociations is not a positive integer or does not respect the limit imposed by maxAssociations. */ - public function setMinAssociations($minAssociations) + public function setMinAssociations($minAssociations): void { if (is_int($minAssociations) && $minAssociations >= 0) { if ($this->hasMaxAssociations() === true && $minAssociations > $this->getMaxAssociations()) { @@ -185,7 +185,7 @@ public function setMinAssociations($minAssociations) * * @return int A positive (> 0) integer. */ - public function getMinAssociations() + public function getMinAssociations(): int { return $this->minAssociations; } @@ -195,7 +195,7 @@ public function getMinAssociations() * * @return bool */ - public function hasMinAssociations() + public function hasMinAssociations(): bool { return $this->getMinAssociations() > 0; } @@ -207,7 +207,7 @@ public function hasMinAssociations() * @param SimpleMatchSetCollection $simpleMatchSets A collection of exactly two SimpleMatchSet objects. * @throws InvalidArgumentException If $simpleMatchSets does not contain exactly two SimpleMatchSet objects. */ - public function setSimpleMatchSets(SimpleMatchSetCollection $simpleMatchSets) + public function setSimpleMatchSets(SimpleMatchSetCollection $simpleMatchSets): void { if (count($simpleMatchSets) === 2) { $this->simpleMatchSets = $simpleMatchSets; @@ -223,7 +223,7 @@ public function setSimpleMatchSets(SimpleMatchSetCollection $simpleMatchSets) * * @return SimpleMatchSetCollection A collection of exactly two SimpleMatchSet objects. */ - public function getSimpleMatchSets() + public function getSimpleMatchSets(): SimpleMatchSetCollection { return $this->simpleMatchSets; } @@ -233,7 +233,7 @@ public function getSimpleMatchSets() * * @return SimpleMatchSet A SimpleMatchSet object. */ - public function getSourceChoices() + public function getSourceChoices(): SimpleMatchSet { $matchSets = $this->getSimpleMatchSets(); @@ -245,7 +245,7 @@ public function getSourceChoices() * * @return SimpleMatchSet A SimpleMatchSet object. */ - public function getTargetChoices() + public function getTargetChoices(): SimpleMatchSet { $matchSets = $this->getSimpleMatchSets(); @@ -255,7 +255,7 @@ public function getTargetChoices() /** * @return ResponseValidityConstraint */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ResponseValidityConstraint { $responseValidityConstraint = new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -279,7 +279,7 @@ public function getResponseValidityConstraint() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $parentComponents = parent::getComponents(); @@ -289,7 +289,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'matchInteraction'; } diff --git a/src/qtism/data/content/interactions/MediaInteraction.php b/src/qtism/data/content/interactions/MediaInteraction.php index 52ac55249..96d73a0db 100644 --- a/src/qtism/data/content/interactions/MediaInteraction.php +++ b/src/qtism/data/content/interactions/MediaInteraction.php @@ -121,7 +121,7 @@ public function __construct($responseIdentifier, $autostart, ObjectElement $obje * @param bool $autostart * @throws InvalidArgumentException If $autostart is not a boolean value. */ - public function setAutostart($autostart) + public function setAutostart($autostart): void { if (is_bool($autostart)) { $this->autostart = $autostart; @@ -136,7 +136,7 @@ public function setAutostart($autostart) * * @return bool */ - public function mustAutostart() + public function mustAutostart(): bool { return $this->autostart; } @@ -147,7 +147,7 @@ public function mustAutostart() * @param int $minPlays A positive (>= 0) integer. * @throws InvalidArgumentException If $minPlays is not a positive integer. */ - public function setMinPlays($minPlays) + public function setMinPlays($minPlays): void { if (is_int($minPlays) && $minPlays >= 0) { $this->minPlays = $minPlays; @@ -162,7 +162,7 @@ public function setMinPlays($minPlays) * * @return int A positive (> 0) integer. */ - public function getMinPlays() + public function getMinPlays(): int { return $this->minPlays; } @@ -172,7 +172,7 @@ public function getMinPlays() * * @return bool */ - public function hasMinPlays() + public function hasMinPlays(): bool { return $this->getMinPlays() !== 0; } @@ -183,7 +183,7 @@ public function hasMinPlays() * @param int $maxPlays A positive (>= 0) integer. * @throws InvalidArgumentException If $maxPlays is not a positive integer. */ - public function setMaxPlays($maxPlays) + public function setMaxPlays($maxPlays): void { if (is_int($maxPlays) && $maxPlays >= 0) { $this->maxPlays = $maxPlays; @@ -198,7 +198,7 @@ public function setMaxPlays($maxPlays) * * @return int A positive (>= 0) integer. */ - public function getMaxPlays() + public function getMaxPlays(): int { return $this->maxPlays; } @@ -208,7 +208,7 @@ public function getMaxPlays() * * @return bool */ - public function hasMaxPlays() + public function hasMaxPlays(): bool { return $this->getMaxPlays() !== 0; } @@ -219,7 +219,7 @@ public function hasMaxPlays() * @param bool $loop * @throws InvalidArgumentException If $loop is not a boolean value. */ - public function setLoop($loop) + public function setLoop($loop): void { if (is_bool($loop)) { $this->loop = $loop; @@ -234,7 +234,7 @@ public function setLoop($loop) * * @return bool */ - public function mustLoop() + public function mustLoop(): bool { return $this->loop; } @@ -244,7 +244,7 @@ public function mustLoop() * * @param ObjectElement $object */ - public function setObject(ObjectElement $object) + public function setObject(ObjectElement $object): void { $this->object = $object; } @@ -254,7 +254,7 @@ public function setObject(ObjectElement $object) * * @return ObjectElement */ - public function getObject() + public function getObject(): ObjectElement { return $this->object; } @@ -262,7 +262,7 @@ public function getObject() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $parentComponent = parent::getComponents(); @@ -272,7 +272,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'mediaInteraction'; } diff --git a/src/qtism/data/content/interactions/OrderInteraction.php b/src/qtism/data/content/interactions/OrderInteraction.php index 7fed2adec..1dd564ea2 100644 --- a/src/qtism/data/content/interactions/OrderInteraction.php +++ b/src/qtism/data/content/interactions/OrderInteraction.php @@ -138,7 +138,7 @@ public function __construct($responseIdentifier, SimpleChoiceCollection $simpleC * @param SimpleChoiceCollection $simpleChoices A list of at lease one SimpleChoice object. * @throws InvalidArgumentException If $simpleChoices is empty. */ - public function setSimpleChoices(SimpleChoiceCollection $simpleChoices) + public function setSimpleChoices(SimpleChoiceCollection $simpleChoices): void { if (count($simpleChoices) > 0) { $this->simpleChoices = $simpleChoices; @@ -153,7 +153,7 @@ public function setSimpleChoices(SimpleChoiceCollection $simpleChoices) * * @return SimpleChoiceCollection A list of at lease one SimpleChoice object. */ - public function getSimpleChoices() + public function getSimpleChoices(): SimpleChoiceCollection { return $this->simpleChoices; } @@ -164,7 +164,7 @@ public function getSimpleChoices() * @param bool $shuffle A boolean value. * @throws InvalidArgumentException If $shuffle is not a boolean value. */ - public function setShuffle($shuffle) + public function setShuffle($shuffle): void { if (is_bool($shuffle)) { $this->shuffle = $shuffle; @@ -179,7 +179,7 @@ public function setShuffle($shuffle) * * @return bool */ - public function mustShuffle() + public function mustShuffle(): bool { return $this->shuffle; } @@ -190,7 +190,7 @@ public function mustShuffle() * @param int $minChoices A strictly (> 0) positive integer or -1 if no value is specified for the attribute. * @throws InvalidArgumentException If $minChoices is not a strictly positive integer nor -1. */ - public function setMinChoices($minChoices) + public function setMinChoices($minChoices): void { if (is_int($minChoices) && ($minChoices > 0 || $minChoices === -1)) { if ($minChoices > count($this->getSimpleChoices())) { @@ -210,7 +210,7 @@ public function setMinChoices($minChoices) * * @return int A strictly positive (> 0) integer. */ - public function getMinChoices() + public function getMinChoices(): int { return $this->minChoices; } @@ -220,7 +220,7 @@ public function getMinChoices() * * @return bool */ - public function hasMinChoices() + public function hasMinChoices(): bool { return $this->getMinChoices() !== -1; } @@ -231,7 +231,7 @@ public function hasMinChoices() * @param int $maxChoices A strictly positive (> 0) integer or -1 if no value is specified for the attribuite. * @throws InvalidArgumentException If $maxChoices is not a strictly positive integer nor -1. */ - public function setMaxChoices($maxChoices) + public function setMaxChoices($maxChoices): void { if (is_int($maxChoices) && $maxChoices > 0 || $maxChoices === -1) { if ($this->hasMinChoices() === true && $maxChoices > count($this->getSimpleChoices())) { @@ -251,7 +251,7 @@ public function setMaxChoices($maxChoices) * * @return int A strictly positive (> 0) integer or -1 if no value is defined for the maxChoices attribute. */ - public function getMaxChoices() + public function getMaxChoices(): int { return $this->maxChoices; } @@ -261,7 +261,7 @@ public function getMaxChoices() * * @return bool */ - public function hasMaxChoices() + public function hasMaxChoices(): bool { return $this->getMaxChoices() !== -1; } @@ -272,7 +272,7 @@ public function hasMaxChoices() * @param int $orientation A value from the Orientation enumeration. * @throws InvalidArgumentException If $orientation is not a value from the Orientation enumeration. */ - public function setOrientation($orientation) + public function setOrientation($orientation): void { if (in_array($orientation, Orientation::asArray(), true)) { $this->orientation = $orientation; @@ -287,7 +287,7 @@ public function setOrientation($orientation) * * @return int A value from the Orientation enumeration. */ - public function getOrientation() + public function getOrientation(): int { return $this->orientation; } @@ -295,7 +295,7 @@ public function getOrientation() /** * @return ResponseValidityConstraint */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ResponseValidityConstraint { return new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -307,7 +307,7 @@ public function getResponseValidityConstraint() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $parentComponents = parent::getComponents(); @@ -317,7 +317,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'orderInteraction'; } diff --git a/src/qtism/data/content/interactions/Orientation.php b/src/qtism/data/content/interactions/Orientation.php index 344f12155..2de3eb351 100644 --- a/src/qtism/data/content/interactions/Orientation.php +++ b/src/qtism/data/content/interactions/Orientation.php @@ -30,14 +30,14 @@ */ class Orientation implements Enumeration { - const VERTICAL = 0; + public const VERTICAL = 0; - const HORIZONTAL = 1; + public const HORIZONTAL = 1; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'VERTICAL' => 0, @@ -51,7 +51,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'vertical': return self::VERTICAL; break; diff --git a/src/qtism/data/content/interactions/PositionObjectInteraction.php b/src/qtism/data/content/interactions/PositionObjectInteraction.php index dfa92ff53..52f1f1ef6 100644 --- a/src/qtism/data/content/interactions/PositionObjectInteraction.php +++ b/src/qtism/data/content/interactions/PositionObjectInteraction.php @@ -119,7 +119,7 @@ public function __construct($responseIdentifier, ObjectElement $object, $id = '' * * @param QtiPoint $centerPoint A Point object or null. */ - public function setCenterPoint(QtiPoint $centerPoint = null) + public function setCenterPoint(QtiPoint $centerPoint = null): void { $this->centerPoint = $centerPoint; } @@ -128,9 +128,9 @@ public function setCenterPoint(QtiPoint $centerPoint = null) * Get the centerPoint attribute. The null value is returned if there is no centerPoint * specified. * - * @return QtiPoint A Point object or null. + * @return QtiPoint|null A Point object or null. */ - public function getCenterPoint() + public function getCenterPoint(): ?QtiPoint { return $this->centerPoint; } @@ -140,7 +140,7 @@ public function getCenterPoint() * * @return bool */ - public function hasCenterPoint() + public function hasCenterPoint(): bool { return $this->getCenterPoint() !== null; } @@ -151,7 +151,7 @@ public function hasCenterPoint() * @param int $maxChoices A positive (>= 0) integer. * @throws InvalidArgumentException If $maxChoices is not a positive integer. */ - public function setMaxChoices($maxChoices) + public function setMaxChoices($maxChoices): void { if (is_int($maxChoices) && $maxChoices >= 0) { $this->maxChoices = $maxChoices; @@ -166,7 +166,7 @@ public function setMaxChoices($maxChoices) * * @return int A positive (>= 0) integer. */ - public function getMaxChoices() + public function getMaxChoices(): int { return $this->maxChoices; } @@ -178,7 +178,7 @@ public function getMaxChoices() * @param int $minChoices A strictly positive (> 0) integer that respects the limits imposed by 'maxChoices' or a negative integer to specify there is no 'minChoices'. * @throws InvalidArgumentException If $minChoices is not a strictly positive integer of if it does not respect the limits imposed by 'maxChoices'. */ - public function setMinChoices($minChoices) + public function setMinChoices($minChoices): void { if (is_int($minChoices) && $minChoices >= 0) { if ($this->maxChoices > 0 && $minChoices > $this->maxChoices) { @@ -199,7 +199,7 @@ public function setMinChoices($minChoices) * * @return int A strictly positive integer or a negative integer which specifies there is no 'minChoices'. */ - public function getMinChoices() + public function getMinChoices(): int { return $this->minChoices; } @@ -209,7 +209,7 @@ public function getMinChoices() * * @return bool */ - public function hasMinChoices() + public function hasMinChoices(): bool { return $this->getMinChoices() > 0; } @@ -219,7 +219,7 @@ public function hasMinChoices() * * @param ObjectElement $object An image as an ObjectElement object. */ - public function setObject(ObjectElement $object) + public function setObject(ObjectElement $object): void { $this->object = $object; } @@ -229,7 +229,7 @@ public function setObject(ObjectElement $object) * * @return ObjectElement An image as an ObjectElement object. */ - public function getObject() + public function getObject(): ObjectElement { return $this->object; } @@ -237,7 +237,7 @@ public function getObject() /** * @return ResponseValidityConstraint */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ResponseValidityConstraint { return new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -249,7 +249,7 @@ public function getResponseValidityConstraint() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection([$this->getObject()]); } @@ -257,7 +257,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'positionObjectInteraction'; } diff --git a/src/qtism/data/content/interactions/PositionObjectInteractionCollection.php b/src/qtism/data/content/interactions/PositionObjectInteractionCollection.php index 076df2bb5..32308bb57 100644 --- a/src/qtism/data/content/interactions/PositionObjectInteractionCollection.php +++ b/src/qtism/data/content/interactions/PositionObjectInteractionCollection.php @@ -38,7 +38,7 @@ class PositionObjectInteractionCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a PositionObjectInteraction object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof PositionObjectInteraction) { $msg = 'PositionObjectInteractionCollection objects only accept to store PositionObjectInteraction objects.'; diff --git a/src/qtism/data/content/interactions/PositionObjectStage.php b/src/qtism/data/content/interactions/PositionObjectStage.php index 56972d9c1..8aa10ba0b 100644 --- a/src/qtism/data/content/interactions/PositionObjectStage.php +++ b/src/qtism/data/content/interactions/PositionObjectStage.php @@ -59,7 +59,7 @@ class PositionObjectStage extends QtiComponent implements Block * @param ObjectElement $object An ObjectElement object. * @qtism-bean-property */ - public function setObject(ObjectElement $object) + public function setObject(ObjectElement $object): void { $this->object = $object; } @@ -70,7 +70,7 @@ public function setObject(ObjectElement $object) * @return ObjectElement An ObjectElement object. * @qtism-bean-property */ - public function getObject() + public function getObject(): ObjectElement { return $this->object; } @@ -93,7 +93,7 @@ public function __construct(ObjectElement $object, PositionObjectInteractionColl * @param PositionObjectInteractionCollection $positionObjectInteractions A collection of PositionObjectInteraction objects. * @throws InvalidArgumentException If $positionObjectInteractions is empty. */ - public function setPositionObjectInteractions(PositionObjectInteractionCollection $positionObjectInteractions) + public function setPositionObjectInteractions(PositionObjectInteractionCollection $positionObjectInteractions): void { if (count($positionObjectInteractions) > 0) { $this->positionObjectInteractions = $positionObjectInteractions; @@ -108,7 +108,7 @@ public function setPositionObjectInteractions(PositionObjectInteractionCollectio * * @return PositionObjectInteractionCollection A collection of PositionObjectInteraction objects. */ - public function getPositionObjectInteractions() + public function getPositionObjectInteractions(): PositionObjectInteractionCollection { return $this->positionObjectInteractions; } @@ -116,7 +116,7 @@ public function getPositionObjectInteractions() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(array_merge([$this->getObject()], $this->getPositionObjectInteractions()->getArrayCopy())); } @@ -124,7 +124,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'positionObjectStage'; } diff --git a/src/qtism/data/content/interactions/Prompt.php b/src/qtism/data/content/interactions/Prompt.php index 1c6904f45..f69925982 100644 --- a/src/qtism/data/content/interactions/Prompt.php +++ b/src/qtism/data/content/interactions/Prompt.php @@ -63,7 +63,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @param FlowStaticCollection $content A collection of FlowStatic objects. */ - public function setContent(FlowStaticCollection $content) + public function setContent(FlowStaticCollection $content): void { $this->content = $content; } @@ -73,7 +73,7 @@ public function setContent(FlowStaticCollection $content) * * @return FlowStaticCollection A collection of FlowStatic objects. */ - public function getContent() + public function getContent(): FlowStaticCollection { return $this->content; } @@ -81,7 +81,7 @@ public function getContent() /** * @return FlowStaticCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -89,7 +89,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'prompt'; } diff --git a/src/qtism/data/content/interactions/SelectPointInteraction.php b/src/qtism/data/content/interactions/SelectPointInteraction.php index 6693a02c7..801b469bc 100644 --- a/src/qtism/data/content/interactions/SelectPointInteraction.php +++ b/src/qtism/data/content/interactions/SelectPointInteraction.php @@ -92,7 +92,7 @@ public function __construct($responseIdentifier, ObjectElement $object, $id = '' * * @return int A positive (>= 0) integer. */ - public function getMaxChoices() + public function getMaxChoices(): int { return $this->maxChoices; } @@ -103,7 +103,7 @@ public function getMaxChoices() * @param int $maxChoices A positive (>= 0) integer. * @throws InvalidArgumentException If $maxChoices is not a positive integer. */ - public function setMaxChoices($maxChoices) + public function setMaxChoices($maxChoices): void { if (is_int($maxChoices) && $maxChoices >= 0) { $this->maxChoices = $maxChoices; @@ -118,7 +118,7 @@ public function setMaxChoices($maxChoices) * * @return int A positive (>= 0) integer. */ - public function getMinChoices() + public function getMinChoices(): int { return $this->minChoices; } @@ -129,7 +129,7 @@ public function getMinChoices() * @param int $minChoices A positive (>= 0) integer. * @throws InvalidArgumentException If $minChoices is not a positive integer. */ - public function setMinChoices($minChoices) + public function setMinChoices($minChoices): void { if (is_int($minChoices) && $minChoices >= 0) { $this->minChoices = $minChoices; @@ -142,7 +142,7 @@ public function setMinChoices($minChoices) /** * @return ResponseValidityConstraint|null */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ?ResponseValidityConstraint { return new ResponseValidityConstraint( $this->getResponseIdentifier(), @@ -154,7 +154,7 @@ public function getResponseValidityConstraint() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection([$this->getObject()]); } @@ -162,7 +162,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'selectPointInteraction'; } diff --git a/src/qtism/data/content/interactions/SimpleAssociableChoice.php b/src/qtism/data/content/interactions/SimpleAssociableChoice.php index 53fc23e5e..314f32e5e 100644 --- a/src/qtism/data/content/interactions/SimpleAssociableChoice.php +++ b/src/qtism/data/content/interactions/SimpleAssociableChoice.php @@ -108,7 +108,7 @@ public function __construct($identifier, $matchMax, $id = '', $class = '', $lang * @param int $matchMax A positive (>= 0) integer. * @throws InvalidArgumentException If $matchMax is not a positive integer. */ - public function setMatchMax($matchMax) + public function setMatchMax($matchMax): void { if (is_int($matchMax) && $matchMax >= 0) { $this->matchMax = $matchMax; @@ -123,7 +123,7 @@ public function setMatchMax($matchMax) * * @return int A positive (>= 0) integer. */ - public function getMatchMax() + public function getMatchMax(): int { return $this->matchMax; } @@ -134,7 +134,7 @@ public function getMatchMax() * @param int $matchMin A positive (>= 0) integer. * @throws InvalidArgumentException If $matchMin is not a positive integer. */ - public function setMatchMin($matchMin) + public function setMatchMin($matchMin): void { if (is_int($matchMin) && $matchMin >= 0) { $this->matchMin = $matchMin; @@ -147,7 +147,7 @@ public function setMatchMin($matchMin) /** * @return FlowStaticCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -157,7 +157,7 @@ public function getComponents() * * @param FlowStaticCollection $content A collection of FlowStatic objects. */ - public function setContent(FlowStaticCollection $content) + public function setContent(FlowStaticCollection $content): void { $this->content = $content; } @@ -167,7 +167,7 @@ public function setContent(FlowStaticCollection $content) * * @return FlowStaticCollection A collection of FlowStatic objects. */ - public function getContent() + public function getContent(): FlowStaticCollection { return $this->content; } @@ -177,7 +177,7 @@ public function getContent() * * @return int A positive (>= 0) integer. */ - public function getMatchMin() + public function getMatchMin(): int { return $this->matchMin; } @@ -185,7 +185,7 @@ public function getMatchMin() /** * @param IdentifierCollection $matchGroup */ - public function setMatchGroup(IdentifierCollection $matchGroup) + public function setMatchGroup(IdentifierCollection $matchGroup): void { $this->matchGroup = $matchGroup; } @@ -193,7 +193,7 @@ public function setMatchGroup(IdentifierCollection $matchGroup) /** * @return IdentifierCollection */ - public function getMatchGroup() + public function getMatchGroup(): IdentifierCollection { return $this->matchGroup; } @@ -201,7 +201,7 @@ public function getMatchGroup() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'simpleAssociableChoice'; } diff --git a/src/qtism/data/content/interactions/SimpleAssociableChoiceCollection.php b/src/qtism/data/content/interactions/SimpleAssociableChoiceCollection.php index 626f0b40e..1eca7fe3f 100644 --- a/src/qtism/data/content/interactions/SimpleAssociableChoiceCollection.php +++ b/src/qtism/data/content/interactions/SimpleAssociableChoiceCollection.php @@ -38,7 +38,7 @@ class SimpleAssociableChoiceCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of SimpleAssociableChoice. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof SimpleAssociableChoice) { $msg = 'SimpleAssociableChoiceCollection objects only accepts to store SimpleAssociableChoice objects.'; diff --git a/src/qtism/data/content/interactions/SimpleChoice.php b/src/qtism/data/content/interactions/SimpleChoice.php index 9890ffba2..a49214150 100644 --- a/src/qtism/data/content/interactions/SimpleChoice.php +++ b/src/qtism/data/content/interactions/SimpleChoice.php @@ -60,7 +60,7 @@ public function __construct($identifier, $id = '', $class = '', $lang = '', $lab * * @return FlowStaticCollection A collection of FlowStatic objects. */ - public function getComponents() + public function getComponents(): FlowStaticCollection { return $this->getContent(); } @@ -70,7 +70,7 @@ public function getComponents() * * @param FlowStaticCollection $content A collection of FlowStatic objects. */ - public function setContent(FlowStaticCollection $content) + public function setContent(FlowStaticCollection $content): void { $this->content = $content; } @@ -80,7 +80,7 @@ public function setContent(FlowStaticCollection $content) * * @return FlowStaticCollection */ - public function getContent() + public function getContent(): FlowStaticCollection { return $this->content; } @@ -88,7 +88,7 @@ public function getContent() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'simpleChoice'; } diff --git a/src/qtism/data/content/interactions/SimpleChoiceCollection.php b/src/qtism/data/content/interactions/SimpleChoiceCollection.php index c24b4dc67..0d82c718e 100644 --- a/src/qtism/data/content/interactions/SimpleChoiceCollection.php +++ b/src/qtism/data/content/interactions/SimpleChoiceCollection.php @@ -38,7 +38,7 @@ class SimpleChoiceCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of SimpleChoice. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof SimpleChoice) { $msg = 'A SimpleChoiceCollection object only accepts to store SimpleChoice objects.'; diff --git a/src/qtism/data/content/interactions/SimpleMatchSet.php b/src/qtism/data/content/interactions/SimpleMatchSet.php index 8761cb317..03a2d5f68 100644 --- a/src/qtism/data/content/interactions/SimpleMatchSet.php +++ b/src/qtism/data/content/interactions/SimpleMatchSet.php @@ -56,7 +56,7 @@ public function __construct(SimpleAssociableChoiceCollection $simpleAssociableCh * * @param SimpleAssociableChoiceCollection $simpleAssociableChoices */ - public function setSimpleAssociableChoices(SimpleAssociableChoiceCollection $simpleAssociableChoices) + public function setSimpleAssociableChoices(SimpleAssociableChoiceCollection $simpleAssociableChoices): void { $this->simpleAssociableChoices = $simpleAssociableChoices; } @@ -66,7 +66,7 @@ public function setSimpleAssociableChoices(SimpleAssociableChoiceCollection $sim * * @return SimpleAssociableChoiceCollection */ - public function getSimpleAssociableChoices() + public function getSimpleAssociableChoices(): SimpleAssociableChoiceCollection { return $this->simpleAssociableChoices; } @@ -74,7 +74,7 @@ public function getSimpleAssociableChoices() /** * @return SimpleAssociableChoiceCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getSimpleAssociableChoices(); } @@ -82,7 +82,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'simpleMatchSet'; } diff --git a/src/qtism/data/content/interactions/SimpleMatchSetCollection.php b/src/qtism/data/content/interactions/SimpleMatchSetCollection.php index 92c30199d..62fb8686d 100644 --- a/src/qtism/data/content/interactions/SimpleMatchSetCollection.php +++ b/src/qtism/data/content/interactions/SimpleMatchSetCollection.php @@ -37,7 +37,7 @@ class SimpleMatchSetCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of SimpleMatchSet. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof SimpleMatchSet) { $msg = 'SimpleMatchSetCollection objects only accept to store SimpleMatchSet collection objects.'; diff --git a/src/qtism/data/content/interactions/SliderInteraction.php b/src/qtism/data/content/interactions/SliderInteraction.php index bc84a61da..c861caa4e 100644 --- a/src/qtism/data/content/interactions/SliderInteraction.php +++ b/src/qtism/data/content/interactions/SliderInteraction.php @@ -159,7 +159,7 @@ public function __construct($responseIdentifier, $lowerBound, $upperBound, $id = * @param float $lowerBound A float value. * @throws InvalidArgumentException If $lowerBound is not a float value. */ - public function setLowerBound($lowerBound) + public function setLowerBound($lowerBound): void { if (is_float($lowerBound)) { $this->lowerBound = $lowerBound; @@ -174,7 +174,7 @@ public function setLowerBound($lowerBound) * * @return float A float value. */ - public function getLowerBound() + public function getLowerBound(): float { return $this->lowerBound; } @@ -185,7 +185,7 @@ public function getLowerBound() * @param float $upperBound A float value. * @throws InvalidArgumentException If $upperBound is not a float value. */ - public function setUpperBound($upperBound) + public function setUpperBound($upperBound): void { if (is_float($upperBound)) { $this->upperBound = $upperBound; @@ -200,7 +200,7 @@ public function setUpperBound($upperBound) * * @return float A float value. */ - public function getUpperBound() + public function getUpperBound(): float { return $this->upperBound; } @@ -212,7 +212,7 @@ public function getUpperBound() * @param int $step A positive (>= 0) integer. * @throws InvalidArgumentException If $step is not a positive integer. */ - public function setStep($step) + public function setStep($step): void { if (is_int($step) && $step >= 0) { $this->step = $step; @@ -227,7 +227,7 @@ public function setStep($step) * * @return int A positive (>= 0) integer. */ - public function getStep() + public function getStep(): int { return $this->step; } @@ -237,7 +237,7 @@ public function getStep() * * @return bool */ - public function hasStep() + public function hasStep(): bool { return $this->getStep() > 0; } @@ -248,7 +248,7 @@ public function hasStep() * @param bool $stepLabel * @throws InvalidArgumentException If $stepLabel is not a boolean value. */ - public function setStepLabel($stepLabel) + public function setStepLabel($stepLabel): void { if (is_bool($stepLabel)) { $this->stepLabel = $stepLabel; @@ -263,7 +263,7 @@ public function setStepLabel($stepLabel) * * @return bool */ - public function mustStepLabel() + public function mustStepLabel(): bool { return $this->stepLabel; } @@ -274,7 +274,7 @@ public function mustStepLabel() * @param int $orientation A value from the Orientation enumeration. * @throws InvalidArgumentException If $orientation is not a value from the Orientation enumeration. */ - public function setOrientation($orientation) + public function setOrientation($orientation): void { if (in_array($orientation, Orientation::asArray(), true)) { $this->orientation = $orientation; @@ -289,7 +289,7 @@ public function setOrientation($orientation) * * @return int A value from the Orientation enumeration. */ - public function getOrientation() + public function getOrientation(): int { return $this->orientation; } @@ -300,7 +300,7 @@ public function getOrientation() * @param bool $reverse * @throws InvalidArgumentException If $reverse is not a boolean value. */ - public function setReverse($reverse) + public function setReverse($reverse): void { if (is_bool($reverse)) { $this->reverse = $reverse; @@ -315,7 +315,7 @@ public function setReverse($reverse) * * @return bool */ - public function mustReverse() + public function mustReverse(): bool { return $this->reverse; } @@ -323,7 +323,7 @@ public function mustReverse() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return parent::getComponents(); } @@ -331,7 +331,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'sliderInteraction'; } diff --git a/src/qtism/data/content/interactions/StringInteraction.php b/src/qtism/data/content/interactions/StringInteraction.php index 7b5fd8d37..e6b7d684d 100644 --- a/src/qtism/data/content/interactions/StringInteraction.php +++ b/src/qtism/data/content/interactions/StringInteraction.php @@ -56,7 +56,7 @@ public function setBase($base); * * @return int A positive (>= 0) integer. */ - public function getBase(); + public function getBase(): int; /** * Set the stringIdentifier attribute of the StringInteraction. If $stringIdentifier is @@ -73,14 +73,14 @@ public function setStringIdentifier($stringIdentifier); * * @return string A QTI identifier or an empty string. */ - public function getStringIdentifier(); + public function getStringIdentifier(): string; /** * Whether a value for the stringIdentifier attribute is defined. * * @return bool */ - public function hasStringIdentifier(); + public function hasStringIdentifier(): bool; /** * Set the expectedLength attribute of the StringInteraction. If $expectedLength -1, @@ -97,14 +97,14 @@ public function setExpectedLength($expectedLength); * * @return int A strictly positive (> 0) integer or -1. */ - public function getExpectedLength(); + public function getExpectedLength(): int; /** * Whether a value is defined for the expectedLength attribute. * * @return bool */ - public function hasExpectedLength(); + public function hasExpectedLength(): bool; /** * Set the patternMask attribute of the StringInteraction. If $patternMask @@ -121,14 +121,14 @@ public function setPatternMask($patternMask); * * @return string An XML Schema 2 regular expression or an empty string. */ - public function getPatternMask(); + public function getPatternMask(): string; /** * Whether a value for the patternMask attribute is defined. * * @return bool */ - public function hasPatternMask(); + public function hasPatternMask(): bool; /** * Set the placeholderText attribute of the StringInteraction. If $placeholderText is @@ -152,5 +152,5 @@ public function getPlaceholderText(); * * @return bool */ - public function hasPlaceholderText(); + public function hasPlaceholderText(): bool; } diff --git a/src/qtism/data/content/interactions/TextEntryInteraction.php b/src/qtism/data/content/interactions/TextEntryInteraction.php index 96228c7df..29caf40cf 100644 --- a/src/qtism/data/content/interactions/TextEntryInteraction.php +++ b/src/qtism/data/content/interactions/TextEntryInteraction.php @@ -132,7 +132,7 @@ public function __construct($responseIdentifier, $id = '', $class = '', $lang = * @param int $base A positive (>= 0) integer. * @throws InvalidArgumentException If $base is not a positive integer. */ - public function setBase($base) + public function setBase($base): void { if (is_int($base) && $base >= 0) { $this->base = $base; @@ -148,7 +148,7 @@ public function setBase($base) * * @return int A positive (>= 0) integer. */ - public function getBase() + public function getBase(): int { return $this->base; } @@ -161,9 +161,9 @@ public function getBase() * @param string $stringIdentifier A QTI Identifier or an empty string. * @throws InvalidArgumentException If $stringIdentifier is not a valid QTIIdentifier nor an empty string. */ - public function setStringIdentifier($stringIdentifier) + public function setStringIdentifier($stringIdentifier): void { - if (Format::isIdentifier($stringIdentifier, false) === true || (is_string($stringIdentifier) && empty($stringIdentifier))) { + if (Format::isIdentifier((string)$stringIdentifier, false) === true || (is_string($stringIdentifier) && empty($stringIdentifier))) { $this->stringIdentifier = $stringIdentifier; } else { $msg = "The 'stringIdentifier' argument must be a valid QTI identifier or an empty string, '" . $stringIdentifier . "' given."; @@ -178,7 +178,7 @@ public function setStringIdentifier($stringIdentifier) * * @return string A QTI identifier or an empty string. */ - public function getStringIdentifier() + public function getStringIdentifier(): string { return $this->stringIdentifier; } @@ -188,7 +188,7 @@ public function getStringIdentifier() * * @return bool */ - public function hasStringIdentifier() + public function hasStringIdentifier(): bool { return $this->getStringIdentifier() !== ''; } @@ -200,7 +200,7 @@ public function hasStringIdentifier() * @param int|null $expectedLength A non-negative integer (>= 0) or null to unset expectedLength. * @throws InvalidArgumentException If $expectedLength is not a non-negative integer nor null. */ - public function setExpectedLength($expectedLength) + public function setExpectedLength($expectedLength): void { if ($expectedLength !== null && (!is_int($expectedLength) || $expectedLength < 0)) { $given = is_int($expectedLength) @@ -220,9 +220,9 @@ public function setExpectedLength($expectedLength) * * @return int|null A non-negative integer (>= 0) or null if undefined. */ - public function getExpectedLength() + public function getExpectedLength(): int { - return $this->expectedLength; + return $this->expectedLength ?? -1; } /** @@ -230,9 +230,9 @@ public function getExpectedLength() * * @return bool */ - public function hasExpectedLength() + public function hasExpectedLength(): bool { - return $this->getExpectedLength() !== null; + return $this->getExpectedLength() !== -1; } /** @@ -242,7 +242,7 @@ public function hasExpectedLength() * @param string $patternMask An XML Schema 2 regular expression or an empty string. * @throws InvalidArgumentException If $patternMask is not a string value. */ - public function setPatternMask($patternMask) + public function setPatternMask($patternMask): void { if (is_string($patternMask)) { $this->patternMask = $patternMask; @@ -259,7 +259,7 @@ public function setPatternMask($patternMask) * * @return string An XML Schema 2 regular expression or an empty string. */ - public function getPatternMask() + public function getPatternMask(): string { return $this->patternMask; } @@ -269,7 +269,7 @@ public function getPatternMask() * * @return bool */ - public function hasPatternMask() + public function hasPatternMask(): bool { return $this->patternMask !== ''; } @@ -281,7 +281,7 @@ public function hasPatternMask() * @param string $placeholderText A placeholder text or an empty string. * @throws InvalidArgumentException If $placeholderText is not a string value. */ - public function setPlaceholderText($placeholderText) + public function setPlaceholderText($placeholderText): void { if (is_string($placeholderText)) { $this->placeholderText = $placeholderText; @@ -297,7 +297,7 @@ public function setPlaceholderText($placeholderText) * * @return string A placeholder text or an empty string. */ - public function getPlaceholderText() + public function getPlaceholderText(): string { return $this->placeholderText; } @@ -307,7 +307,7 @@ public function getPlaceholderText() * * @return bool */ - public function hasPlaceholderText() + public function hasPlaceholderText(): bool { return $this->getPlaceholderText() !== ''; } @@ -315,7 +315,7 @@ public function hasPlaceholderText() /** * @return ResponseValidityConstraint */ - public function getResponseValidityConstraint() + public function getResponseValidityConstraint(): ResponseValidityConstraint { return new ResponseValidityConstraint($this->getResponseIdentifier(), 0, 1, $this->getPatternMask()); } @@ -323,7 +323,7 @@ public function getResponseValidityConstraint() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -331,7 +331,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'textEntryInteraction'; } diff --git a/src/qtism/data/content/interactions/TextFormat.php b/src/qtism/data/content/interactions/TextFormat.php index 22bcc31b8..0cae310a3 100644 --- a/src/qtism/data/content/interactions/TextFormat.php +++ b/src/qtism/data/content/interactions/TextFormat.php @@ -41,7 +41,7 @@ class TextFormat implements Enumeration * * @var int */ - const PLAIN = 0; + public const PLAIN = 0; /** * From IMS QTI: @@ -54,7 +54,7 @@ class TextFormat implements Enumeration * * @var int */ - const PRE_FORMATTED = 1; + public const PRE_FORMATTED = 1; /** * From IMS QTI: @@ -68,12 +68,12 @@ class TextFormat implements Enumeration * * @var int */ - const XHTML = 2; + public const XHTML = 2; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'PLAIN' => self::PLAIN, @@ -88,7 +88,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'plain': return self::PLAIN; break; diff --git a/src/qtism/data/content/interactions/UploadInteraction.php b/src/qtism/data/content/interactions/UploadInteraction.php index 327335054..de39a8582 100644 --- a/src/qtism/data/content/interactions/UploadInteraction.php +++ b/src/qtism/data/content/interactions/UploadInteraction.php @@ -68,7 +68,7 @@ public function __construct($responseIdentifier, $id = '', $class = '', $lang = * @param string $type A mime-type. * @throws InvalidArgumentException If $type is not a string value. */ - public function setType($type) + public function setType($type): void { if (is_string($type)) { $this->type = $type; @@ -83,7 +83,7 @@ public function setType($type) * * @return string A mime-type. */ - public function getType() + public function getType(): string { return $this->type; } @@ -94,7 +94,7 @@ public function getType() * * @return bool */ - public function hasType() + public function hasType(): bool { return $this->getType() !== ''; } @@ -102,7 +102,7 @@ public function hasType() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return parent::getComponents(); } @@ -110,7 +110,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'uploadInteraction'; } diff --git a/src/qtism/data/content/ssml/Sub.php b/src/qtism/data/content/ssml/Sub.php index 11c42d993..87b32aa50 100644 --- a/src/qtism/data/content/ssml/Sub.php +++ b/src/qtism/data/content/ssml/Sub.php @@ -52,12 +52,12 @@ public function __construct($xmlString) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'sub'; } - protected function buildTargetNamespace() + protected function buildTargetNamespace(): void { $this->setTargetNamespace('http://www.w3.org/2010/10/synthesis'); } diff --git a/src/qtism/data/content/xhtml/A.php b/src/qtism/data/content/xhtml/A.php index e3a93eb29..62d4b91e8 100644 --- a/src/qtism/data/content/xhtml/A.php +++ b/src/qtism/data/content/xhtml/A.php @@ -74,7 +74,7 @@ public function __construct($href, $id = '', $class = '', $lang = '', $label = ' * @param string $href A URI (Uniform Resource Identifier). * @throws InvalidArgumentException If $href is not a URI. */ - public function setHref($href) + public function setHref($href): void { if (Format::isUri($href) === true) { $this->href = $href; @@ -89,7 +89,7 @@ public function setHref($href) * * @return string A URI (Uniform Resource Identifier). */ - public function getHref() + public function getHref(): string { return $this->href; } @@ -101,7 +101,7 @@ public function getHref() * @param string $type A mime-type. * @throws InvalidArgumentException If $type is not a string value. */ - public function setType($type) + public function setType($type): void { if (is_string($type)) { $this->type = $type; @@ -117,7 +117,7 @@ public function setType($type) * * @return string A mime-type. */ - public function getType() + public function getType(): string { return $this->type; } @@ -127,7 +127,7 @@ public function getType() * * @return bool */ - public function hasType() + public function hasType(): bool { return $this->getType() !== ''; } @@ -135,7 +135,7 @@ public function hasType() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'a'; } diff --git a/src/qtism/data/content/xhtml/Img.php b/src/qtism/data/content/xhtml/Img.php index d34cea471..2154804cc 100644 --- a/src/qtism/data/content/xhtml/Img.php +++ b/src/qtism/data/content/xhtml/Img.php @@ -32,7 +32,7 @@ */ class Img extends AtomicInline { - public const QTI_CLASS_NAME_IMG='img'; + public const QTI_CLASS_NAME_IMG = 'img'; /** * The img's src attribute. @@ -122,7 +122,7 @@ public function setSrc(string $src): void * * @return string A URI. */ - public function getSrc() + public function getSrc(): string { return $this->src; } @@ -133,7 +133,7 @@ public function getSrc() * @param string $alt A string * @throws InvalidArgumentException If $alt is not a string. */ - public function setAlt($alt) + public function setAlt($alt): void { if (is_string($alt)) { $this->alt = $alt; @@ -148,7 +148,7 @@ public function setAlt($alt) * * @return string A non-empty string. */ - public function getAlt() + public function getAlt(): string { return $this->alt; } @@ -159,7 +159,7 @@ public function getAlt() * @param string $longdesc A valid URI. * @throws InvalidArgumentException If $longdesc is not a valid URI. */ - public function setLongdesc(string $longdesc) + public function setLongdesc(string $longdesc): void { if ($longdesc === '' || Format::isUri($longdesc)) { $this->longdesc = $longdesc; @@ -174,7 +174,7 @@ public function setLongdesc(string $longdesc) * * @return string A URI. */ - public function getLongdesc() + public function getLongdesc(): string { return $this->longdesc; } @@ -184,7 +184,7 @@ public function getLongdesc() * * @return bool */ - public function hasLongdesc() + public function hasLongdesc(): bool { return $this->getLongdesc() !== ''; } @@ -234,7 +234,7 @@ public function hasWidth(): bool /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'img'; } diff --git a/src/qtism/data/content/xhtml/ObjectElement.php b/src/qtism/data/content/xhtml/ObjectElement.php index 42d0ad672..b47e86d39 100644 --- a/src/qtism/data/content/xhtml/ObjectElement.php +++ b/src/qtism/data/content/xhtml/ObjectElement.php @@ -131,7 +131,7 @@ public function setData(string $data): void * * @return string A URI. */ - public function getData() + public function getData(): string { return $this->data; } @@ -142,7 +142,7 @@ public function getData() * @param string $type A mime-type. * @throws InvalidArgumentException If $type is not a valid mime-type. */ - public function setType($type) + public function setType($type): void { if (is_string($type) && empty($type) === false) { $this->type = $type; @@ -157,7 +157,7 @@ public function setType($type) * * @return string A mime-type. */ - public function getType() + public function getType(): string { return $this->type; } @@ -209,7 +209,7 @@ public function hasHeight(): bool * * @return ObjectFlowCollection|QtiComponentCollection A collection of ObjectFlow objects. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -219,7 +219,7 @@ public function getComponents() * * @param ObjectFlowCollection $content */ - public function setContent(ObjectFlowCollection $content) + public function setContent(ObjectFlowCollection $content): void { $this->content = $content; } @@ -229,7 +229,7 @@ public function setContent(ObjectFlowCollection $content) * * @return ObjectFlowCollection */ - public function getContent() + public function getContent(): ObjectFlowCollection { return $this->content; } @@ -237,7 +237,7 @@ public function getContent() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'object'; } diff --git a/src/qtism/data/content/xhtml/Param.php b/src/qtism/data/content/xhtml/Param.php index 84a093c75..d553f0d5b 100644 --- a/src/qtism/data/content/xhtml/Param.php +++ b/src/qtism/data/content/xhtml/Param.php @@ -111,7 +111,7 @@ public function __construct($name, $value, $valueType = ParamType::DATA, $type = * @param string $name A string. * @throws InvalidArgumentException If $name is not a string. */ - public function setName($name) + public function setName($name): void { if (is_string($name)) { $this->name = $name; @@ -126,7 +126,7 @@ public function setName($name) * * @return string A string. */ - public function getName() + public function getName(): string { return $this->name; } @@ -137,7 +137,7 @@ public function getName() * @param string $value A value as a string. * @throws InvalidArgumentException If $value is not a string. */ - public function setValue($value) + public function setValue($value): void { if (is_string($value)) { $this->value = $value; @@ -152,7 +152,7 @@ public function setValue($value) * * @return string A value as a string. */ - public function getValue() + public function getValue(): string { return $this->value; } @@ -163,7 +163,7 @@ public function getValue() * @param int $valueType A value from the ParamType enumeration. * @throws InvalidArgumentException If $valueType is not a value from the ParamType enumeration. */ - public function setValueType($valueType) + public function setValueType($valueType): void { if (in_array($valueType, ParamType::asArray(), true)) { $this->valueType = $valueType; @@ -178,7 +178,7 @@ public function setValueType($valueType) * * @return int A value from the ParamType enumeration. */ - public function getValueType() + public function getValueType(): int { return $this->valueType; } @@ -190,7 +190,7 @@ public function getValueType() * @param string $type A mime-type. * @throws InvalidArgumentException If the $type argument is not a string. */ - public function setType($type) + public function setType($type): void { if (is_string($type)) { $this->type = $type; @@ -206,7 +206,7 @@ public function setType($type) * * @return string A mime-type or an empty string if no type was provided. */ - public function getType() + public function getType(): string { return $this->type; } @@ -216,7 +216,7 @@ public function getType() * * @return bool */ - public function hasType() + public function hasType(): bool { return $this->getType() !== ''; } @@ -224,7 +224,7 @@ public function hasType() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -232,7 +232,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'param'; } diff --git a/src/qtism/data/content/xhtml/ParamType.php b/src/qtism/data/content/xhtml/ParamType.php index e2a1e3da5..58d47c177 100644 --- a/src/qtism/data/content/xhtml/ParamType.php +++ b/src/qtism/data/content/xhtml/ParamType.php @@ -35,19 +35,19 @@ class ParamType implements Enumeration * * @var int */ - const DATA = 0; + public const DATA = 0; /** * REF * * @var int */ - const REF = 1; + public const REF = 1; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'DATA' => self::DATA, @@ -61,7 +61,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'data': return self::DATA; break; diff --git a/src/qtism/data/content/xhtml/html5/Figcaption.php b/src/qtism/data/content/xhtml/html5/Figcaption.php index 8fcb41ac0..361c0067d 100644 --- a/src/qtism/data/content/xhtml/html5/Figcaption.php +++ b/src/qtism/data/content/xhtml/html5/Figcaption.php @@ -18,13 +18,12 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\content\xhtml\html5; use qtism\data\content\FlowStatic; use qtism\data\content\FlowTrait; use qtism\data\content\InlineCollection; +use qtism\data\QtiComponentCollection; class Figcaption extends Html5Element implements FlowStatic { @@ -49,12 +48,12 @@ public function __construct($title = null, $role = null, $id = null, $class = nu $this->setContent(new InlineCollection()); } - public function getQtiClassName() + public function getQtiClassName(): string { return self::QTI_CLASS_NAME_FIGCAPTION; } - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -64,7 +63,7 @@ public function getComponents() * * @param InlineCollection $content A collection of Flow objects. */ - public function setContent(InlineCollection $content) + public function setContent(InlineCollection $content): void { $this->content = $content; } @@ -74,7 +73,7 @@ public function setContent(InlineCollection $content) * * @return InlineCollection */ - public function getContent() + public function getContent(): InlineCollection { return $this->content; } diff --git a/src/qtism/data/content/xhtml/html5/Figure.php b/src/qtism/data/content/xhtml/html5/Figure.php index 8022ee026..09f7ad765 100644 --- a/src/qtism/data/content/xhtml/html5/Figure.php +++ b/src/qtism/data/content/xhtml/html5/Figure.php @@ -18,14 +18,13 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\content\xhtml\html5; use qtism\data\content\FlowCollection; use qtism\data\content\FlowStatic; use qtism\data\content\FlowTrait; use qtism\data\content\Inline; +use qtism\data\QtiComponentCollection; class Figure extends Html5Element implements FlowStatic, Inline { @@ -50,12 +49,12 @@ public function __construct($title = null, $role = null, $id = null, $class = nu $this->setContent(new FlowCollection()); } - public function getQtiClassName() + public function getQtiClassName(): string { return self::QTI_CLASS_NAME_FIGURE; } - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -65,7 +64,7 @@ public function getComponents() * * @param FlowCollection $content A collection of Flow objects. */ - public function setContent(FlowCollection $content) + public function setContent(FlowCollection $content): void { $this->content = $content; } @@ -75,7 +74,7 @@ public function setContent(FlowCollection $content) * * @return FlowCollection */ - public function getContent() + public function getContent(): FlowCollection { return $this->content; } diff --git a/src/qtism/data/content/xhtml/html5/Rb.php b/src/qtism/data/content/xhtml/html5/Rb.php index d24397ec0..10d0300a2 100644 --- a/src/qtism/data/content/xhtml/html5/Rb.php +++ b/src/qtism/data/content/xhtml/html5/Rb.php @@ -18,13 +18,12 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\content\xhtml\html5; use qtism\data\content\FlowStatic; use qtism\data\content\FlowTrait; use qtism\data\content\InlineCollection; +use qtism\data\QtiComponentCollection; class Rb extends Html5Element implements FlowStatic { @@ -49,12 +48,12 @@ public function __construct($title = null, $role = null, $id = null, $class = nu $this->setContent(new InlineCollection()); } - public function getQtiClassName() + public function getQtiClassName(): string { return self::QTI_CLASS_NAME; } - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -64,7 +63,7 @@ public function getComponents() * * @param InlineCollection $content A collection of Flow objects. */ - public function setContent(InlineCollection $content) + public function setContent(InlineCollection $content): void { $this->content = $content; } @@ -74,7 +73,7 @@ public function setContent(InlineCollection $content) * * @return InlineCollection */ - public function getContent() + public function getContent(): InlineCollection { return $this->content; } diff --git a/src/qtism/data/content/xhtml/html5/Rp.php b/src/qtism/data/content/xhtml/html5/Rp.php index 06e4b5220..af84326ae 100644 --- a/src/qtism/data/content/xhtml/html5/Rp.php +++ b/src/qtism/data/content/xhtml/html5/Rp.php @@ -18,13 +18,12 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\content\xhtml\html5; use qtism\data\content\FlowStatic; use qtism\data\content\FlowTrait; use qtism\data\content\InlineCollection; +use qtism\data\QtiComponentCollection; class Rp extends Html5Element implements FlowStatic { @@ -49,12 +48,12 @@ public function __construct($title = null, $role = null, $id = null, $class = nu $this->setContent(new InlineCollection()); } - public function getQtiClassName() + public function getQtiClassName(): string { return self::QTI_CLASS_NAME; } - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -64,7 +63,7 @@ public function getComponents() * * @param InlineCollection $content A collection of Flow objects. */ - public function setContent(InlineCollection $content) + public function setContent(InlineCollection $content): void { $this->content = $content; } @@ -74,7 +73,7 @@ public function setContent(InlineCollection $content) * * @return InlineCollection */ - public function getContent() + public function getContent(): InlineCollection { return $this->content; } diff --git a/src/qtism/data/content/xhtml/html5/Rt.php b/src/qtism/data/content/xhtml/html5/Rt.php index 58772cfed..0ce121d63 100644 --- a/src/qtism/data/content/xhtml/html5/Rt.php +++ b/src/qtism/data/content/xhtml/html5/Rt.php @@ -18,13 +18,12 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\content\xhtml\html5; use qtism\data\content\FlowStatic; use qtism\data\content\FlowTrait; use qtism\data\content\InlineCollection; +use qtism\data\QtiComponentCollection; class Rt extends Html5Element implements FlowStatic { @@ -49,12 +48,12 @@ public function __construct($title = null, $role = null, $id = null, $class = nu $this->setContent(new InlineCollection()); } - public function getQtiClassName() + public function getQtiClassName(): string { return self::QTI_CLASS_NAME; } - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -64,7 +63,7 @@ public function getComponents() * * @param InlineCollection $content A collection of Flow objects. */ - public function setContent(InlineCollection $content) + public function setContent(InlineCollection $content): void { $this->content = $content; } @@ -74,7 +73,7 @@ public function setContent(InlineCollection $content) * * @return InlineCollection */ - public function getContent() + public function getContent(): InlineCollection { return $this->content; } diff --git a/src/qtism/data/content/xhtml/html5/Ruby.php b/src/qtism/data/content/xhtml/html5/Ruby.php index 8c2119835..e4f8320d2 100644 --- a/src/qtism/data/content/xhtml/html5/Ruby.php +++ b/src/qtism/data/content/xhtml/html5/Ruby.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\content\xhtml\html5; use qtism\data\content\FlowCollection; @@ -28,6 +26,7 @@ use qtism\data\content\Inline; use qtism\data\content\InlineStatic; use qtism\data\content\TextOrVariable; +use qtism\data\QtiComponentCollection; class Ruby extends Html5Element implements FlowStatic, Inline, TextOrVariable, InlineStatic { @@ -52,12 +51,12 @@ public function __construct($title = null, $role = null, $id = null, $class = nu $this->setContent(new FlowCollection()); } - public function getQtiClassName() + public function getQtiClassName(): string { return self::QTI_CLASS_NAME; } - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -67,7 +66,7 @@ public function getComponents() * * @param FlowCollection $content A collection of Flow objects. */ - public function setContent(FlowCollection $content) + public function setContent(FlowCollection $content): void { $this->content = $content; } @@ -77,7 +76,7 @@ public function setContent(FlowCollection $content) * * @return FlowCollection */ - public function getContent() + public function getContent(): FlowCollection { return $this->content; } diff --git a/src/qtism/data/content/xhtml/lists/Dd.php b/src/qtism/data/content/xhtml/lists/Dd.php index 6c9e16f51..8002ad966 100644 --- a/src/qtism/data/content/xhtml/lists/Dd.php +++ b/src/qtism/data/content/xhtml/lists/Dd.php @@ -59,7 +59,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @param FlowCollection $content A collection of Flow objects. */ - public function setContent(FlowCollection $content) + public function setContent(FlowCollection $content): void { $this->content = $content; } @@ -69,7 +69,7 @@ public function setContent(FlowCollection $content) * * @return FlowCollection */ - public function getContent() + public function getContent(): FlowCollection { return $this->content; } @@ -79,7 +79,7 @@ public function getContent() * * @return FlowCollection A collection of Flow objects. */ - public function getComponents() + public function getComponents(): FlowCollection { return $this->getContent(); } @@ -87,7 +87,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'dd'; } diff --git a/src/qtism/data/content/xhtml/lists/Dl.php b/src/qtism/data/content/xhtml/lists/Dl.php index d28856929..c2682d775 100644 --- a/src/qtism/data/content/xhtml/lists/Dl.php +++ b/src/qtism/data/content/xhtml/lists/Dl.php @@ -71,7 +71,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @param DlElementCollection $content A collection of DlElement objects. */ - public function setContent(DlElementCollection $content) + public function setContent(DlElementCollection $content): void { $this->content = $content; } @@ -81,7 +81,7 @@ public function setContent(DlElementCollection $content) * * @return DlElementCollection */ - public function getContent() + public function getContent(): DlElementCollection { return $this->content; } @@ -91,7 +91,7 @@ public function getContent() * * @return QtiComponentCollection A collection of DlElement objects. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -99,7 +99,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'dl'; } @@ -110,7 +110,7 @@ public function getQtiClassName() * @param string $xmlBase A URI. * @throws InvalidArgumentException if $base is not a valid URI nor an empty string. */ - public function setXmlBase($xmlBase = '') + public function setXmlBase($xmlBase = ''): void { if (is_string($xmlBase) && (empty($xmlBase) || Format::isUri($xmlBase))) { $this->xmlBase = $xmlBase; @@ -125,7 +125,7 @@ public function setXmlBase($xmlBase = '') * * @return string An empty string or a URI. */ - public function getXmlBase() + public function getXmlBase(): string { return $this->xmlBase; } @@ -133,7 +133,7 @@ public function getXmlBase() /** * @return bool */ - public function hasXmlBase() + public function hasXmlBase(): bool { return $this->getXmlBase() !== ''; } diff --git a/src/qtism/data/content/xhtml/lists/DlElementCollection.php b/src/qtism/data/content/xhtml/lists/DlElementCollection.php index 51a12c1cb..391194db2 100644 --- a/src/qtism/data/content/xhtml/lists/DlElementCollection.php +++ b/src/qtism/data/content/xhtml/lists/DlElementCollection.php @@ -38,7 +38,7 @@ class DlElementCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of DlElement. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof DlElement) { $msg = 'DlElementCollection objects only accept to store DlElement objects.'; diff --git a/src/qtism/data/content/xhtml/lists/Dt.php b/src/qtism/data/content/xhtml/lists/Dt.php index a51b4b253..3a45eecfb 100644 --- a/src/qtism/data/content/xhtml/lists/Dt.php +++ b/src/qtism/data/content/xhtml/lists/Dt.php @@ -60,7 +60,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @param InlineCollection $content A collection of Inline objects. */ - public function setContent(InlineCollection $content) + public function setContent(InlineCollection $content): void { $this->content = $content; } @@ -70,7 +70,7 @@ public function setContent(InlineCollection $content) * * @return InlineCollection */ - public function getContent() + public function getContent(): InlineCollection { return $this->content; } @@ -80,7 +80,7 @@ public function getContent() * * @return QtiComponentCollection The Inline objects composing the Dt. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -88,7 +88,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'dt'; } diff --git a/src/qtism/data/content/xhtml/lists/Li.php b/src/qtism/data/content/xhtml/lists/Li.php index 205906e7a..514480af5 100644 --- a/src/qtism/data/content/xhtml/lists/Li.php +++ b/src/qtism/data/content/xhtml/lists/Li.php @@ -60,7 +60,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @return FlowCollection A collection of Flow objects. */ - public function getComponents() + public function getComponents(): FlowCollection { return $this->getContent(); } @@ -70,7 +70,7 @@ public function getComponents() * * @param FlowCollection $content */ - public function setContent(FlowCollection $content) + public function setContent(FlowCollection $content): void { $this->content = $content; } @@ -80,7 +80,7 @@ public function setContent(FlowCollection $content) * * @return FlowCollection */ - public function getContent() + public function getContent(): FlowCollection { return $this->content; } @@ -88,7 +88,7 @@ public function getContent() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'li'; } diff --git a/src/qtism/data/content/xhtml/lists/LiCollection.php b/src/qtism/data/content/xhtml/lists/LiCollection.php index e88baeb02..8c6d2bfc9 100644 --- a/src/qtism/data/content/xhtml/lists/LiCollection.php +++ b/src/qtism/data/content/xhtml/lists/LiCollection.php @@ -38,7 +38,7 @@ class LiCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of Li. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Li) { $msg = 'LiCollection objects only accept to store Li objects.'; diff --git a/src/qtism/data/content/xhtml/lists/Ol.php b/src/qtism/data/content/xhtml/lists/Ol.php index 1dddef0f8..f720719b0 100644 --- a/src/qtism/data/content/xhtml/lists/Ol.php +++ b/src/qtism/data/content/xhtml/lists/Ol.php @@ -71,7 +71,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @param LiCollection $content A collection of Li objects. */ - public function setContent(LiCollection $content) + public function setContent(LiCollection $content): void { $this->content = $content; } @@ -81,7 +81,7 @@ public function setContent(LiCollection $content) * * @return LiCollection */ - public function getContent() + public function getContent(): LiCollection { return $this->content; } @@ -91,7 +91,7 @@ public function getContent() * * @return QtiComponentCollection A collection of Li objects. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -102,7 +102,7 @@ public function getComponents() * @param string $xmlBase A URI. * @throws InvalidArgumentException if $base is not a valid URI nor an empty string. */ - public function setXmlBase($xmlBase = '') + public function setXmlBase($xmlBase = ''): void { if (is_string($xmlBase) && (empty($xmlBase) || Format::isUri($xmlBase))) { $this->xmlBase = $xmlBase; @@ -117,7 +117,7 @@ public function setXmlBase($xmlBase = '') * * @return string An empty string or a URI. */ - public function getXmlBase() + public function getXmlBase(): string { return $this->xmlBase; } @@ -125,7 +125,7 @@ public function getXmlBase() /** * @return bool */ - public function hasXmlBase() + public function hasXmlBase(): bool { return $this->getXmlBase() !== ''; } @@ -133,7 +133,7 @@ public function hasXmlBase() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'ol'; } diff --git a/src/qtism/data/content/xhtml/lists/Ul.php b/src/qtism/data/content/xhtml/lists/Ul.php index 26b98b5e8..ea8f10384 100644 --- a/src/qtism/data/content/xhtml/lists/Ul.php +++ b/src/qtism/data/content/xhtml/lists/Ul.php @@ -70,7 +70,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @param LiCollection $content A collection of Li objects. */ - public function setContent(LiCollection $content) + public function setContent(LiCollection $content): void { $this->content = $content; } @@ -80,7 +80,7 @@ public function setContent(LiCollection $content) * * @return LiCollection */ - public function getContent() + public function getContent(): LiCollection { return $this->content; } @@ -90,7 +90,7 @@ public function getContent() * * @return LiCollection A collection of Li objects. */ - public function getComponents() + public function getComponents(): LiCollection { return $this->getContent(); } @@ -101,7 +101,7 @@ public function getComponents() * @param string $xmlBase A URI. * @throws InvalidArgumentException if $base is not a valid URI nor an empty string. */ - public function setXmlBase($xmlBase = '') + public function setXmlBase($xmlBase = ''): void { if (is_string($xmlBase) && (empty($xmlBase) || Format::isUri($xmlBase))) { $this->xmlBase = $xmlBase; @@ -116,7 +116,7 @@ public function setXmlBase($xmlBase = '') * * @return string An empty string or a URI. */ - public function getXmlBase() + public function getXmlBase(): string { return $this->xmlBase; } @@ -124,7 +124,7 @@ public function getXmlBase() /** * @return bool */ - public function hasXmlBase() + public function hasXmlBase(): bool { return $this->getXmlBase() !== ''; } @@ -132,7 +132,7 @@ public function hasXmlBase() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'ul'; } diff --git a/src/qtism/data/content/xhtml/presentation/B.php b/src/qtism/data/content/xhtml/presentation/B.php index 38b676ab4..43be18d04 100644 --- a/src/qtism/data/content/xhtml/presentation/B.php +++ b/src/qtism/data/content/xhtml/presentation/B.php @@ -48,7 +48,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'b'; } diff --git a/src/qtism/data/content/xhtml/presentation/Big.php b/src/qtism/data/content/xhtml/presentation/Big.php index 341db879d..8b5ebd4a8 100644 --- a/src/qtism/data/content/xhtml/presentation/Big.php +++ b/src/qtism/data/content/xhtml/presentation/Big.php @@ -48,7 +48,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'big'; } diff --git a/src/qtism/data/content/xhtml/presentation/Hr.php b/src/qtism/data/content/xhtml/presentation/Hr.php index f7a299ffd..ec5b5465c 100644 --- a/src/qtism/data/content/xhtml/presentation/Hr.php +++ b/src/qtism/data/content/xhtml/presentation/Hr.php @@ -63,7 +63,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * @param string $xmlBase A URI. * @throws InvalidArgumentException if $base is not a valid URI nor an empty string. */ - public function setXmlBase($xmlBase = '') + public function setXmlBase($xmlBase = ''): void { if (is_string($xmlBase) && (empty($xmlBase) || Format::isUri($xmlBase))) { $this->xmlBase = $xmlBase; @@ -78,7 +78,7 @@ public function setXmlBase($xmlBase = '') * * @return string An empty string or a URI. */ - public function getXmlBase() + public function getXmlBase(): string { return $this->xmlBase; } @@ -86,7 +86,7 @@ public function getXmlBase() /** * @return bool */ - public function hasXmlBase() + public function hasXmlBase(): bool { return $this->getXmlBase() !== ''; } @@ -94,7 +94,7 @@ public function hasXmlBase() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -102,7 +102,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'hr'; } diff --git a/src/qtism/data/content/xhtml/presentation/I.php b/src/qtism/data/content/xhtml/presentation/I.php index a63bd11e2..2e12d37b9 100644 --- a/src/qtism/data/content/xhtml/presentation/I.php +++ b/src/qtism/data/content/xhtml/presentation/I.php @@ -48,7 +48,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'i'; } diff --git a/src/qtism/data/content/xhtml/presentation/Small.php b/src/qtism/data/content/xhtml/presentation/Small.php index 445d164e5..91a56b243 100644 --- a/src/qtism/data/content/xhtml/presentation/Small.php +++ b/src/qtism/data/content/xhtml/presentation/Small.php @@ -48,7 +48,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'small'; } diff --git a/src/qtism/data/content/xhtml/presentation/Sub.php b/src/qtism/data/content/xhtml/presentation/Sub.php index bc39d246f..de1dea33a 100644 --- a/src/qtism/data/content/xhtml/presentation/Sub.php +++ b/src/qtism/data/content/xhtml/presentation/Sub.php @@ -48,7 +48,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'sub'; } diff --git a/src/qtism/data/content/xhtml/presentation/Sup.php b/src/qtism/data/content/xhtml/presentation/Sup.php index 361e5cef9..7260c7b0c 100644 --- a/src/qtism/data/content/xhtml/presentation/Sup.php +++ b/src/qtism/data/content/xhtml/presentation/Sup.php @@ -48,7 +48,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'sup'; } diff --git a/src/qtism/data/content/xhtml/presentation/Tt.php b/src/qtism/data/content/xhtml/presentation/Tt.php index b9f3daf8f..3ed51bb2d 100644 --- a/src/qtism/data/content/xhtml/presentation/Tt.php +++ b/src/qtism/data/content/xhtml/presentation/Tt.php @@ -48,7 +48,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'tt'; } diff --git a/src/qtism/data/content/xhtml/tables/Caption.php b/src/qtism/data/content/xhtml/tables/Caption.php index d4ae16d31..b63408548 100644 --- a/src/qtism/data/content/xhtml/tables/Caption.php +++ b/src/qtism/data/content/xhtml/tables/Caption.php @@ -60,7 +60,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @return InlineCollection A collection of Inline objects. */ - public function getComponents() + public function getComponents(): InlineCollection { return $this->getContent(); } @@ -70,7 +70,7 @@ public function getComponents() * * @param InlineCollection $content A collection of Inline objects. */ - public function setContent(InlineCollection $content) + public function setContent(InlineCollection $content): void { $this->content = $content; } @@ -80,7 +80,7 @@ public function setContent(InlineCollection $content) * * @return InlineCollection */ - public function getContent() + public function getContent(): InlineCollection { return $this->content; } @@ -88,7 +88,7 @@ public function getContent() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'caption'; } diff --git a/src/qtism/data/content/xhtml/tables/Col.php b/src/qtism/data/content/xhtml/tables/Col.php index 09dd2bb1e..d2e9106d7 100644 --- a/src/qtism/data/content/xhtml/tables/Col.php +++ b/src/qtism/data/content/xhtml/tables/Col.php @@ -61,7 +61,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * @param int $span A strictly positive integer. * @throws InvalidArgumentException If $span is not a positive integer. */ - public function setSpan($span) + public function setSpan($span): void { if (is_int($span) && $span > 0) { $this->span = $span; @@ -76,7 +76,7 @@ public function setSpan($span) * * @return int A strictly positive integer. */ - public function getSpan() + public function getSpan(): int { return $this->span; } @@ -84,7 +84,7 @@ public function getSpan() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -92,7 +92,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'col'; } diff --git a/src/qtism/data/content/xhtml/tables/ColCollection.php b/src/qtism/data/content/xhtml/tables/ColCollection.php index baccfec83..508e65704 100644 --- a/src/qtism/data/content/xhtml/tables/ColCollection.php +++ b/src/qtism/data/content/xhtml/tables/ColCollection.php @@ -38,7 +38,7 @@ class ColCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of Col. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Col) { $msg = 'ColCollection objects only accept to store Col objects.'; diff --git a/src/qtism/data/content/xhtml/tables/Colgroup.php b/src/qtism/data/content/xhtml/tables/Colgroup.php index c88405316..0550c44e5 100644 --- a/src/qtism/data/content/xhtml/tables/Colgroup.php +++ b/src/qtism/data/content/xhtml/tables/Colgroup.php @@ -71,7 +71,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * @param int $span A strictly positive (> 0) integer. * @throws InvalidArgumentException If $span is not a strictly positive integer. */ - public function setSpan($span) + public function setSpan($span): void { if (is_int($span) && $span > 0) { $this->span = $span; @@ -86,7 +86,7 @@ public function setSpan($span) * * @return int A strictly positive (> 0) integer. */ - public function getSpan() + public function getSpan(): int { return $this->span; } @@ -94,7 +94,7 @@ public function getSpan() /** * @return ColCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -104,7 +104,7 @@ public function getComponents() * * @param ColCollection $content A collection of Col objects. */ - public function setContent(ColCollection $content) + public function setContent(ColCollection $content): void { $this->content = $content; } @@ -114,7 +114,7 @@ public function setContent(ColCollection $content) * * @return ColCollection */ - public function getContent() + public function getContent(): ColCollection { return $this->content; } @@ -122,7 +122,7 @@ public function getContent() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'colgroup'; } diff --git a/src/qtism/data/content/xhtml/tables/ColgroupCollection.php b/src/qtism/data/content/xhtml/tables/ColgroupCollection.php index 8b570fdcc..c5ed145d9 100644 --- a/src/qtism/data/content/xhtml/tables/ColgroupCollection.php +++ b/src/qtism/data/content/xhtml/tables/ColgroupCollection.php @@ -38,7 +38,7 @@ class ColgroupCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of $value. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Colgroup) { $msg = 'ColgroupCollection objects only accept to store Colgroup objects'; diff --git a/src/qtism/data/content/xhtml/tables/Table.php b/src/qtism/data/content/xhtml/tables/Table.php index 13b7ad2c0..31d60fc2d 100644 --- a/src/qtism/data/content/xhtml/tables/Table.php +++ b/src/qtism/data/content/xhtml/tables/Table.php @@ -122,7 +122,7 @@ public function __construct(TbodyCollection $tbodies, $id = '', $class = '', $la * @param string $summary * @throws InvalidArgumentException If $summary is not a string. */ - public function setSummary($summary) + public function setSummary($summary): void { if (is_string($summary)) { $this->summary = $summary; @@ -138,7 +138,7 @@ public function setSummary($summary) * * @return string */ - public function getSummary() + public function getSummary(): string { return $this->summary; } @@ -148,7 +148,7 @@ public function getSummary() * * @return bool */ - public function hasSummary() + public function hasSummary(): bool { return $this->getSummary() !== ''; } @@ -159,7 +159,7 @@ public function hasSummary() * * @param Caption $caption A Caption object or null. */ - public function setCaption(Caption $caption = null) + public function setCaption(Caption $caption = null): void { $this->caption = $caption; } @@ -170,7 +170,7 @@ public function setCaption(Caption $caption = null) * * @return Caption|null A Caption object or null. */ - public function getCaption() + public function getCaption(): ?Caption { return $this->caption; } @@ -180,7 +180,7 @@ public function getCaption() * * @return bool */ - public function hasCaption() + public function hasCaption(): bool { return $this->getCaption() !== null; } @@ -190,7 +190,7 @@ public function hasCaption() * * @param ColCollection $cols A collection of Col objects. */ - public function setCols(ColCollection $cols) + public function setCols(ColCollection $cols): void { $this->cols = $cols; } @@ -200,7 +200,7 @@ public function setCols(ColCollection $cols) * * @return ColCollection A collection of Col objects. */ - public function getCols() + public function getCols(): ColCollection { return $this->cols; } @@ -210,7 +210,7 @@ public function getCols() * * @param ColgroupCollection $colgroups A collection of Colgroup objects. */ - public function setColgroups(ColgroupCollection $colgroups) + public function setColgroups(ColgroupCollection $colgroups): void { $this->colgroups = $colgroups; } @@ -220,7 +220,7 @@ public function setColgroups(ColgroupCollection $colgroups) * * @return ColgroupCollection A collection of Colgroup objects. */ - public function getColgroups() + public function getColgroups(): ColgroupCollection { return $this->colgroups; } @@ -231,7 +231,7 @@ public function getColgroups() * * @param Thead $thead A Thead object or null. */ - public function setThead(Thead $thead = null) + public function setThead(Thead $thead = null): void { $this->thead = $thead; } @@ -239,9 +239,9 @@ public function setThead(Thead $thead = null) /** * Get the Thead object. A null value means there is no Thead. * - * @return Thead A Thead object or null. + * @return Thead|null A Thead object or null. */ - public function getThead() + public function getThead(): ?Thead { return $this->thead; } @@ -251,7 +251,7 @@ public function getThead() * * @return bool */ - public function hasThead() + public function hasThead(): bool { return $this->getThead() !== null; } @@ -261,7 +261,7 @@ public function hasThead() * * @param Tfoot $tfoot */ - public function setTfoot(Tfoot $tfoot) + public function setTfoot(Tfoot $tfoot): void { $this->tfoot = $tfoot; } @@ -270,9 +270,9 @@ public function setTfoot(Tfoot $tfoot) * Get the Tfoot object of the Table. A null value means there is no * Tfoot. * - * @return Tfoot A Tfoot object or null. + * @return Tfoot|null A Tfoot object or null. */ - public function getTfoot() + public function getTfoot(): ?Tfoot { return $this->tfoot; } @@ -282,7 +282,7 @@ public function getTfoot() * * @return bool */ - public function hasTfoot() + public function hasTfoot(): bool { return $this->getTfoot() !== null; } @@ -292,7 +292,7 @@ public function hasTfoot() * * @param TbodyCollection $tbodies A collection of Tbody objects. */ - public function setTbodies(TbodyCollection $tbodies) + public function setTbodies(TbodyCollection $tbodies): void { $this->tbodies = $tbodies; } @@ -302,7 +302,7 @@ public function setTbodies(TbodyCollection $tbodies) * * @return TbodyCollection A collection of Tbody objects. */ - public function getTbodies() + public function getTbodies(): TbodyCollection { return $this->tbodies; } @@ -310,7 +310,7 @@ public function getTbodies() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $array = []; @@ -336,7 +336,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'table'; } diff --git a/src/qtism/data/content/xhtml/tables/TableCell.php b/src/qtism/data/content/xhtml/tables/TableCell.php index 3dcb93138..362ea3574 100644 --- a/src/qtism/data/content/xhtml/tables/TableCell.php +++ b/src/qtism/data/content/xhtml/tables/TableCell.php @@ -118,7 +118,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @param IdentifierCollection $headers A collection of QTI identifiers. */ - public function setHeaders(IdentifierCollection $headers) + public function setHeaders(IdentifierCollection $headers): void { $this->headers = $headers; } @@ -128,7 +128,7 @@ public function setHeaders(IdentifierCollection $headers) * * @return IdentifierCollection A collection of QTI identifiers. */ - public function getHeaders() + public function getHeaders(): IdentifierCollection { return $this->headers; } @@ -138,7 +138,7 @@ public function getHeaders() * * @return bool */ - public function hasHeaders() + public function hasHeaders(): bool { return count($this->getHeaders()) > 0; } @@ -149,7 +149,7 @@ public function hasHeaders() * @param int $scope A value from the TableCellScope enumeration or -1 if no scope is defined. * @throws InvalidArgumentException If $scope is not a value from the TableCellScope enumeration nor -1. */ - public function setScope($scope) + public function setScope($scope): void { if (in_array($scope, TableCellScope::asArray(), true) || $scope === -1) { $this->scope = $scope; @@ -164,7 +164,7 @@ public function setScope($scope) * * @return int A value from the TableCellScope enumeration or -1 if no scope is defined. */ - public function getScope() + public function getScope(): int { return $this->scope; } @@ -174,7 +174,7 @@ public function getScope() * * @return bool */ - public function hasScope() + public function hasScope(): bool { return $this->getScope() !== -1; } @@ -185,7 +185,7 @@ public function hasScope() * @param string $abbr A string or an empty string if no abbr is defined. * @throws InvalidArgumentException If $bbr is not a string. */ - public function setAbbr($abbr) + public function setAbbr($abbr): void { if (is_string($abbr)) { $this->abbr = $abbr; @@ -200,7 +200,7 @@ public function setAbbr($abbr) * * @return string A string or an empty string if no abbr is defined. */ - public function getAbbr() + public function getAbbr(): string { return $this->abbr; } @@ -210,7 +210,7 @@ public function getAbbr() * * @return bool */ - public function hasAbbr() + public function hasAbbr(): bool { return $this->getAbbr() !== ''; } @@ -221,7 +221,7 @@ public function hasAbbr() * @param string $axis A string. Give an empty string if no axis is indicated. * @throws InvalidArgumentException If $axis is not a string. */ - public function setAxis($axis) + public function setAxis($axis): void { if (is_string($axis)) { $this->axis = $axis; @@ -236,7 +236,7 @@ public function setAxis($axis) * * @return string A string. The string is empty if no axis is defined. */ - public function getAxis() + public function getAxis(): string { return $this->axis; } @@ -246,7 +246,7 @@ public function getAxis() * * @return bool */ - public function hasAxis() + public function hasAxis(): bool { return $this->getAxis() !== ''; } @@ -258,7 +258,7 @@ public function hasAxis() * @param int $rowspan * @throws InvalidArgumentException If $rowspan is not an integer. */ - public function setRowspan($rowspan) + public function setRowspan($rowspan): void { if (is_int($rowspan)) { $this->rowspan = $rowspan; @@ -274,7 +274,7 @@ public function setRowspan($rowspan) * * @return int */ - public function getRowspan() + public function getRowspan(): int { return $this->rowspan; } @@ -284,7 +284,7 @@ public function getRowspan() * * @return bool */ - public function hasRowspan() + public function hasRowspan(): bool { return $this->getRowspan() >= 0; } @@ -296,7 +296,7 @@ public function hasRowspan() * @param int $colspan An integer. * @throws InvalidArgumentException If $colspan is not an integer. */ - public function setColspan($colspan) + public function setColspan($colspan): void { if (is_int($colspan)) { $this->colspan = $colspan; @@ -312,7 +312,7 @@ public function setColspan($colspan) * * @return int */ - public function getColspan() + public function getColspan(): int { return $this->colspan; } @@ -322,7 +322,7 @@ public function getColspan() * * @return bool */ - public function hasColspan() + public function hasColspan(): bool { return $this->getColspan() >= 0; } @@ -332,7 +332,7 @@ public function hasColspan() * * @param FlowCollection $content A collection of Flow objects. */ - public function setContent(FlowCollection $content) + public function setContent(FlowCollection $content): void { $this->content = $content; } @@ -342,7 +342,7 @@ public function setContent(FlowCollection $content) * * @return FlowCollection */ - public function getContent() + public function getContent(): FlowCollection { return $this->content; } @@ -350,7 +350,7 @@ public function getContent() /** * @return FlowCollection */ - public function getComponents() + public function getComponents(): FlowCollection { return $this->getContent(); } diff --git a/src/qtism/data/content/xhtml/tables/TableCellCollection.php b/src/qtism/data/content/xhtml/tables/TableCellCollection.php index 832055e71..502473001 100644 --- a/src/qtism/data/content/xhtml/tables/TableCellCollection.php +++ b/src/qtism/data/content/xhtml/tables/TableCellCollection.php @@ -38,7 +38,7 @@ class TableCellCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of TableCell. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof TableCell) { $msg = 'TableCellCollection objects only accept to store TableCell objects.'; diff --git a/src/qtism/data/content/xhtml/tables/TableCellScope.php b/src/qtism/data/content/xhtml/tables/TableCellScope.php index faf9f233e..aa099e33d 100644 --- a/src/qtism/data/content/xhtml/tables/TableCellScope.php +++ b/src/qtism/data/content/xhtml/tables/TableCellScope.php @@ -33,27 +33,27 @@ class TableCellScope implements Enumeration /** * @var int */ - const ROW = 0; + public const ROW = 0; /** * @var int */ - const COL = 1; + public const COL = 1; /** * @var int */ - const ROWGROUP = 2; + public const ROWGROUP = 2; /** * @var int */ - const COLGROUP = 3; + public const COLGROUP = 3; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'ROW' => self::ROW, @@ -69,7 +69,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'row': return self::ROW; break; diff --git a/src/qtism/data/content/xhtml/tables/Tbody.php b/src/qtism/data/content/xhtml/tables/Tbody.php index d5db46e74..9c0633ac9 100644 --- a/src/qtism/data/content/xhtml/tables/Tbody.php +++ b/src/qtism/data/content/xhtml/tables/Tbody.php @@ -62,7 +62,7 @@ public function __construct(TrCollection $content, $id = '', $class = '', $lang * @param TrCollection $content A non-empty TrCollection object. * @throws InvalidArgumentException If $components is empty. */ - public function setContent(TrCollection $content) + public function setContent(TrCollection $content): void { if (count($content) > 0) { $this->content = $content; @@ -77,7 +77,7 @@ public function setContent(TrCollection $content) * * @return TrCollection */ - public function getContent() + public function getContent(): TrCollection { return $this->content; } @@ -85,7 +85,7 @@ public function getContent() /** * @return TrCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -93,7 +93,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'tbody'; } diff --git a/src/qtism/data/content/xhtml/tables/TbodyCollection.php b/src/qtism/data/content/xhtml/tables/TbodyCollection.php index 3609e7abd..2721b9815 100644 --- a/src/qtism/data/content/xhtml/tables/TbodyCollection.php +++ b/src/qtism/data/content/xhtml/tables/TbodyCollection.php @@ -38,7 +38,7 @@ class TbodyCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException if $value is not an instance of Tbody. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Tbody) { $msg = 'TbodyCollection objects only accept to store Tbody objects.'; diff --git a/src/qtism/data/content/xhtml/tables/Td.php b/src/qtism/data/content/xhtml/tables/Td.php index 74c57b7c7..4590ddc7c 100644 --- a/src/qtism/data/content/xhtml/tables/Td.php +++ b/src/qtism/data/content/xhtml/tables/Td.php @@ -31,7 +31,7 @@ class Td extends TableCell /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'td'; } diff --git a/src/qtism/data/content/xhtml/tables/Tfoot.php b/src/qtism/data/content/xhtml/tables/Tfoot.php index 271545c72..a4419a430 100644 --- a/src/qtism/data/content/xhtml/tables/Tfoot.php +++ b/src/qtism/data/content/xhtml/tables/Tfoot.php @@ -62,7 +62,7 @@ public function __construct(TrCollection $content, $id = '', $class = '', $lang * @param TrCollection $content A collection of Tfoot object. * @throws InvalidArgumentException If $content is empty. */ - public function setContent(TrCollection $content) + public function setContent(TrCollection $content): void { if (count($content) > 0) { $this->content = $content; @@ -77,7 +77,7 @@ public function setContent(TrCollection $content) * * @return TrCollection */ - public function getContent() + public function getContent(): TrCollection { return $this->content; } @@ -85,7 +85,7 @@ public function getContent() /** * @return TrCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -93,7 +93,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'tfoot'; } diff --git a/src/qtism/data/content/xhtml/tables/Th.php b/src/qtism/data/content/xhtml/tables/Th.php index d5daac5f0..3572a5425 100644 --- a/src/qtism/data/content/xhtml/tables/Th.php +++ b/src/qtism/data/content/xhtml/tables/Th.php @@ -47,7 +47,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'th'; } diff --git a/src/qtism/data/content/xhtml/tables/Thead.php b/src/qtism/data/content/xhtml/tables/Thead.php index 1cf24edbd..068d49b83 100644 --- a/src/qtism/data/content/xhtml/tables/Thead.php +++ b/src/qtism/data/content/xhtml/tables/Thead.php @@ -62,7 +62,7 @@ public function __construct(TrCollection $content, $id = '', $class = '', $lang * @param TrCollection $content A collection of Tr objects. * @throws InvalidArgumentException If $content is empty. */ - public function setContent(TrCollection $content) + public function setContent(TrCollection $content): void { if (count($content) > 0) { $this->content = $content; @@ -77,7 +77,7 @@ public function setContent(TrCollection $content) * * @return TrCollection */ - public function getContent() + public function getContent(): TrCollection { return $this->content; } @@ -85,7 +85,7 @@ public function getContent() /** * @return TrCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -93,7 +93,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'thead'; } diff --git a/src/qtism/data/content/xhtml/tables/Tr.php b/src/qtism/data/content/xhtml/tables/Tr.php index 4abafe722..a27b4c5bf 100644 --- a/src/qtism/data/content/xhtml/tables/Tr.php +++ b/src/qtism/data/content/xhtml/tables/Tr.php @@ -59,7 +59,7 @@ public function __construct(TableCellCollection $content, $id = '', $class = '', /** * @return TableCellCollection|QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getContent(); } @@ -69,7 +69,7 @@ public function getComponents() * * @param TableCellCollection $content A collection of TableCell objects. */ - public function setContent(TableCellCollection $content) + public function setContent(TableCellCollection $content): void { $this->content = $content; } @@ -79,7 +79,7 @@ public function setContent(TableCellCollection $content) * * @return TableCellCollection */ - public function getContent() + public function getContent(): TableCellCollection { return $this->content; } @@ -87,7 +87,7 @@ public function getContent() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'tr'; } diff --git a/src/qtism/data/content/xhtml/tables/TrCollection.php b/src/qtism/data/content/xhtml/tables/TrCollection.php index 23533259f..f678540ce 100644 --- a/src/qtism/data/content/xhtml/tables/TrCollection.php +++ b/src/qtism/data/content/xhtml/tables/TrCollection.php @@ -38,7 +38,7 @@ class TrCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instanceof Tr. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Tr) { $msg = 'TrCollection objects only accept to store Tr objects.'; diff --git a/src/qtism/data/content/xhtml/text/Abbr.php b/src/qtism/data/content/xhtml/text/Abbr.php index 56f4308e3..cec65643a 100644 --- a/src/qtism/data/content/xhtml/text/Abbr.php +++ b/src/qtism/data/content/xhtml/text/Abbr.php @@ -37,7 +37,7 @@ class Abbr extends SimpleInline /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'abbr'; } diff --git a/src/qtism/data/content/xhtml/text/Acronym.php b/src/qtism/data/content/xhtml/text/Acronym.php index 95250c839..94801d695 100644 --- a/src/qtism/data/content/xhtml/text/Acronym.php +++ b/src/qtism/data/content/xhtml/text/Acronym.php @@ -37,7 +37,7 @@ class Acronym extends SimpleInline /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'acronym'; } diff --git a/src/qtism/data/content/xhtml/text/Address.php b/src/qtism/data/content/xhtml/text/Address.php index 0a01f2c51..d95d22a4d 100644 --- a/src/qtism/data/content/xhtml/text/Address.php +++ b/src/qtism/data/content/xhtml/text/Address.php @@ -33,7 +33,7 @@ class Address extends AtomicBlock /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'address'; } diff --git a/src/qtism/data/content/xhtml/text/Bdo.php b/src/qtism/data/content/xhtml/text/Bdo.php index 3b687f133..1b89b2b10 100644 --- a/src/qtism/data/content/xhtml/text/Bdo.php +++ b/src/qtism/data/content/xhtml/text/Bdo.php @@ -33,7 +33,7 @@ class Bdo extends SimpleInline /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'bdo'; } diff --git a/src/qtism/data/content/xhtml/text/Blockquote.php b/src/qtism/data/content/xhtml/text/Blockquote.php index 3a9db4f3f..893e8f203 100644 --- a/src/qtism/data/content/xhtml/text/Blockquote.php +++ b/src/qtism/data/content/xhtml/text/Blockquote.php @@ -61,7 +61,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '', $cit * * @return string A URI. */ - public function getCite() + public function getCite(): string { return $this->cite; } @@ -72,7 +72,7 @@ public function getCite() * @param string $cite * @throws InvalidArgumentException If $cite is not a valid URI. */ - public function setCite($cite) + public function setCite($cite): void { if ($cite !== '' && !Format::isUri($cite)) { $msg = "The 'cite' argument must be a valid URI, '" . $cite . "' given."; @@ -87,7 +87,7 @@ public function setCite($cite) * * @return bool */ - public function hasCite() + public function hasCite(): bool { return $this->getCite() !== ''; } @@ -95,7 +95,7 @@ public function hasCite() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'blockquote'; } diff --git a/src/qtism/data/content/xhtml/text/Br.php b/src/qtism/data/content/xhtml/text/Br.php index eb84e0ef2..769b12f0f 100644 --- a/src/qtism/data/content/xhtml/text/Br.php +++ b/src/qtism/data/content/xhtml/text/Br.php @@ -33,7 +33,7 @@ class Br extends AtomicInline /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'br'; } diff --git a/src/qtism/data/content/xhtml/text/Cite.php b/src/qtism/data/content/xhtml/text/Cite.php index 800c04c13..459cbf794 100644 --- a/src/qtism/data/content/xhtml/text/Cite.php +++ b/src/qtism/data/content/xhtml/text/Cite.php @@ -33,7 +33,7 @@ class Cite extends SimpleInline /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'cite'; } diff --git a/src/qtism/data/content/xhtml/text/Code.php b/src/qtism/data/content/xhtml/text/Code.php index a90db437b..34f2f9bc0 100644 --- a/src/qtism/data/content/xhtml/text/Code.php +++ b/src/qtism/data/content/xhtml/text/Code.php @@ -33,7 +33,7 @@ class Code extends SimpleInline /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'code'; } diff --git a/src/qtism/data/content/xhtml/text/Dfn.php b/src/qtism/data/content/xhtml/text/Dfn.php index e23d1e759..b5c8a885a 100644 --- a/src/qtism/data/content/xhtml/text/Dfn.php +++ b/src/qtism/data/content/xhtml/text/Dfn.php @@ -33,7 +33,7 @@ class Dfn extends SimpleInline /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'dfn'; } diff --git a/src/qtism/data/content/xhtml/text/Div.php b/src/qtism/data/content/xhtml/text/Div.php index 92f67baf5..7cb729643 100644 --- a/src/qtism/data/content/xhtml/text/Div.php +++ b/src/qtism/data/content/xhtml/text/Div.php @@ -71,7 +71,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '') * * @return FlowCollection A collection of Flow objects. */ - public function getComponents() + public function getComponents(): FlowCollection { return $this->getContent(); } @@ -81,7 +81,7 @@ public function getComponents() * * @param FlowCollection $content A collection of Flow objects. */ - public function setContent(FlowCollection $content) + public function setContent(FlowCollection $content): void { $this->content = $content; } @@ -91,7 +91,7 @@ public function setContent(FlowCollection $content) * * @return FlowCollection */ - public function getContent() + public function getContent(): FlowCollection { return $this->content; } @@ -102,7 +102,7 @@ public function getContent() * @param string $xmlBase A URI. * @throws InvalidArgumentException if $base is not a valid URI nor an empty string. */ - public function setXmlBase($xmlBase = '') + public function setXmlBase($xmlBase = ''): void { if (is_string($xmlBase) && (empty($xmlBase) || Format::isUri($xmlBase))) { $this->xmlBase = $xmlBase; @@ -115,7 +115,7 @@ public function setXmlBase($xmlBase = '') /** * @return string */ - public function getXmlBase() + public function getXmlBase(): string { return $this->xmlBase; } @@ -123,7 +123,7 @@ public function getXmlBase() /** * @return bool */ - public function hasXmlBase() + public function hasXmlBase(): bool { return $this->getXmlBase() !== ''; } @@ -131,7 +131,7 @@ public function hasXmlBase() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'div'; } diff --git a/src/qtism/data/content/xhtml/text/Em.php b/src/qtism/data/content/xhtml/text/Em.php index c52b58594..45c6ead8e 100644 --- a/src/qtism/data/content/xhtml/text/Em.php +++ b/src/qtism/data/content/xhtml/text/Em.php @@ -33,7 +33,7 @@ class Em extends SimpleInline /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'em'; } diff --git a/src/qtism/data/content/xhtml/text/H1.php b/src/qtism/data/content/xhtml/text/H1.php index f0f5b3396..719f89d9c 100644 --- a/src/qtism/data/content/xhtml/text/H1.php +++ b/src/qtism/data/content/xhtml/text/H1.php @@ -33,7 +33,7 @@ class H1 extends AtomicBlock /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'h1'; } diff --git a/src/qtism/data/content/xhtml/text/H2.php b/src/qtism/data/content/xhtml/text/H2.php index 77bdc6b42..08e905729 100644 --- a/src/qtism/data/content/xhtml/text/H2.php +++ b/src/qtism/data/content/xhtml/text/H2.php @@ -33,7 +33,7 @@ class H2 extends AtomicBlock /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'h2'; } diff --git a/src/qtism/data/content/xhtml/text/H3.php b/src/qtism/data/content/xhtml/text/H3.php index 76e8e6670..2e747ffb1 100644 --- a/src/qtism/data/content/xhtml/text/H3.php +++ b/src/qtism/data/content/xhtml/text/H3.php @@ -33,7 +33,7 @@ class H3 extends AtomicBlock /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'h3'; } diff --git a/src/qtism/data/content/xhtml/text/H4.php b/src/qtism/data/content/xhtml/text/H4.php index 5e2e80b6b..567067d30 100644 --- a/src/qtism/data/content/xhtml/text/H4.php +++ b/src/qtism/data/content/xhtml/text/H4.php @@ -33,7 +33,7 @@ class H4 extends AtomicBlock /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'h4'; } diff --git a/src/qtism/data/content/xhtml/text/H5.php b/src/qtism/data/content/xhtml/text/H5.php index ab12629b7..c25638b63 100644 --- a/src/qtism/data/content/xhtml/text/H5.php +++ b/src/qtism/data/content/xhtml/text/H5.php @@ -33,7 +33,7 @@ class H5 extends AtomicBlock /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'h5'; } diff --git a/src/qtism/data/content/xhtml/text/H6.php b/src/qtism/data/content/xhtml/text/H6.php index 5403d5a7a..d44374872 100644 --- a/src/qtism/data/content/xhtml/text/H6.php +++ b/src/qtism/data/content/xhtml/text/H6.php @@ -33,7 +33,7 @@ class H6 extends AtomicBlock /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'h6'; } diff --git a/src/qtism/data/content/xhtml/text/Kbd.php b/src/qtism/data/content/xhtml/text/Kbd.php index 73132dd0b..2addf430d 100644 --- a/src/qtism/data/content/xhtml/text/Kbd.php +++ b/src/qtism/data/content/xhtml/text/Kbd.php @@ -33,7 +33,7 @@ class Kbd extends SimpleInline /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'kbd'; } diff --git a/src/qtism/data/content/xhtml/text/P.php b/src/qtism/data/content/xhtml/text/P.php index 3862f0497..b2c67d0c4 100644 --- a/src/qtism/data/content/xhtml/text/P.php +++ b/src/qtism/data/content/xhtml/text/P.php @@ -33,7 +33,7 @@ class P extends AtomicBlock /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'p'; } diff --git a/src/qtism/data/content/xhtml/text/Pre.php b/src/qtism/data/content/xhtml/text/Pre.php index fb5b6a823..5d58737c2 100644 --- a/src/qtism/data/content/xhtml/text/Pre.php +++ b/src/qtism/data/content/xhtml/text/Pre.php @@ -33,7 +33,7 @@ class Pre extends AtomicBlock /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'pre'; } diff --git a/src/qtism/data/content/xhtml/text/Q.php b/src/qtism/data/content/xhtml/text/Q.php index 16a47ce62..2702f2a41 100644 --- a/src/qtism/data/content/xhtml/text/Q.php +++ b/src/qtism/data/content/xhtml/text/Q.php @@ -61,7 +61,7 @@ public function __construct($id = '', $class = '', $lang = '', $label = '', $cit * * @return string A URI. */ - public function getCite() + public function getCite(): string { return $this->cite; } @@ -72,7 +72,7 @@ public function getCite() * @param string $cite * @throws InvalidArgumentException If $cite is not a valid URI. */ - public function setCite($cite) + public function setCite($cite): void { if ($cite !== '' && !Format::isUri($cite)) { $msg = "The 'cite' argument must be a valid URI, '" . $cite . "' given."; @@ -87,7 +87,7 @@ public function setCite($cite) * * @return string */ - public function hasCite() + public function hasCite(): string { return $this->getCite() !== ''; } @@ -95,7 +95,7 @@ public function hasCite() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'q'; } diff --git a/src/qtism/data/content/xhtml/text/Samp.php b/src/qtism/data/content/xhtml/text/Samp.php index a884f275f..a9120f364 100644 --- a/src/qtism/data/content/xhtml/text/Samp.php +++ b/src/qtism/data/content/xhtml/text/Samp.php @@ -33,7 +33,7 @@ class Samp extends SimpleInline /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'samp'; } diff --git a/src/qtism/data/content/xhtml/text/Span.php b/src/qtism/data/content/xhtml/text/Span.php index cb2753dba..e293b5638 100644 --- a/src/qtism/data/content/xhtml/text/Span.php +++ b/src/qtism/data/content/xhtml/text/Span.php @@ -33,7 +33,7 @@ class Span extends SimpleInline /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'span'; } diff --git a/src/qtism/data/content/xhtml/text/Strong.php b/src/qtism/data/content/xhtml/text/Strong.php index f60461230..bdfe1e594 100644 --- a/src/qtism/data/content/xhtml/text/Strong.php +++ b/src/qtism/data/content/xhtml/text/Strong.php @@ -33,7 +33,7 @@ class Strong extends SimpleInline /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'strong'; } diff --git a/src/qtism/data/content/xhtml/text/VarElement.php b/src/qtism/data/content/xhtml/text/VarElement.php index 59bd365fd..18f929af8 100644 --- a/src/qtism/data/content/xhtml/text/VarElement.php +++ b/src/qtism/data/content/xhtml/text/VarElement.php @@ -35,7 +35,7 @@ class VarElement extends SimpleInline /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'var'; } diff --git a/src/qtism/data/expressions/BaseValue.php b/src/qtism/data/expressions/BaseValue.php index 83d6ca836..e991df603 100644 --- a/src/qtism/data/expressions/BaseValue.php +++ b/src/qtism/data/expressions/BaseValue.php @@ -69,7 +69,7 @@ public function __construct($baseType, $value) * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -80,7 +80,7 @@ public function getBaseType() * @param int $baseType A value from the BaseType enumeration. * @throws InvalidArgumentException If $baseType is not a value from the BaseType enumeration. */ - public function setBaseType($baseType) + public function setBaseType($baseType): void { if (in_array($baseType, BaseType::asArray())) { $this->baseType = $baseType; @@ -95,6 +95,7 @@ public function setBaseType($baseType) * * @return mixed A value. */ + #[\ReturnTypeWillChange] public function getValue() { return $this->value; @@ -105,7 +106,7 @@ public function getValue() * * @param mixed $value The actual value. */ - public function setValue($value) + public function setValue($value): void { $this->value = $value; } @@ -113,7 +114,7 @@ public function setValue($value) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'baseValue'; } @@ -123,7 +124,7 @@ public function getQtiClassName() * * @return bool */ - public function isPure() + public function isPure(): bool { return true; } diff --git a/src/qtism/data/expressions/Correct.php b/src/qtism/data/expressions/Correct.php index 29263d20f..94bfc3cfe 100644 --- a/src/qtism/data/expressions/Correct.php +++ b/src/qtism/data/expressions/Correct.php @@ -61,7 +61,7 @@ public function __construct($identifier) * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false)) { $this->identifier = $identifier; @@ -76,7 +76,7 @@ public function setIdentifier($identifier) * * @return string A QTI Identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -84,7 +84,7 @@ public function getIdentifier() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'correct'; } @@ -94,7 +94,7 @@ public function getQtiClassName() * * @return bool */ - public function isPure() + public function isPure(): bool { return false; } diff --git a/src/qtism/data/expressions/DefaultVal.php b/src/qtism/data/expressions/DefaultVal.php index 92bafa80a..c0831567c 100644 --- a/src/qtism/data/expressions/DefaultVal.php +++ b/src/qtism/data/expressions/DefaultVal.php @@ -65,7 +65,7 @@ public function __construct($identifier) * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { $this->identifier = $identifier; } @@ -75,7 +75,7 @@ public function setIdentifier($identifier) * * @return string A QTI Identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -83,7 +83,7 @@ public function getIdentifier() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'default'; } @@ -93,7 +93,7 @@ public function getQtiClassName() * * @return bool */ - public function isPure() + public function isPure(): bool { return false; // we can change the default value of a variable during runtime } diff --git a/src/qtism/data/expressions/Expression.php b/src/qtism/data/expressions/Expression.php index a05c9ac3b..aa28ff124 100644 --- a/src/qtism/data/expressions/Expression.php +++ b/src/qtism/data/expressions/Expression.php @@ -113,7 +113,7 @@ abstract class Expression extends QtiComponent * * @return array An array of string values. */ - public static function getExpressionClassNames() + public static function getExpressionClassNames(): array { return self::$expressionClassNames; } @@ -121,7 +121,7 @@ public static function getExpressionClassNames() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -133,5 +133,5 @@ public function getComponents() * * @return bool True if the expression is pure, false otherwise */ - abstract public function isPure(); + abstract public function isPure(): bool; } diff --git a/src/qtism/data/expressions/ExpressionCollection.php b/src/qtism/data/expressions/ExpressionCollection.php index 38b22848d..c071e3b27 100644 --- a/src/qtism/data/expressions/ExpressionCollection.php +++ b/src/qtism/data/expressions/ExpressionCollection.php @@ -37,7 +37,7 @@ class ExpressionCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of Expression. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Expression) { $msg = "ExpressionCollection only accepts to store Expression objects, '" . gettype($value) . "' given."; @@ -50,7 +50,7 @@ protected function checkType($value) * * @return bool */ - public function isPure() + public function isPure(): bool { foreach ($this as $expr) { if (!$expr->isPure()) { diff --git a/src/qtism/data/expressions/ItemSubset.php b/src/qtism/data/expressions/ItemSubset.php index 13b063472..20ba9f501 100644 --- a/src/qtism/data/expressions/ItemSubset.php +++ b/src/qtism/data/expressions/ItemSubset.php @@ -83,7 +83,7 @@ public function __construct() * @param string $sectionIdentifier A QTI Identifier. * @throws InvalidArgumentException If $sectionIdentifier is not a valid QTI Identifier. */ - public function setSectionIdentifier($sectionIdentifier) + public function setSectionIdentifier($sectionIdentifier): void { if (Format::isIdentifier($sectionIdentifier) || empty($sectionIdentifier)) { $this->sectionIdentifier = $sectionIdentifier; @@ -98,7 +98,7 @@ public function setSectionIdentifier($sectionIdentifier) * * @return string */ - public function getSectionIdentifier() + public function getSectionIdentifier(): string { return $this->sectionIdentifier; } @@ -108,7 +108,7 @@ public function getSectionIdentifier() * * @param IdentifierCollection $includeCategories A collection of QTI Identifiers. */ - public function setIncludeCategories(IdentifierCollection $includeCategories) + public function setIncludeCategories(IdentifierCollection $includeCategories): void { $this->includeCategories = $includeCategories; } @@ -118,7 +118,7 @@ public function setIncludeCategories(IdentifierCollection $includeCategories) * * @return IdentifierCollection */ - public function getIncludeCategories() + public function getIncludeCategories(): IdentifierCollection { return $this->includeCategories; } @@ -128,7 +128,7 @@ public function getIncludeCategories() * * @param IdentifierCollection $excludeCategories A collection of QTI Identifiers. */ - public function setExcludeCategories(IdentifierCollection $excludeCategories) + public function setExcludeCategories(IdentifierCollection $excludeCategories): void { $this->excludeCategories = $excludeCategories; } @@ -138,7 +138,7 @@ public function setExcludeCategories(IdentifierCollection $excludeCategories) * * @return IdentifierCollection */ - public function getExcludeCategories() + public function getExcludeCategories(): IdentifierCollection { return $this->excludeCategories; } @@ -146,7 +146,7 @@ public function getExcludeCategories() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'itemSubset'; } @@ -156,7 +156,7 @@ public function getQtiClassName() * * @return bool */ - public function isPure() + public function isPure(): bool { return false; // Dependant on the items of the test } diff --git a/src/qtism/data/expressions/MapResponse.php b/src/qtism/data/expressions/MapResponse.php index 02c6dc053..c35f57f54 100644 --- a/src/qtism/data/expressions/MapResponse.php +++ b/src/qtism/data/expressions/MapResponse.php @@ -70,7 +70,7 @@ public function __construct($identifier) * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false)) { $this->identifier = $identifier; @@ -85,7 +85,7 @@ public function setIdentifier($identifier) * * @return string A QTI Identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -93,7 +93,7 @@ public function getIdentifier() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'mapResponse'; } @@ -103,7 +103,7 @@ public function getQtiClassName() * * @return bool */ - public function isPure() + public function isPure(): bool { return false; // dependant on identifier } diff --git a/src/qtism/data/expressions/MapResponsePoint.php b/src/qtism/data/expressions/MapResponsePoint.php index b7838ba0e..b29e59384 100644 --- a/src/qtism/data/expressions/MapResponsePoint.php +++ b/src/qtism/data/expressions/MapResponsePoint.php @@ -64,7 +64,7 @@ public function __construct($identifier) * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false)) { $this->identifier = $identifier; @@ -79,7 +79,7 @@ public function setIdentifier($identifier) * * @return string A QTI Identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -87,7 +87,7 @@ public function getIdentifier() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'mapResponsePoint'; } @@ -97,7 +97,7 @@ public function getQtiClassName() * * @return bool */ - public function isPure() + public function isPure(): bool { return false; // dependant on identifier } diff --git a/src/qtism/data/expressions/MathConstant.php b/src/qtism/data/expressions/MathConstant.php index 9909168f0..dfa966893 100644 --- a/src/qtism/data/expressions/MathConstant.php +++ b/src/qtism/data/expressions/MathConstant.php @@ -55,7 +55,7 @@ public function __construct($name) * * @return int A value from the MathEnumeration enumeration. */ - public function getName() + public function getName(): int { return $this->name; } @@ -66,7 +66,7 @@ public function getName() * @param string $name The name of the math constant. * @throws InvalidArgumentException If $name is not a valid QTI math constant name. */ - public function setName($name) + public function setName($name): void { if (in_array($name, MathEnumeration::asArray())) { $this->name = $name; @@ -79,7 +79,7 @@ public function setName($name) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'mathConstant'; } @@ -89,7 +89,7 @@ public function getQtiClassName() * * @return bool */ - public function isPure() + public function isPure(): bool { return true; } diff --git a/src/qtism/data/expressions/MathEnumeration.php b/src/qtism/data/expressions/MathEnumeration.php index 285b1e73b..309258575 100644 --- a/src/qtism/data/expressions/MathEnumeration.php +++ b/src/qtism/data/expressions/MathEnumeration.php @@ -37,7 +37,7 @@ class MathEnumeration implements Enumeration * * @var float */ - const PI = 0; + public const PI = 0; /** * From IMS QTI: @@ -46,12 +46,12 @@ class MathEnumeration implements Enumeration * * @var float */ - const E = 1; + public const E = 1; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'PI' => self::PI, @@ -86,7 +86,7 @@ public static function getNameByConstant($constant) */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'pi': return self::PI; break; diff --git a/src/qtism/data/expressions/NullValue.php b/src/qtism/data/expressions/NullValue.php index aff724ecd..51d93125a 100644 --- a/src/qtism/data/expressions/NullValue.php +++ b/src/qtism/data/expressions/NullValue.php @@ -34,7 +34,7 @@ class NullValue extends Expression /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'null'; } @@ -44,7 +44,7 @@ public function getQtiClassName() * * @return bool */ - public function isPure() + public function isPure(): bool { return true; } diff --git a/src/qtism/data/expressions/NumberCorrect.php b/src/qtism/data/expressions/NumberCorrect.php index ef8db9a14..6dc12c163 100644 --- a/src/qtism/data/expressions/NumberCorrect.php +++ b/src/qtism/data/expressions/NumberCorrect.php @@ -35,7 +35,7 @@ class NumberCorrect extends ItemSubset /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'numberCorrect'; } diff --git a/src/qtism/data/expressions/NumberIncorrect.php b/src/qtism/data/expressions/NumberIncorrect.php index 407924d58..942746b05 100644 --- a/src/qtism/data/expressions/NumberIncorrect.php +++ b/src/qtism/data/expressions/NumberIncorrect.php @@ -37,7 +37,7 @@ class NumberIncorrect extends ItemSubset /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'numberIncorrect'; } diff --git a/src/qtism/data/expressions/NumberPresented.php b/src/qtism/data/expressions/NumberPresented.php index 3bd4ab309..a07438814 100644 --- a/src/qtism/data/expressions/NumberPresented.php +++ b/src/qtism/data/expressions/NumberPresented.php @@ -36,7 +36,7 @@ class NumberPresented extends ItemSubset /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'numberPresented'; } diff --git a/src/qtism/data/expressions/NumberResponded.php b/src/qtism/data/expressions/NumberResponded.php index 288f255ed..11a1b8aa6 100644 --- a/src/qtism/data/expressions/NumberResponded.php +++ b/src/qtism/data/expressions/NumberResponded.php @@ -37,7 +37,7 @@ class NumberResponded extends ItemSubset /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'numberResponded'; } diff --git a/src/qtism/data/expressions/NumberSelected.php b/src/qtism/data/expressions/NumberSelected.php index 40545ae46..8889ba1ba 100644 --- a/src/qtism/data/expressions/NumberSelected.php +++ b/src/qtism/data/expressions/NumberSelected.php @@ -36,7 +36,7 @@ class NumberSelected extends ItemSubset /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'numberSelected'; } diff --git a/src/qtism/data/expressions/OutcomeMaximum.php b/src/qtism/data/expressions/OutcomeMaximum.php index 7e36c4479..2eb63ba84 100644 --- a/src/qtism/data/expressions/OutcomeMaximum.php +++ b/src/qtism/data/expressions/OutcomeMaximum.php @@ -77,7 +77,7 @@ public function __construct($outcomeIdentifier, $weightIdentifier = '') * @param string $outcomeIdentifier A QTI Identifier. * @throws InvalidArgumentException If $outcomeIdentifier is not a valid QTI Identifier. */ - public function setOutcomeIdentifier($outcomeIdentifier) + public function setOutcomeIdentifier($outcomeIdentifier): void { if (Format::isIdentifier($outcomeIdentifier)) { $this->outcomeIdentifier = $outcomeIdentifier; @@ -92,7 +92,7 @@ public function setOutcomeIdentifier($outcomeIdentifier) * * @return string A QTI Identifier. */ - public function getOutcomeIdentifier() + public function getOutcomeIdentifier(): string { return $this->outcomeIdentifier; } @@ -103,7 +103,7 @@ public function getOutcomeIdentifier() * @param string $weightIdentifier A QTI Identifier or '' (empty string) if not specified. * @throws InvalidArgumentException If $weightIdentifier is not a valid QTI Identifier nor '' (empty string). */ - public function setWeightIdentifier($weightIdentifier) + public function setWeightIdentifier($weightIdentifier): void { if (Format::isIdentifier($weightIdentifier) || $weightIdentifier == '') { $this->weightIdentifier = $weightIdentifier; @@ -118,7 +118,7 @@ public function setWeightIdentifier($weightIdentifier) * * @return string A QTI Identifier or '' (empty string). */ - public function getWeightIdentifier() + public function getWeightIdentifier(): string { return $this->weightIdentifier; } @@ -126,7 +126,7 @@ public function getWeightIdentifier() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'outcomeMaximum'; } diff --git a/src/qtism/data/expressions/OutcomeMinimum.php b/src/qtism/data/expressions/OutcomeMinimum.php index 936153abc..0c95d1333 100644 --- a/src/qtism/data/expressions/OutcomeMinimum.php +++ b/src/qtism/data/expressions/OutcomeMinimum.php @@ -77,7 +77,7 @@ public function __construct($outcomeIdentifier, $weightIdentifier = '') * @param string $outcomeIdentifier A QTI Identifier. * @throws InvalidArgumentException If $outcomeIdentifier is not a valid QTI Identifier. */ - public function setOutcomeIdentifier($outcomeIdentifier) + public function setOutcomeIdentifier($outcomeIdentifier): void { if (Format::isIdentifier($outcomeIdentifier)) { $this->outcomeIdentifier = $outcomeIdentifier; @@ -92,7 +92,7 @@ public function setOutcomeIdentifier($outcomeIdentifier) * * @return string A QTI Identifier. */ - public function getOutcomeIdentifier() + public function getOutcomeIdentifier(): string { return $this->outcomeIdentifier; } @@ -103,7 +103,7 @@ public function getOutcomeIdentifier() * @param string $weightIdentifier A QTI Identifier or '' (empty string) if not specified. * @throws InvalidArgumentException If $weightIdentifier is not a valid QTI Identifier nor '' (empty string). */ - public function setWeightIdentifier($weightIdentifier) + public function setWeightIdentifier($weightIdentifier): void { if (Format::isIdentifier($weightIdentifier) || $weightIdentifier == '') { $this->weightIdentifier = $weightIdentifier; @@ -118,7 +118,7 @@ public function setWeightIdentifier($weightIdentifier) * * @return string A QTI Identifier or '' (empty string). */ - public function getWeightIdentifier() + public function getWeightIdentifier(): string { return $this->weightIdentifier; } @@ -126,7 +126,7 @@ public function getWeightIdentifier() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'outcomeMinimum'; } diff --git a/src/qtism/data/expressions/RandomFloat.php b/src/qtism/data/expressions/RandomFloat.php index c80016508..5d8719770 100644 --- a/src/qtism/data/expressions/RandomFloat.php +++ b/src/qtism/data/expressions/RandomFloat.php @@ -77,7 +77,7 @@ public function getMin() * @param number|string $min A float value, int value or a variableRef. * @throws InvalidArgumentException If $min is not a numeric value nor a variableRef. */ - public function setMin($min) + public function setMin($min): void { if (is_numeric($min) || Format::isVariableRef($min)) { $this->min = $min; @@ -103,7 +103,7 @@ public function getMax() * @param number|string $max A numeric value or a variableRef. * @throws InvalidArgumentException If $max is not a numeric value nor a variableRef. */ - public function setMax($max) + public function setMax($max): void { if (is_numeric($max) || Format::isVariableRef($max)) { $this->max = $max; @@ -116,7 +116,7 @@ public function setMax($max) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'randomFloat'; } @@ -126,7 +126,7 @@ public function getQtiClassName() * * @return bool */ - public function isPure() + public function isPure(): bool { return false; // Random --> impure } diff --git a/src/qtism/data/expressions/RandomInteger.php b/src/qtism/data/expressions/RandomInteger.php index d9f13714c..2fa8a73f7 100644 --- a/src/qtism/data/expressions/RandomInteger.php +++ b/src/qtism/data/expressions/RandomInteger.php @@ -37,7 +37,7 @@ class RandomInteger extends Expression /** * The min attribute value. * - * @var int + * @var int|string * @qtism-bean-property */ private $min = 0; @@ -45,7 +45,7 @@ class RandomInteger extends Expression /** * The max attribute value. * - * @var int + * @var int|string * @qtism-bean-property */ private $max; @@ -76,8 +76,9 @@ public function __construct($min, $max, $step = 1) /** * Get the value of the min attribute. * - * @return int + * @return int|string */ + #[\ReturnTypeWillChange] public function getMin() { return $this->min; @@ -89,7 +90,7 @@ public function getMin() * @param int $min * @throws InvalidArgumentException */ - public function setMin($min) + public function setMin($min): void { if (is_int($min) || Format::isVariableRef($min)) { $this->min = $min; @@ -102,8 +103,9 @@ public function setMin($min) /** * Get the value of the max attribute. * - * @return int + * @return int|string */ + #[\ReturnTypeWillChange] public function getMax() { return $this->max; @@ -115,7 +117,7 @@ public function getMax() * @param int $max * @throws InvalidArgumentException */ - public function setMax($max) + public function setMax($max): void { if (is_int($max) || Format::isVariableRef($max)) { $this->max = $max; @@ -130,7 +132,7 @@ public function setMax($max) * * @return int */ - public function getStep() + public function getStep(): int { return $this->step; } @@ -141,7 +143,7 @@ public function getStep() * @param int $step * @throws InvalidArgumentException */ - public function setStep($step) + public function setStep($step): void { if (is_int($step)) { $this->step = $step; @@ -154,7 +156,7 @@ public function setStep($step) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'randomInteger'; } @@ -164,7 +166,7 @@ public function getQtiClassName() * * @return bool */ - public function isPure() + public function isPure(): bool { return false; // random --> false } diff --git a/src/qtism/data/expressions/TestVariables.php b/src/qtism/data/expressions/TestVariables.php index 80ab9c986..fd79eeb61 100644 --- a/src/qtism/data/expressions/TestVariables.php +++ b/src/qtism/data/expressions/TestVariables.php @@ -106,7 +106,7 @@ public function __construct($variableIdentifier, $baseType = -1, $weightIdentifi * @param string $variableIdentifier A QTI Identifier. * @throws InvalidArgumentException If $variableIdentifier is not a valid QTI Identifier. */ - public function setVariableIdentifier($variableIdentifier) + public function setVariableIdentifier($variableIdentifier): void { if (Format::isIdentifier($variableIdentifier)) { $this->variableIdentifier = $variableIdentifier; @@ -121,7 +121,7 @@ public function setVariableIdentifier($variableIdentifier) * * @return string A QTI Identifier. */ - public function getVariableIdentifier() + public function getVariableIdentifier(): string { return $this->variableIdentifier; } @@ -132,7 +132,7 @@ public function getVariableIdentifier() * @param int $baseType A value from the BaseType enumeration or -1. * @throws InvalidArgumentException If $baseType is not a valid QTI Identifier nor -1. */ - public function setBaseType($baseType) + public function setBaseType($baseType): void { if ($baseType == -1 || in_array($baseType, BaseType::asArray())) { $this->baseType = $baseType; @@ -147,7 +147,7 @@ public function setBaseType($baseType) * * @return int A value from the BaseType enumeration or -1 if no baseType specified. */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -158,7 +158,7 @@ public function getBaseType() * @param string $weightIdentifier A QTI Identifier. * @throws InvalidArgumentException If $weightIdentifier is not a valid QTI Identifier. */ - public function setWeightIdentifier($weightIdentifier) + public function setWeightIdentifier($weightIdentifier): void { if (Format::isIdentifier($weightIdentifier) || empty($weightIdentifier)) { $this->weightIdentifier = $weightIdentifier; @@ -173,7 +173,7 @@ public function setWeightIdentifier($weightIdentifier) * * @return string A QTI Identifier. */ - public function getWeightIdentifier() + public function getWeightIdentifier(): string { return $this->weightIdentifier; } @@ -181,7 +181,7 @@ public function getWeightIdentifier() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'testVariables'; } diff --git a/src/qtism/data/expressions/Variable.php b/src/qtism/data/expressions/Variable.php index 3e18411b7..5f3004650 100644 --- a/src/qtism/data/expressions/Variable.php +++ b/src/qtism/data/expressions/Variable.php @@ -107,7 +107,7 @@ public function __construct($identifier, $weightIdentifier = '') * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false)) { $this->identifier = $identifier; @@ -122,7 +122,7 @@ public function setIdentifier($identifier) * * @return string A QTI Identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -134,7 +134,7 @@ public function getIdentifier() * @param string $weightIdentifier A QTI identifier. * @throws InvalidArgumentException If $weightIdentifier is not empty but is an invalid QTI Identifier. */ - public function setWeightIdentifier($weightIdentifier) + public function setWeightIdentifier($weightIdentifier): void { if (empty($weightIdentifier) || Format::isIdentifier($weightIdentifier)) { $this->weightIdentifier = $weightIdentifier; @@ -150,7 +150,7 @@ public function setWeightIdentifier($weightIdentifier) * * @return string A QTI identifier or an empty string if no weight identifier is specified. */ - public function getWeightIdentifier() + public function getWeightIdentifier(): string { return $this->weightIdentifier; } @@ -158,7 +158,7 @@ public function getWeightIdentifier() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'variable'; } @@ -168,7 +168,7 @@ public function getQtiClassName() * * @return bool */ - public function isPure() + public function isPure(): bool { return false; // variable --> impure } diff --git a/src/qtism/data/expressions/operators/AndOperator.php b/src/qtism/data/expressions/operators/AndOperator.php index 3553c8cfb..f70213a66 100644 --- a/src/qtism/data/expressions/operators/AndOperator.php +++ b/src/qtism/data/expressions/operators/AndOperator.php @@ -54,7 +54,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'and'; } diff --git a/src/qtism/data/expressions/operators/AnyN.php b/src/qtism/data/expressions/operators/AnyN.php index 5f11b7009..d8b0ffc91 100644 --- a/src/qtism/data/expressions/operators/AnyN.php +++ b/src/qtism/data/expressions/operators/AnyN.php @@ -86,7 +86,7 @@ public function __construct(ExpressionCollection $expressions, $min, $max) * @param string|int $min An integer or a variable reference. * @throws InvalidArgumentException If $min is not an integer nor a variable reference. */ - public function setMin($min) + public function setMin($min): void { if (is_int($min) || (is_string($min) && Format::isVariableRef($min))) { $this->min = $min; @@ -112,7 +112,7 @@ public function getMin() * @param string|int $max An integer or a variable reference. * @throws InvalidArgumentException If $max is not an integer nor a variable reference. */ - public function setMax($max) + public function setMax($max): void { if (is_int($max) || (is_string($max) && Format::isVariableRef($max))) { $this->max = $max; @@ -135,7 +135,7 @@ public function getMax() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'anyN'; } diff --git a/src/qtism/data/expressions/operators/ContainerSize.php b/src/qtism/data/expressions/operators/ContainerSize.php index d91bb2deb..5bad19975 100644 --- a/src/qtism/data/expressions/operators/ContainerSize.php +++ b/src/qtism/data/expressions/operators/ContainerSize.php @@ -51,7 +51,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'containerSize'; } diff --git a/src/qtism/data/expressions/operators/Contains.php b/src/qtism/data/expressions/operators/Contains.php index 2ccb4417f..8a9d9fcae 100644 --- a/src/qtism/data/expressions/operators/Contains.php +++ b/src/qtism/data/expressions/operators/Contains.php @@ -60,7 +60,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'contains'; } diff --git a/src/qtism/data/expressions/operators/CustomOperator.php b/src/qtism/data/expressions/operators/CustomOperator.php index 3eecefd85..39520f4d3 100644 --- a/src/qtism/data/expressions/operators/CustomOperator.php +++ b/src/qtism/data/expressions/operators/CustomOperator.php @@ -99,7 +99,7 @@ public function __construct(ExpressionCollection $expressions, $xmlString) * @param string $class A class name which is tool specific. * @throws InvalidArgumentException If $class is not a string. */ - public function setClass($class) + public function setClass($class): void { if (is_string($class)) { $this->class = $class; @@ -114,7 +114,7 @@ public function setClass($class) * * @return string A class name which is tool specific. */ - public function getClass() + public function getClass(): string { return $this->class; } @@ -124,7 +124,7 @@ public function getClass() * * @return bool */ - public function hasClass() + public function hasClass(): bool { return $this->getClass() !== ''; } @@ -136,7 +136,7 @@ public function hasClass() * @param string $definition A URI or an empty string. * @throws InvalidArgumentException If $definition is not a string. */ - public function setDefinition($definition) + public function setDefinition($definition): void { if (is_string($definition)) { $this->definition = $definition; @@ -152,7 +152,7 @@ public function setDefinition($definition) * * @return string A URI or an empty string. */ - public function getDefinition() + public function getDefinition(): string { return $this->definition; } @@ -162,7 +162,7 @@ public function getDefinition() * * @return bool */ - public function hasDefinition() + public function hasDefinition(): bool { return $this->getDefinition() !== ''; } @@ -183,7 +183,7 @@ public function getXml(): ?SerializableDomDocument * * @param string $xmlString */ - public function setXmlString($xmlString) + public function setXmlString($xmlString): void { $this->xmlString = $xmlString; @@ -197,7 +197,7 @@ public function setXmlString($xmlString) * * @return string */ - public function getXmlString() + public function getXmlString(): string { return $this->xmlString; } @@ -207,7 +207,7 @@ public function getXmlString() * * @param ExternalQtiComponent $externalComponent */ - private function setExternalComponent(ExternalQtiComponent $externalComponent) + private function setExternalComponent(ExternalQtiComponent $externalComponent): void { $this->externalComponent = $externalComponent; } @@ -217,7 +217,7 @@ private function setExternalComponent(ExternalQtiComponent $externalComponent) * * @return ExternalQtiComponent */ - private function getExternalComponent() + private function getExternalComponent(): ExternalQtiComponent { return $this->externalComponent; } @@ -225,7 +225,7 @@ private function getExternalComponent() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'customOperator'; } @@ -235,7 +235,7 @@ public function getQtiClassName() * * @return bool */ - public function isPure() + public function isPure(): bool { return false; // Too impredictable, for instance calling web service --> impure } diff --git a/src/qtism/data/expressions/operators/Delete.php b/src/qtism/data/expressions/operators/Delete.php index bba16567e..f2e4eaec2 100644 --- a/src/qtism/data/expressions/operators/Delete.php +++ b/src/qtism/data/expressions/operators/Delete.php @@ -54,7 +54,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'delete'; } diff --git a/src/qtism/data/expressions/operators/Divide.php b/src/qtism/data/expressions/operators/Divide.php index b179721d7..2f321e935 100644 --- a/src/qtism/data/expressions/operators/Divide.php +++ b/src/qtism/data/expressions/operators/Divide.php @@ -53,7 +53,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'divide'; } diff --git a/src/qtism/data/expressions/operators/DurationGTE.php b/src/qtism/data/expressions/operators/DurationGTE.php index ba971462f..4d77f676a 100644 --- a/src/qtism/data/expressions/operators/DurationGTE.php +++ b/src/qtism/data/expressions/operators/DurationGTE.php @@ -51,7 +51,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'durationGTE'; } diff --git a/src/qtism/data/expressions/operators/DurationLT.php b/src/qtism/data/expressions/operators/DurationLT.php index 6fad1bcda..2ab3e1a8f 100644 --- a/src/qtism/data/expressions/operators/DurationLT.php +++ b/src/qtism/data/expressions/operators/DurationLT.php @@ -58,7 +58,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'durationLT'; } diff --git a/src/qtism/data/expressions/operators/Equal.php b/src/qtism/data/expressions/operators/Equal.php index aabf98893..2afb0dc16 100644 --- a/src/qtism/data/expressions/operators/Equal.php +++ b/src/qtism/data/expressions/operators/Equal.php @@ -123,7 +123,7 @@ public function __construct(ExpressionCollection $expressions, $toleranceMode = * @param int $toleranceMode A value from the ToleranceMode enumeration. * @throws InvalidArgumentException If $toleranceMode is not a value from the ToleranceMode enumeration. */ - public function setToleranceMode($toleranceMode) + public function setToleranceMode($toleranceMode): void { if (in_array($toleranceMode, ToleranceMode::asArray(), true)) { $this->toleranceMode = $toleranceMode; @@ -138,7 +138,7 @@ public function setToleranceMode($toleranceMode) * * @return int A value from the ToleranceMode enumeration. */ - public function getToleranceMode() + public function getToleranceMode(): int { return $this->toleranceMode; } @@ -151,7 +151,7 @@ public function getToleranceMode() * @param array $tolerance An array of float|variableRef. * @throws InvalidArgumentException If the $tolerance count is less than 1 or greather than 2. */ - public function setTolerance(array $tolerance) + public function setTolerance(array $tolerance): void { if (($this->getToleranceMode() == ToleranceMode::ABSOLUTE || $this->getToleranceMode() == ToleranceMode::RELATIVE) && count($tolerance) < 1) { $msg = 'The tolerance array must contain at least t0.'; @@ -171,7 +171,7 @@ public function setTolerance(array $tolerance) * * @return array An array of float|variableRef. */ - public function getTolerance() + public function getTolerance(): array { return $this->tolerance; } @@ -182,7 +182,7 @@ public function getTolerance() * @param bool $includeLowerBound * @throws InvalidArgumentException If $includedLowerBound is not a boolean value. */ - public function setIncludeLowerBound($includeLowerBound) + public function setIncludeLowerBound($includeLowerBound): void { if (is_bool($includeLowerBound)) { $this->includeLowerBound = $includeLowerBound; @@ -197,7 +197,7 @@ public function setIncludeLowerBound($includeLowerBound) * * @return bool */ - public function doesIncludeLowerBound() + public function doesIncludeLowerBound(): bool { return $this->includeLowerBound; } @@ -208,7 +208,7 @@ public function doesIncludeLowerBound() * @param bool $includeUpperBound * @throws InvalidArgumentException If $includeUpperBound is not a boolean. */ - public function setIncludeUpperBound($includeUpperBound) + public function setIncludeUpperBound($includeUpperBound): void { if (is_bool($includeUpperBound)) { $this->includeUpperBound = $includeUpperBound; @@ -223,7 +223,7 @@ public function setIncludeUpperBound($includeUpperBound) * * @return bool */ - public function doesIncludeUpperBound() + public function doesIncludeUpperBound(): bool { return $this->includeUpperBound; } @@ -231,7 +231,7 @@ public function doesIncludeUpperBound() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'equal'; } diff --git a/src/qtism/data/expressions/operators/EqualRounded.php b/src/qtism/data/expressions/operators/EqualRounded.php index 46e375735..62c26c7e3 100644 --- a/src/qtism/data/expressions/operators/EqualRounded.php +++ b/src/qtism/data/expressions/operators/EqualRounded.php @@ -81,7 +81,7 @@ public function __construct(ExpressionCollection $expressions, $figures, $roundi * @param int $roundingMode A value from the RoundingMode enumeration. * @throws InvalidArgumentException If $roundingMode is not a value from the RoundingMode enumeration. */ - public function setRoundingMode($roundingMode) + public function setRoundingMode($roundingMode): void { if (in_array($roundingMode, RoundingMode::asArray())) { $this->roundingMode = $roundingMode; @@ -96,7 +96,7 @@ public function setRoundingMode($roundingMode) * * @return int A value from the RoundingMode enumeration. */ - public function getRoundingMode() + public function getRoundingMode(): int { return $this->roundingMode; } @@ -107,7 +107,7 @@ public function getRoundingMode() * @param int|string $figures An integer value or a variable reference. * @throws InvalidArgumentException If $figures is not an integer nor a variable reference. */ - public function setFigures($figures) + public function setFigures($figures): void { if (is_int($figures) || (is_string($figures) && Format::isVariableRef($figures))) { $this->figures = $figures; @@ -130,7 +130,7 @@ public function getFigures() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'equalRounded'; } diff --git a/src/qtism/data/expressions/operators/FieldValue.php b/src/qtism/data/expressions/operators/FieldValue.php index d08397289..823c37481 100644 --- a/src/qtism/data/expressions/operators/FieldValue.php +++ b/src/qtism/data/expressions/operators/FieldValue.php @@ -60,7 +60,7 @@ public function __construct(ExpressionCollection $expressions, $fieldIdentifier) * @param string $fieldIdentifier A QTI Identifier. * @throws InvalidArgumentException If $fieldIdentifier is not a valid QTI Identifier. */ - public function setFieldIdentifier($fieldIdentifier) + public function setFieldIdentifier($fieldIdentifier): void { if (Format::isIdentifier($fieldIdentifier)) { $this->fieldIdentifier = $fieldIdentifier; @@ -75,7 +75,7 @@ public function setFieldIdentifier($fieldIdentifier) * * @return string A QTI Identifier. */ - public function getFieldIdentifier() + public function getFieldIdentifier(): string { return $this->fieldIdentifier; } @@ -83,7 +83,7 @@ public function getFieldIdentifier() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'fieldValue'; } diff --git a/src/qtism/data/expressions/operators/Gcd.php b/src/qtism/data/expressions/operators/Gcd.php index 9a36d7141..de092d6e1 100644 --- a/src/qtism/data/expressions/operators/Gcd.php +++ b/src/qtism/data/expressions/operators/Gcd.php @@ -54,7 +54,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'gcd'; } diff --git a/src/qtism/data/expressions/operators/Gt.php b/src/qtism/data/expressions/operators/Gt.php index b34c7aedc..80ba4475e 100644 --- a/src/qtism/data/expressions/operators/Gt.php +++ b/src/qtism/data/expressions/operators/Gt.php @@ -49,7 +49,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'gt'; } diff --git a/src/qtism/data/expressions/operators/Gte.php b/src/qtism/data/expressions/operators/Gte.php index 8d6b142d7..a318fac2d 100644 --- a/src/qtism/data/expressions/operators/Gte.php +++ b/src/qtism/data/expressions/operators/Gte.php @@ -49,7 +49,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'gte'; } diff --git a/src/qtism/data/expressions/operators/Index.php b/src/qtism/data/expressions/operators/Index.php index 36a145196..21a2a847d 100644 --- a/src/qtism/data/expressions/operators/Index.php +++ b/src/qtism/data/expressions/operators/Index.php @@ -67,7 +67,7 @@ public function __construct(ExpressionCollection $expressions, $n) * @param int|string $n The index to lookup. It must be an integer or a variable reference. * @throws InvalidArgumentException If $n is not an integer nor a variable reference. */ - public function setN($n) + public function setN($n): void { if (is_int($n) || (is_string($n) && Format::isVariableRef($n))) { $this->n = $n; @@ -90,7 +90,7 @@ public function getN() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'index'; } diff --git a/src/qtism/data/expressions/operators/Inside.php b/src/qtism/data/expressions/operators/Inside.php index 2e4903a4c..9af3103d5 100644 --- a/src/qtism/data/expressions/operators/Inside.php +++ b/src/qtism/data/expressions/operators/Inside.php @@ -80,7 +80,7 @@ public function __construct(ExpressionCollection $expressions, $shape, QtiCoords * @param int $shape A value from the Shape enumeration. * @throws InvalidArgumentException If $shape is not a value from the Shape enumeration. */ - public function setShape($shape) + public function setShape($shape): void { if (in_array($shape, QtiShape::asArray())) { $this->shape = $shape; @@ -95,7 +95,7 @@ public function setShape($shape) * * @return int A value from the Shape enumeration. */ - public function getShape() + public function getShape(): int { return $this->shape; } @@ -105,7 +105,7 @@ public function getShape() * * @param QtiCoords $coords A Coords object. */ - public function setCoords(QtiCoords $coords) + public function setCoords(QtiCoords $coords): void { $this->coords = $coords; } @@ -115,7 +115,7 @@ public function setCoords(QtiCoords $coords) * * @return QtiCoords A Coords object. */ - public function getCoords() + public function getCoords(): QtiCoords { return $this->coords; } @@ -123,7 +123,7 @@ public function getCoords() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'inside'; } diff --git a/src/qtism/data/expressions/operators/IntegerDivide.php b/src/qtism/data/expressions/operators/IntegerDivide.php index 7475814b9..a0b8314dd 100644 --- a/src/qtism/data/expressions/operators/IntegerDivide.php +++ b/src/qtism/data/expressions/operators/IntegerDivide.php @@ -49,7 +49,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'integerDivide'; } diff --git a/src/qtism/data/expressions/operators/IntegerModulus.php b/src/qtism/data/expressions/operators/IntegerModulus.php index 68b511d3a..461e9674a 100644 --- a/src/qtism/data/expressions/operators/IntegerModulus.php +++ b/src/qtism/data/expressions/operators/IntegerModulus.php @@ -50,7 +50,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'integerModulus'; } diff --git a/src/qtism/data/expressions/operators/IntegerToFloat.php b/src/qtism/data/expressions/operators/IntegerToFloat.php index f3188bbc1..bd445e974 100644 --- a/src/qtism/data/expressions/operators/IntegerToFloat.php +++ b/src/qtism/data/expressions/operators/IntegerToFloat.php @@ -53,7 +53,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'integerToFloat'; } diff --git a/src/qtism/data/expressions/operators/IsNull.php b/src/qtism/data/expressions/operators/IsNull.php index bb0d2cebc..813d899ea 100644 --- a/src/qtism/data/expressions/operators/IsNull.php +++ b/src/qtism/data/expressions/operators/IsNull.php @@ -48,7 +48,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'isNull'; } diff --git a/src/qtism/data/expressions/operators/Lcm.php b/src/qtism/data/expressions/operators/Lcm.php index e738ea0f8..36d047f9e 100644 --- a/src/qtism/data/expressions/operators/Lcm.php +++ b/src/qtism/data/expressions/operators/Lcm.php @@ -52,7 +52,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'lcm'; } diff --git a/src/qtism/data/expressions/operators/Lt.php b/src/qtism/data/expressions/operators/Lt.php index f120907c3..44ad76317 100644 --- a/src/qtism/data/expressions/operators/Lt.php +++ b/src/qtism/data/expressions/operators/Lt.php @@ -49,7 +49,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'lt'; } diff --git a/src/qtism/data/expressions/operators/Lte.php b/src/qtism/data/expressions/operators/Lte.php index 77783eccc..16d93c264 100644 --- a/src/qtism/data/expressions/operators/Lte.php +++ b/src/qtism/data/expressions/operators/Lte.php @@ -49,7 +49,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'lte'; } diff --git a/src/qtism/data/expressions/operators/MatchOperator.php b/src/qtism/data/expressions/operators/MatchOperator.php index ab8be7d6c..46fa794db 100644 --- a/src/qtism/data/expressions/operators/MatchOperator.php +++ b/src/qtism/data/expressions/operators/MatchOperator.php @@ -53,7 +53,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'match'; } diff --git a/src/qtism/data/expressions/operators/MathFunctions.php b/src/qtism/data/expressions/operators/MathFunctions.php index d8e48e0a5..335b172d0 100644 --- a/src/qtism/data/expressions/operators/MathFunctions.php +++ b/src/qtism/data/expressions/operators/MathFunctions.php @@ -32,66 +32,66 @@ */ class MathFunctions implements Enumeration { - const SIN = 0; + public const SIN = 0; - const COS = 1; + public const COS = 1; - const TAN = 2; + public const TAN = 2; - const SEC = 3; + public const SEC = 3; - const CSC = 4; + public const CSC = 4; - const COT = 5; + public const COT = 5; - const ASIN = 6; + public const ASIN = 6; - const ACOS = 7; + public const ACOS = 7; - const ATAN = 8; + public const ATAN = 8; - const ATAN2 = 9; + public const ATAN2 = 9; - const ASEC = 10; + public const ASEC = 10; - const ACSC = 11; + public const ACSC = 11; - const ACOT = 12; + public const ACOT = 12; - const SINH = 13; + public const SINH = 13; - const COSH = 14; + public const COSH = 14; - const TANH = 15; + public const TANH = 15; - const SECH = 16; + public const SECH = 16; - const CSCH = 17; + public const CSCH = 17; - const COTH = 18; + public const COTH = 18; - const LOG = 19; + public const LOG = 19; - const LN = 20; + public const LN = 20; - const EXP = 21; + public const EXP = 21; - const ABS = 22; + public const ABS = 22; - const SIGNUM = 23; + public const SIGNUM = 23; - const FLOOR = 24; + public const FLOOR = 24; - const CEIL = 25; + public const CEIL = 25; - const TO_DEGREES = 26; + public const TO_DEGREES = 26; - const TO_RADIANS = 27; + public const TO_RADIANS = 27; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'SIN' => self::SIN, @@ -127,11 +127,12 @@ public static function asArray() /** * @param false|int $name + * * @return bool|int */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'sin': return self::SIN; break; diff --git a/src/qtism/data/expressions/operators/MathOperator.php b/src/qtism/data/expressions/operators/MathOperator.php index 335528785..e28c3c4f4 100644 --- a/src/qtism/data/expressions/operators/MathOperator.php +++ b/src/qtism/data/expressions/operators/MathOperator.php @@ -96,7 +96,7 @@ public function __construct(ExpressionCollection $expressions, $name) * * @return int A value from the MathFunctions enumeration. */ - public function getName() + public function getName(): int { return $this->name; } @@ -107,7 +107,7 @@ public function getName() * @param int $name A value from the MathFunctions enumeration. * @throws InvalidArgumentException If $name is not a value from the MathFunctions enumeration. */ - public function setName($name) + public function setName($name): void { if (in_array($name, MathFunctions::asArray())) { $this->name = $name; @@ -120,7 +120,7 @@ public function setName($name) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'mathOperator'; } diff --git a/src/qtism/data/expressions/operators/Max.php b/src/qtism/data/expressions/operators/Max.php index e85d1edca..66eac5d4a 100644 --- a/src/qtism/data/expressions/operators/Max.php +++ b/src/qtism/data/expressions/operators/Max.php @@ -53,7 +53,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'max'; } diff --git a/src/qtism/data/expressions/operators/Member.php b/src/qtism/data/expressions/operators/Member.php index 82f03cc49..848bf6608 100644 --- a/src/qtism/data/expressions/operators/Member.php +++ b/src/qtism/data/expressions/operators/Member.php @@ -54,7 +54,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'member'; } diff --git a/src/qtism/data/expressions/operators/Min.php b/src/qtism/data/expressions/operators/Min.php index 19d352f4d..003d319ad 100644 --- a/src/qtism/data/expressions/operators/Min.php +++ b/src/qtism/data/expressions/operators/Min.php @@ -52,7 +52,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'min'; } diff --git a/src/qtism/data/expressions/operators/Multiple.php b/src/qtism/data/expressions/operators/Multiple.php index a418f6d17..e33a4cfbc 100644 --- a/src/qtism/data/expressions/operators/Multiple.php +++ b/src/qtism/data/expressions/operators/Multiple.php @@ -55,7 +55,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'multiple'; } diff --git a/src/qtism/data/expressions/operators/NotOperator.php b/src/qtism/data/expressions/operators/NotOperator.php index fbaaffee9..bd28f3cb3 100644 --- a/src/qtism/data/expressions/operators/NotOperator.php +++ b/src/qtism/data/expressions/operators/NotOperator.php @@ -48,7 +48,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'not'; } diff --git a/src/qtism/data/expressions/operators/Operator.php b/src/qtism/data/expressions/operators/Operator.php index e0873ad75..8d4a90801 100644 --- a/src/qtism/data/expressions/operators/Operator.php +++ b/src/qtism/data/expressions/operators/Operator.php @@ -97,7 +97,7 @@ public function __construct(ExpressionCollection $expressions, $minOperands = 0, * @param ExpressionCollection $expressions A collection of $expressions that form the hierarchy of expressions. * @throws InvalidArgumentException If $expressions does not contain at least one Expression object. */ - public function setExpressions(ExpressionCollection $expressions) + public function setExpressions(ExpressionCollection $expressions): void { $this->expressions = $expressions; } @@ -107,7 +107,7 @@ public function setExpressions(ExpressionCollection $expressions) * * @return ExpressionCollection A collection of Expression objects. */ - public function getExpressions() + public function getExpressions(): ExpressionCollection { return $this->expressions; } @@ -115,7 +115,7 @@ public function getExpressions() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = $this->getExpressions()->getArrayCopy(); @@ -128,7 +128,7 @@ public function getComponents() * @param int $minOperands An integer which is >= 0. * @throws InvalidArgumentException If $minOperands is not an integer >= 0. */ - public function setMinOperands($minOperands) + public function setMinOperands($minOperands): void { if (is_int($minOperands) && $minOperands >= 0) { $this->minOperands = $minOperands; @@ -143,7 +143,7 @@ public function setMinOperands($minOperands) * * @return int */ - public function getMinOperands() + public function getMinOperands(): int { return $this->minOperands; } @@ -155,7 +155,7 @@ public function getMinOperands() * @param int $maxOperands * @throws InvalidArgumentException If $maxOperands is not an integer. */ - public function setMaxOperands($maxOperands) + public function setMaxOperands($maxOperands): void { if (is_int($maxOperands)) { $this->maxOperands = $maxOperands; @@ -171,7 +171,7 @@ public function setMaxOperands($maxOperands) * * @return int */ - public function getMaxOperands() + public function getMaxOperands(): int { return $this->maxOperands; } @@ -181,7 +181,7 @@ public function getMaxOperands() * * @return array An array of values from the Cardinality enumeration. */ - public function getAcceptedCardinalities() + public function getAcceptedCardinalities(): array { return $this->acceptedCardinalities; } @@ -192,7 +192,7 @@ public function getAcceptedCardinalities() * @param array $acceptedCardinalities An array of values from the Cardinality enumeration. * @throws InvalidArgumentException If a value from $acceptedCardinalities is not a value from the Cardinality enumeration. */ - public function setAcceptedCardinalities(array $acceptedCardinalities) + public function setAcceptedCardinalities(array $acceptedCardinalities): void { foreach ($acceptedCardinalities as $cardinality) { if (!in_array($cardinality, OperatorCardinality::asArray(), true)) { @@ -209,7 +209,7 @@ public function setAcceptedCardinalities(array $acceptedCardinalities) * * @return array An array of values from OperatorBaseType enumeration. */ - public function getAcceptedBaseTypes() + public function getAcceptedBaseTypes(): array { return $this->acceptedBaseTypes; } @@ -220,7 +220,7 @@ public function getAcceptedBaseTypes() * @param array $acceptedBaseTypes An array of values from the OperatorBaseType enumeration. * @throws InvalidArgumentException If a value from the $acceptedBaseTypes is not a value from the OperatorBaseType. */ - public function setAcceptedBaseTypes(array $acceptedBaseTypes) + public function setAcceptedBaseTypes(array $acceptedBaseTypes): void { foreach ($acceptedBaseTypes as $baseType) { if (!in_array($baseType, OperatorBaseType::asArray(), true)) { @@ -237,7 +237,7 @@ public function setAcceptedBaseTypes(array $acceptedBaseTypes) * * @return bool */ - public function isPure() + public function isPure(): bool { return $this->getExpressions()->isPure(); } diff --git a/src/qtism/data/expressions/operators/OperatorBaseType.php b/src/qtism/data/expressions/operators/OperatorBaseType.php index 8d8b37f83..0ff542b6a 100644 --- a/src/qtism/data/expressions/operators/OperatorBaseType.php +++ b/src/qtism/data/expressions/operators/OperatorBaseType.php @@ -41,7 +41,7 @@ class OperatorBaseType extends BaseType * * @var int */ - const ANY = 13; + public const ANY = 13; /** * Express that all the operands must have the same @@ -49,12 +49,12 @@ class OperatorBaseType extends BaseType * * @var int */ - const SAME = 14; + public const SAME = 14; /** * @return array */ - public static function asArray() + public static function asArray(): array { $values = BaseType::asArray(); $values['ANY'] = self::ANY; diff --git a/src/qtism/data/expressions/operators/OperatorCardinality.php b/src/qtism/data/expressions/operators/OperatorCardinality.php index f68b74200..076b8041e 100644 --- a/src/qtism/data/expressions/operators/OperatorCardinality.php +++ b/src/qtism/data/expressions/operators/OperatorCardinality.php @@ -41,7 +41,7 @@ class OperatorCardinality extends Cardinality * * @var int */ - const SAME = 4; + public const SAME = 4; /** * Express that all the expressions involved in an operator may @@ -49,12 +49,12 @@ class OperatorCardinality extends Cardinality * * @var int */ - const ANY = 5; + public const ANY = 5; /** * @return array */ - public static function asArray() + public static function asArray(): array { $values = Cardinality::asArray(); $values['SAME'] = self::SAME; diff --git a/src/qtism/data/expressions/operators/OrOperator.php b/src/qtism/data/expressions/operators/OrOperator.php index f2705c28d..41f2cd6a5 100644 --- a/src/qtism/data/expressions/operators/OrOperator.php +++ b/src/qtism/data/expressions/operators/OrOperator.php @@ -53,7 +53,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'or'; } diff --git a/src/qtism/data/expressions/operators/Ordered.php b/src/qtism/data/expressions/operators/Ordered.php index a842ee090..caaecf120 100644 --- a/src/qtism/data/expressions/operators/Ordered.php +++ b/src/qtism/data/expressions/operators/Ordered.php @@ -55,7 +55,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'ordered'; } diff --git a/src/qtism/data/expressions/operators/PatternMatch.php b/src/qtism/data/expressions/operators/PatternMatch.php index 62a4faa21..2b9d17917 100644 --- a/src/qtism/data/expressions/operators/PatternMatch.php +++ b/src/qtism/data/expressions/operators/PatternMatch.php @@ -66,7 +66,7 @@ public function __construct(ExpressionCollection $expressions, $pattern) * @param string $pattern A pattern or a variable reference. * @throws InvalidArgumentException If $pattern is not a string value. */ - public function setPattern($pattern) + public function setPattern($pattern): void { if (is_string($pattern)) { $this->pattern = $pattern; @@ -81,7 +81,7 @@ public function setPattern($pattern) * * @return string A pattern or a variable reference. */ - public function getPattern() + public function getPattern(): string { return $this->pattern; } @@ -89,7 +89,7 @@ public function getPattern() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'patternMatch'; } diff --git a/src/qtism/data/expressions/operators/Power.php b/src/qtism/data/expressions/operators/Power.php index 8ad275bdb..60bde9539 100644 --- a/src/qtism/data/expressions/operators/Power.php +++ b/src/qtism/data/expressions/operators/Power.php @@ -52,7 +52,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'power'; } diff --git a/src/qtism/data/expressions/operators/Product.php b/src/qtism/data/expressions/operators/Product.php index 41c179689..8e54da3e5 100644 --- a/src/qtism/data/expressions/operators/Product.php +++ b/src/qtism/data/expressions/operators/Product.php @@ -50,7 +50,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'product'; } diff --git a/src/qtism/data/expressions/operators/Random.php b/src/qtism/data/expressions/operators/Random.php index 5400d24a2..307a2e597 100644 --- a/src/qtism/data/expressions/operators/Random.php +++ b/src/qtism/data/expressions/operators/Random.php @@ -49,7 +49,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'random'; } @@ -61,7 +61,7 @@ public function getQtiClassName() * * @return bool True if the expression is pure, false otherwise */ - public function isPure() + public function isPure(): bool { return false; } diff --git a/src/qtism/data/expressions/operators/Repeat.php b/src/qtism/data/expressions/operators/Repeat.php index 9ea001de7..5ad81d17c 100644 --- a/src/qtism/data/expressions/operators/Repeat.php +++ b/src/qtism/data/expressions/operators/Repeat.php @@ -69,7 +69,7 @@ public function __construct(ExpressionCollection $expressions, $numberRepeats) * @param int|string $numberRepeats An integer or a QTI variable reference. * @throws InvalidArgumentException If $numberRepeats is not an integer nor a valid QTI variable reference. */ - public function setNumberRepeats($numberRepeats) + public function setNumberRepeats($numberRepeats): void { if (is_int($numberRepeats) || (is_string($numberRepeats) && Format::isVariableRef($numberRepeats))) { $this->numberRepeats = $numberRepeats; @@ -92,7 +92,7 @@ public function getNumberRepeats() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'repeat'; } diff --git a/src/qtism/data/expressions/operators/Round.php b/src/qtism/data/expressions/operators/Round.php index a51cdb88c..a59f0ff9d 100644 --- a/src/qtism/data/expressions/operators/Round.php +++ b/src/qtism/data/expressions/operators/Round.php @@ -53,7 +53,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'round'; } diff --git a/src/qtism/data/expressions/operators/RoundTo.php b/src/qtism/data/expressions/operators/RoundTo.php index 720c7ca1f..17ef9888c 100644 --- a/src/qtism/data/expressions/operators/RoundTo.php +++ b/src/qtism/data/expressions/operators/RoundTo.php @@ -98,7 +98,7 @@ public function __construct(ExpressionCollection $expressions, $figures, $roundi * @param int|string $figures An integer or a variable reference. * @throws InvalidArgumentException If $figures is not an integer nor a variable reference. */ - public function setFigures($figures) + public function setFigures($figures): void { if (is_int($figures) || (is_string($figures) && Format::isVariableRef($figures))) { $this->figures = $figures; @@ -124,7 +124,7 @@ public function getFigures() * @param int $roundingMode A value from the RoundingMode enumeration. * @throws InvalidArgumentException If $rounding mode is not a value from the RoundingMode enumeration. */ - public function setRoundingMode($roundingMode) + public function setRoundingMode($roundingMode): void { if (in_array($roundingMode, RoundingMode::asArray())) { $this->roundingMode = $roundingMode; @@ -139,7 +139,7 @@ public function setRoundingMode($roundingMode) * * @return int A value from the RoundingMode enumeration. */ - public function getRoundingMode() + public function getRoundingMode(): int { return $this->roundingMode; } @@ -147,7 +147,7 @@ public function getRoundingMode() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'roundTo'; } diff --git a/src/qtism/data/expressions/operators/RoundingMode.php b/src/qtism/data/expressions/operators/RoundingMode.php index c5df84dc2..ede46627a 100644 --- a/src/qtism/data/expressions/operators/RoundingMode.php +++ b/src/qtism/data/expressions/operators/RoundingMode.php @@ -30,14 +30,14 @@ */ class RoundingMode implements Enumeration { - const SIGNIFICANT_FIGURES = 0; + public const SIGNIFICANT_FIGURES = 0; - const DECIMAL_PLACES = 1; + public const DECIMAL_PLACES = 1; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'SIGNIFICANT_FIGURES' => self::SIGNIFICANT_FIGURES, @@ -51,7 +51,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'significantfigures': return self::SIGNIFICANT_FIGURES; break; diff --git a/src/qtism/data/expressions/operators/Statistics.php b/src/qtism/data/expressions/operators/Statistics.php index de746ad22..cc4d889d5 100644 --- a/src/qtism/data/expressions/operators/Statistics.php +++ b/src/qtism/data/expressions/operators/Statistics.php @@ -38,7 +38,7 @@ class Statistics implements Enumeration * * @var int */ - const MEAN = 0; + public const MEAN = 0; /** * From IMS QTI: @@ -48,7 +48,7 @@ class Statistics implements Enumeration * * @var int */ - const SAMPLE_VARIANCE = 1; + public const SAMPLE_VARIANCE = 1; /** * From IMS QTI: @@ -58,7 +58,7 @@ class Statistics implements Enumeration * * @var int */ - const SAMPLE_SD = 2; + public const SAMPLE_SD = 2; /** * From IMS QTI: @@ -68,7 +68,7 @@ class Statistics implements Enumeration * * @var int */ - const POP_VARIANCE = 3; + public const POP_VARIANCE = 3; /** * From IMS QTI: @@ -78,12 +78,12 @@ class Statistics implements Enumeration * * @var int */ - const POP_SD = 4; + public const POP_SD = 4; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'MEAN' => self::MEAN, @@ -100,7 +100,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'mean': return self::MEAN; break; diff --git a/src/qtism/data/expressions/operators/StatsOperator.php b/src/qtism/data/expressions/operators/StatsOperator.php index 4751c0439..7b0ef50ff 100644 --- a/src/qtism/data/expressions/operators/StatsOperator.php +++ b/src/qtism/data/expressions/operators/StatsOperator.php @@ -65,7 +65,7 @@ public function __construct(ExpressionCollection $expressions, $name) * @param int $name A value from the Statistics enumeration. * @throws InvalidArgumentException If $name is not a value from the Statistics enumeration. */ - public function setName($name) + public function setName($name): void { if (in_array($name, Statistics::asArray())) { $this->name = $name; @@ -80,7 +80,7 @@ public function setName($name) * * @return int A value from the Statistics enumeration. */ - public function getName() + public function getName(): int { return $this->name; } @@ -88,7 +88,7 @@ public function getName() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'statsOperator'; } diff --git a/src/qtism/data/expressions/operators/StringMatch.php b/src/qtism/data/expressions/operators/StringMatch.php index 89d8ff002..6b5613107 100644 --- a/src/qtism/data/expressions/operators/StringMatch.php +++ b/src/qtism/data/expressions/operators/StringMatch.php @@ -80,7 +80,7 @@ public function __construct(ExpressionCollection $expressions, $caseSensitive, $ * @param bool $caseSensitive Case sensitiveness. * @throws InvalidArgumentException If $caseSensitive is not a boolean. */ - public function setCaseSensitive($caseSensitive) + public function setCaseSensitive($caseSensitive): void { if (is_bool($caseSensitive)) { $this->caseSensitive = $caseSensitive; @@ -95,7 +95,7 @@ public function setCaseSensitive($caseSensitive) * * @return bool True if it has to, false otherwise. */ - public function isCaseSensitive() + public function isCaseSensitive(): bool { return $this->caseSensitive; } @@ -107,7 +107,7 @@ public function isCaseSensitive() * @throws InvalidArgumentException If $substring is not a boolean. * @deprecated */ - public function setSubstring($substring) + public function setSubstring($substring): void { if (is_bool($substring)) { $this->substring = $substring; @@ -123,7 +123,7 @@ public function setSubstring($substring) * @return bool * @deprecated */ - public function mustSubstring() + public function mustSubstring(): bool { return $this->substring; } @@ -131,7 +131,7 @@ public function mustSubstring() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'stringMatch'; } diff --git a/src/qtism/data/expressions/operators/Substring.php b/src/qtism/data/expressions/operators/Substring.php index f8afe7600..6b409ff81 100644 --- a/src/qtism/data/expressions/operators/Substring.php +++ b/src/qtism/data/expressions/operators/Substring.php @@ -69,7 +69,7 @@ public function __construct(ExpressionCollection $expressions, $caseSensitive = * @param bool $caseSensitive A boolean value. * @throws InvalidArgumentException If $caseSensitive is not a boolean value. */ - public function setCaseSensitive($caseSensitive) + public function setCaseSensitive($caseSensitive): void { if (is_bool($caseSensitive)) { $this->caseSensitive = $caseSensitive; @@ -84,7 +84,7 @@ public function setCaseSensitive($caseSensitive) * * @return bool */ - public function isCaseSensitive() + public function isCaseSensitive(): bool { return $this->caseSensitive; } @@ -92,7 +92,7 @@ public function isCaseSensitive() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'substring'; } diff --git a/src/qtism/data/expressions/operators/Subtract.php b/src/qtism/data/expressions/operators/Subtract.php index e99de45b3..dbddc6bf3 100644 --- a/src/qtism/data/expressions/operators/Subtract.php +++ b/src/qtism/data/expressions/operators/Subtract.php @@ -49,7 +49,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'subtract'; } diff --git a/src/qtism/data/expressions/operators/Sum.php b/src/qtism/data/expressions/operators/Sum.php index 54e4bac55..8dd692e0c 100644 --- a/src/qtism/data/expressions/operators/Sum.php +++ b/src/qtism/data/expressions/operators/Sum.php @@ -50,7 +50,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'sum'; } diff --git a/src/qtism/data/expressions/operators/ToleranceMode.php b/src/qtism/data/expressions/operators/ToleranceMode.php index 5450e5ce4..d225b67d7 100644 --- a/src/qtism/data/expressions/operators/ToleranceMode.php +++ b/src/qtism/data/expressions/operators/ToleranceMode.php @@ -30,16 +30,16 @@ */ class ToleranceMode implements Enumeration { - const EXACT = 0; + public const EXACT = 0; - const ABSOLUTE = 1; + public const ABSOLUTE = 1; - const RELATIVE = 2; + public const RELATIVE = 2; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'EXACT' => self::EXACT, @@ -54,7 +54,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'exact': return self::EXACT; break; diff --git a/src/qtism/data/expressions/operators/Truncate.php b/src/qtism/data/expressions/operators/Truncate.php index 08a47b926..5861ae314 100644 --- a/src/qtism/data/expressions/operators/Truncate.php +++ b/src/qtism/data/expressions/operators/Truncate.php @@ -51,7 +51,7 @@ public function __construct(ExpressionCollection $expressions) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'truncate'; } diff --git a/src/qtism/data/processing/OutcomeProcessing.php b/src/qtism/data/processing/OutcomeProcessing.php index 90664512f..430f71f4c 100644 --- a/src/qtism/data/processing/OutcomeProcessing.php +++ b/src/qtism/data/processing/OutcomeProcessing.php @@ -71,7 +71,7 @@ public function __construct(OutcomeRuleCollection $outcomeRules = null) * * @return OutcomeRuleCollection A collection of OutcomeRule object. */ - public function getOutcomeRules() + public function getOutcomeRules(): OutcomeRuleCollection { return $this->outcomeRules; } @@ -81,7 +81,7 @@ public function getOutcomeRules() * * @param OutcomeRuleCollection $outcomeRules A collection of OutcomeRule objects. */ - public function setOutcomeRules(OutcomeRuleCollection $outcomeRules) + public function setOutcomeRules(OutcomeRuleCollection $outcomeRules): void { $this->outcomeRules = $outcomeRules; } @@ -89,7 +89,7 @@ public function setOutcomeRules(OutcomeRuleCollection $outcomeRules) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'outcomeProcessing'; } @@ -97,7 +97,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection($this->getOutcomeRules()->getArrayCopy()); } diff --git a/src/qtism/data/processing/ResponseProcessing.php b/src/qtism/data/processing/ResponseProcessing.php index 0dc1e08e9..2c47cde7d 100644 --- a/src/qtism/data/processing/ResponseProcessing.php +++ b/src/qtism/data/processing/ResponseProcessing.php @@ -97,7 +97,7 @@ public function __construct(ResponseRuleCollection $responseRules = null) * * @return ResponseRuleCollection A collection of ResponseRule objects. */ - public function getResponseRules() + public function getResponseRules(): ResponseRuleCollection { return $this->responseRules; } @@ -107,7 +107,7 @@ public function getResponseRules() * * @param ResponseRuleCollection $responseRules A collection of ResponseRule objects. */ - public function setResponseRules(ResponseRuleCollection $responseRules) + public function setResponseRules(ResponseRuleCollection $responseRules): void { $this->responseRules = $responseRules; } @@ -118,7 +118,7 @@ public function setResponseRules(ResponseRuleCollection $responseRules) * * @return string The URI of the response processing template. */ - public function getTemplate() + public function getTemplate(): string { return $this->template; } @@ -128,7 +128,7 @@ public function getTemplate() * * @return bool */ - public function hasTemplate() + public function hasTemplate(): bool { return $this->getTemplate() !== ''; } @@ -140,7 +140,7 @@ public function hasTemplate() * @param string $template The URI of the template. * @throws InvalidArgumentException If $template is not a valid URI nor an empty string. */ - public function setTemplate($template) + public function setTemplate($template): void { if (Format::isUri($template) === true || (is_string($template) && empty($template))) { $this->template = $template; @@ -156,7 +156,7 @@ public function setTemplate($template) * * @return string The URI of the response processing template location. */ - public function getTemplateLocation() + public function getTemplateLocation(): string { return $this->templateLocation; } @@ -166,7 +166,7 @@ public function getTemplateLocation() * * @return bool */ - public function hasTemplateLocation() + public function hasTemplateLocation(): bool { return $this->getTemplateLocation() !== ''; } @@ -178,7 +178,7 @@ public function hasTemplateLocation() * @param string $templateLocation The URI of the template location. * @throws InvalidArgumentException If $templateLocation is not a valid URI nor an empty string. */ - public function setTemplateLocation($templateLocation) + public function setTemplateLocation($templateLocation): void { if (Format::isUri($templateLocation) === true || (is_string($templateLocation) && empty($templateLocation))) { $this->templateLocation = $templateLocation; @@ -191,7 +191,7 @@ public function setTemplateLocation($templateLocation) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'responseProcessing'; } @@ -199,7 +199,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection($this->getResponseRules()->getArrayCopy()); } diff --git a/src/qtism/data/processing/TemplateProcessing.php b/src/qtism/data/processing/TemplateProcessing.php index 80427584a..6b4c06cf3 100644 --- a/src/qtism/data/processing/TemplateProcessing.php +++ b/src/qtism/data/processing/TemplateProcessing.php @@ -65,7 +65,7 @@ public function __construct(TemplateRuleCollection $templateRules) * @param TemplateRuleCollection $templateRules A collection of at least one TemplateRule object. * @throws InvalidArgumentException If $templateRules is an empty collection. */ - public function setTemplateRules(TemplateRuleCollection $templateRules) + public function setTemplateRules(TemplateRuleCollection $templateRules): void { if (count($templateRules) > 0) { $this->templateRules = $templateRules; @@ -81,7 +81,7 @@ public function setTemplateRules(TemplateRuleCollection $templateRules) * * @return TemplateRuleCollection A collection of at least one TemplateRule object. */ - public function getTemplateRules() + public function getTemplateRules(): TemplateRuleCollection { return $this->templateRules; } @@ -89,7 +89,7 @@ public function getTemplateRules() /** * @return QtiComponentCollection|TemplateRuleCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return $this->getTemplateRules(); } @@ -97,7 +97,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'templateProcessing'; } diff --git a/src/qtism/data/results/AssessmentResult.php b/src/qtism/data/results/AssessmentResult.php index f5d977fef..0aaf51e2d 100644 --- a/src/qtism/data/results/AssessmentResult.php +++ b/src/qtism/data/results/AssessmentResult.php @@ -87,7 +87,7 @@ public function __construct(Context $context, TestResult $testResult = null, Ite * * @return string A QTI class name. */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'assessmentResult'; } @@ -97,7 +97,7 @@ public function getQtiClassName() * * @return QtiComponentCollection A collection of QtiComponent objects. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $components = [ $this->getContext(), @@ -121,7 +121,7 @@ public function getComponents() * * @return Context */ - public function getContext() + public function getContext(): Context { return $this->context; } @@ -141,9 +141,9 @@ public function setContext(Context $context) /** * Get the test result * - * @return TestResult + * @return TestResult|null */ - public function getTestResult() + public function getTestResult(): ?TestResult { return $this->testResult; } @@ -165,7 +165,7 @@ public function setTestResult(TestResult $testResult = null) * * @return bool */ - public function hasTestResult() + public function hasTestResult(): bool { return $this->testResult !== null; } @@ -173,9 +173,9 @@ public function hasTestResult() /** * Get the item results * - * @return ItemResultCollection + * @return ItemResultCollection|null */ - public function getItemResults() + public function getItemResults(): ?ItemResultCollection { return $this->itemResults; } @@ -197,7 +197,7 @@ public function setItemResults(ItemResultCollection $itemResults = null) * * @return bool */ - public function hasItemResults() + public function hasItemResults(): bool { return $this->itemResults !== null; } diff --git a/src/qtism/data/results/CandidateResponse.php b/src/qtism/data/results/CandidateResponse.php index 893f08b7a..48427a9e5 100644 --- a/src/qtism/data/results/CandidateResponse.php +++ b/src/qtism/data/results/CandidateResponse.php @@ -59,7 +59,7 @@ public function __construct(ValueCollection $values = null) * * @return string A QTI class name. */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'candidateResponse'; } @@ -69,7 +69,7 @@ public function getQtiClassName() * * @return QtiComponentCollection A collection of QtiComponent objects. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $components = []; if ($this->hasValues()) { @@ -79,11 +79,11 @@ public function getComponents() } /** - * Get candidate response values + * Get candidate response values. * - * @return ValueCollection + * @return ValueCollection|null */ - public function getValues() + public function getValues(): ?ValueCollection { return $this->values; } @@ -105,7 +105,7 @@ public function setValues(ValueCollection $values = null) * * @return bool */ - public function hasValues() + public function hasValues(): bool { return $this->values !== null; } diff --git a/src/qtism/data/results/Context.php b/src/qtism/data/results/Context.php index d550604e4..d97fd89b2 100644 --- a/src/qtism/data/results/Context.php +++ b/src/qtism/data/results/Context.php @@ -77,7 +77,7 @@ public function __construct(QtiIdentifier $sourcedId = null, SessionIdentifierCo * * @return string A QTI class name. */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'context'; } @@ -87,7 +87,7 @@ public function getQtiClassName() * * @return QtiComponentCollection A collection of QtiComponent objects. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { if ($this->hasSessionIdentifiers()) { $components = $this->getSessionIdentifiers()->getArrayCopy(); @@ -102,7 +102,7 @@ public function getComponents() * * @return QtiIdentifier|null */ - public function getSourcedId() + public function getSourcedId(): ?QtiIdentifier { return $this->sourcedId; } @@ -124,7 +124,7 @@ public function setSourcedId(QtiIdentifier $sourcedId = null) * * @return bool */ - public function hasSourcedId() + public function hasSourcedId(): bool { return $this->sourcedId !== null; } @@ -134,7 +134,7 @@ public function hasSourcedId() * * @return SessionIdentifierCollection */ - public function getSessionIdentifiers() + public function getSessionIdentifiers(): SessionIdentifierCollection { return $this->sessionIdentifiers; } @@ -184,7 +184,7 @@ public function addSessionIdentifier(string $sourceId, string $identifier): self * * @return bool */ - public function hasSessionIdentifiers() + public function hasSessionIdentifiers(): bool { return (bool)$this->sessionIdentifiers->count(); } diff --git a/src/qtism/data/results/ItemResult.php b/src/qtism/data/results/ItemResult.php index b25147f30..613571391 100644 --- a/src/qtism/data/results/ItemResult.php +++ b/src/qtism/data/results/ItemResult.php @@ -145,7 +145,7 @@ public function __construct( * * @return string A QTI class name. */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'itemResult'; } @@ -155,7 +155,7 @@ public function getQtiClassName() * * @return QtiComponentCollection A collection of QtiComponent objects. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { if ($this->hasItemVariables()) { $components = $this->getItemVariables()->toArray(); @@ -170,7 +170,7 @@ public function getComponents() * * @return QtiIdentifier */ - public function getIdentifier() + public function getIdentifier(): QtiIdentifier { return $this->identifier; } @@ -192,7 +192,7 @@ public function setIdentifier(QtiIdentifier $identifier) * * @return DateTime */ - public function getDatestamp() + public function getDatestamp(): DateTime { return $this->datestamp; } @@ -203,7 +203,7 @@ public function getDatestamp() * @param DateTime $datestamp * @return $this */ - public function setDatestamp(DateTime $datestamp) + public function setDatestamp(DateTime $datestamp): self { $this->datestamp = $datestamp; return $this; @@ -212,9 +212,9 @@ public function setDatestamp(DateTime $datestamp) /** * Get all test variables. Can be outcome, response, candidate or tempalte variable * - * @return ItemVariableCollection + * @return ItemVariableCollection|null */ - public function getItemVariables() + public function getItemVariables(): ?ItemVariableCollection { return $this->itemVariables; } @@ -225,7 +225,7 @@ public function getItemVariables() * @param ItemVariableCollection $itemVariables * @return $this */ - public function setItemVariables(ItemVariableCollection $itemVariables = null) + public function setItemVariables(ItemVariableCollection $itemVariables = null): self { $this->itemVariables = $itemVariables; return $this; @@ -236,7 +236,7 @@ public function setItemVariables(ItemVariableCollection $itemVariables = null) * * @return bool */ - public function hasItemVariables() + public function hasItemVariables(): bool { return $this->itemVariables !== null; } @@ -244,9 +244,9 @@ public function hasItemVariables() /** * Get the sequence of the item e.g. the position of the item in a test * - * @return QtiInteger + * @return QtiInteger|null */ - public function getSequenceIndex() + public function getSequenceIndex(): ?QtiInteger { return $this->sequenceIndex; } @@ -268,7 +268,7 @@ public function setSequenceIndex(QtiInteger $sequenceIndex = null) * * @return bool */ - public function hasSequenceIndex() + public function hasSequenceIndex(): bool { return $this->sequenceIndex !== null; } @@ -291,7 +291,7 @@ public function getSessionStatus() * * @throws InvalidArgumentException If the sessionStatus is not a valid sessionStatus */ - public function setSessionStatus($sessionStatus) + public function setSessionStatus($sessionStatus): self { $sessionStatus = (int)$sessionStatus; if (!in_array($sessionStatus, SessionStatus::asArray(), true)) { @@ -305,9 +305,9 @@ public function setSessionStatus($sessionStatus) /** * Get the optional candidate comment or null if not set * - * @return string + * @return QtiString|string|null */ - public function getCandidateComment() + public function getCandidateComment(): ?QtiString { return $this->candidateComment; } @@ -318,7 +318,7 @@ public function getCandidateComment() * @param QtiString $candidateComment * @return $this */ - public function setCandidateComment(QtiString $candidateComment = null) + public function setCandidateComment(QtiString $candidateComment = null): self { $this->candidateComment = $candidateComment; return $this; @@ -329,7 +329,7 @@ public function setCandidateComment(QtiString $candidateComment = null) * * @return bool */ - public function hasCandidateComment() + public function hasCandidateComment(): bool { return $this->candidateComment !== null; } diff --git a/src/qtism/data/results/ItemResultCollection.php b/src/qtism/data/results/ItemResultCollection.php index 9f8e2ea61..71da8bd62 100644 --- a/src/qtism/data/results/ItemResultCollection.php +++ b/src/qtism/data/results/ItemResultCollection.php @@ -37,7 +37,7 @@ class ItemResultCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of ItemResult. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof ItemResult) { throw new InvalidArgumentException(sprintf( diff --git a/src/qtism/data/results/ItemVariable.php b/src/qtism/data/results/ItemVariable.php index 3fab8b648..a446bde5b 100644 --- a/src/qtism/data/results/ItemVariable.php +++ b/src/qtism/data/results/ItemVariable.php @@ -83,7 +83,7 @@ public function __construct(QtiIdentifier $identifier, $cardinality, $baseType = * * @return QtiIdentifier An identifier. */ - public function getIdentifier() + public function getIdentifier(): QtiIdentifier { return $this->identifier; } @@ -105,7 +105,7 @@ public function setIdentifier(QtiIdentifier $identifier) * * @return int */ - public function getCardinality() + public function getCardinality(): int { return $this->cardinality; } @@ -131,9 +131,9 @@ public function setCardinality($cardinality) /** * Get the baseType of the Variable. * - * @return int A value from the Cardinality enumeration. + * @return int|null A value from the Cardinality enumeration. */ - public function getBaseType() + public function getBaseType(): ?int { return $this->baseType; } @@ -161,7 +161,7 @@ public function setBaseType($baseType = null) * * @return bool */ - public function hasBaseType() + public function hasBaseType(): bool { return $this->baseType !== null; } diff --git a/src/qtism/data/results/ItemVariableCollection.php b/src/qtism/data/results/ItemVariableCollection.php index ab5e5d374..1543ec5ce 100644 --- a/src/qtism/data/results/ItemVariableCollection.php +++ b/src/qtism/data/results/ItemVariableCollection.php @@ -37,7 +37,7 @@ class ItemVariableCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of ItemResult. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof ItemVariable) { throw new InvalidArgumentException(sprintf( diff --git a/src/qtism/data/results/ResultOutcomeVariable.php b/src/qtism/data/results/ResultOutcomeVariable.php index a70ad7bd4..38e63bb18 100644 --- a/src/qtism/data/results/ResultOutcomeVariable.php +++ b/src/qtism/data/results/ResultOutcomeVariable.php @@ -148,7 +148,7 @@ public function __construct( * * @return string A QTI class name. */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'outcomeVariable'; } @@ -158,7 +158,7 @@ public function getQtiClassName() * * @return QtiComponentCollection A collection of QtiComponent objects. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $components = []; if ($this->hasValues()) { @@ -170,9 +170,9 @@ public function getComponents() /** * Get the outcome values * - * @return ValueCollection + * @return ValueCollection|null */ - public function getValues() + public function getValues(): ?ValueCollection { return $this->values; } @@ -183,7 +183,7 @@ public function getValues() * @param ValueCollection $values * @return $this */ - public function setValues(ValueCollection $values = null) + public function setValues(ValueCollection $values = null): self { $this->values = $values; return $this; @@ -194,7 +194,7 @@ public function setValues(ValueCollection $values = null) * * @return bool */ - public function hasValues() + public function hasValues(): bool { return $this->values !== null; } @@ -202,9 +202,9 @@ public function hasValues() /** * Get the view * - * @return int + * @return int|null */ - public function getView() + public function getView(): ?int { return $this->view; } @@ -216,7 +216,7 @@ public function getView() * @return $this * @throws InvalidArgumentException */ - public function setView($view = null) + public function setView($view = null): self { if ($view !== null && !in_array($view, View::asArray())) { $msg = sprintf('Invalid View. Should be one of "%s"', implode('", "', View::asArray())); @@ -231,7 +231,7 @@ public function setView($view = null) * * @return bool */ - public function hasView() + public function hasView(): bool { return $this->view !== null; } @@ -239,9 +239,9 @@ public function hasView() /** * Set the interpretation * - * @return QtiString + * @return QtiString|null */ - public function getInterpretation() + public function getInterpretation(): ?QtiString { return $this->interpretation; } @@ -252,7 +252,7 @@ public function getInterpretation() * @param QtiString $interpretation * @return $this */ - public function setInterpretation(QtiString $interpretation = null) + public function setInterpretation(QtiString $interpretation = null): self { $this->interpretation = $interpretation; return $this; @@ -263,7 +263,7 @@ public function setInterpretation(QtiString $interpretation = null) * * @return bool */ - public function hasInterpretation() + public function hasInterpretation(): bool { return $this->interpretation !== null; } @@ -271,9 +271,9 @@ public function hasInterpretation() /** * Get the long interpretation * - * @return QtiUri + * @return QtiUri|null */ - public function getLongInterpretation() + public function getLongInterpretation(): ?QtiUri { return $this->longInterpretation; } @@ -284,7 +284,7 @@ public function getLongInterpretation() * @param QtiUri $longInterpretation * @return $this */ - public function setLongInterpretation(QtiUri $longInterpretation = null) + public function setLongInterpretation(QtiUri $longInterpretation = null): self { $this->longInterpretation = $longInterpretation; return $this; @@ -295,7 +295,7 @@ public function setLongInterpretation(QtiUri $longInterpretation = null) * * @return bool */ - public function hasLongInterpretation() + public function hasLongInterpretation(): bool { return $this->longInterpretation !== null; } @@ -303,9 +303,9 @@ public function hasLongInterpretation() /** * Get the normal maximum * - * @return QtiFloat + * @return QtiFloat|null */ - public function getNormalMaximum() + public function getNormalMaximum(): ?QtiFloat { return $this->normalMaximum; } @@ -316,7 +316,7 @@ public function getNormalMaximum() * @param QtiFloat $normalMaximum * @return $this */ - public function setNormalMaximum(QtiFloat $normalMaximum = null) + public function setNormalMaximum(QtiFloat $normalMaximum = null): self { $this->normalMaximum = $normalMaximum; return $this; @@ -327,7 +327,7 @@ public function setNormalMaximum(QtiFloat $normalMaximum = null) * * @return bool */ - public function hasNormalMaximum() + public function hasNormalMaximum(): bool { return $this->normalMaximum !== null; } @@ -335,9 +335,9 @@ public function hasNormalMaximum() /** * Get the normal minimum * - * @return QtiFloat + * @return QtiFloat|null */ - public function getNormalMinimum() + public function getNormalMinimum(): ?QtiFloat { return $this->normalMinimum; } @@ -348,7 +348,7 @@ public function getNormalMinimum() * @param QtiFloat $normalMinimum * @return $this */ - public function setNormalMinimum(QtiFloat $normalMinimum = null) + public function setNormalMinimum(QtiFloat $normalMinimum = null): self { $this->normalMinimum = $normalMinimum; return $this; @@ -359,7 +359,7 @@ public function setNormalMinimum(QtiFloat $normalMinimum = null) * * @return bool */ - public function hasNormalMinimum() + public function hasNormalMinimum(): bool { return $this->normalMinimum !== null; } @@ -367,9 +367,9 @@ public function hasNormalMinimum() /** * Get the mastery value * - * @return QtiFloat + * @return QtiFloat|null */ - public function getMasteryValue() + public function getMasteryValue(): ?QtiFloat { return $this->masteryValue; } @@ -380,7 +380,7 @@ public function getMasteryValue() * @param QtiFloat $masteryValue * @return $this */ - public function setMasteryValue(QtiFloat $masteryValue = null) + public function setMasteryValue(QtiFloat $masteryValue = null): self { $this->masteryValue = $masteryValue; return $this; @@ -391,7 +391,7 @@ public function setMasteryValue(QtiFloat $masteryValue = null) * * @return bool */ - public function hasMasteryValue() + public function hasMasteryValue(): bool { return $this->masteryValue !== null; } diff --git a/src/qtism/data/results/ResultResponseVariable.php b/src/qtism/data/results/ResultResponseVariable.php index 202dacc0a..5b88127c4 100644 --- a/src/qtism/data/results/ResultResponseVariable.php +++ b/src/qtism/data/results/ResultResponseVariable.php @@ -95,7 +95,7 @@ public function __construct( * * @return string A QTI class name. */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'responseVariable'; } @@ -105,7 +105,7 @@ public function getQtiClassName() * * @return QtiComponentCollection A collection of QtiComponent objects. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $components = [$this->getCandidateResponse()]; if ($this->hasCorrectResponse()) { @@ -119,7 +119,7 @@ public function getComponents() * * @return CandidateResponse */ - public function getCandidateResponse() + public function getCandidateResponse(): CandidateResponse { return $this->candidateResponse; } @@ -139,9 +139,9 @@ public function setCandidateResponse(CandidateResponse $candidateResponse) /** * Get the correct response * - * @return CorrectResponse + * @return CorrectResponse|null */ - public function getCorrectResponse() + public function getCorrectResponse(): ?CorrectResponse { return $this->correctResponse; } @@ -163,7 +163,7 @@ public function setCorrectResponse(CorrectResponse $correctResponse = null) * * @return bool */ - public function hasCorrectResponse() + public function hasCorrectResponse(): bool { return $this->correctResponse !== null; } @@ -171,9 +171,9 @@ public function hasCorrectResponse() /** * Get the choice sequence * - * @return QtiIdentifier + * @return QtiIdentifier|null */ - public function getChoiceSequence() + public function getChoiceSequence(): ?QtiIdentifier { return $this->choiceSequence; } @@ -195,7 +195,7 @@ public function setChoiceSequence(QtiIdentifier $choiceSequence = null) * * @return bool */ - public function hasChoiceSequence() + public function hasChoiceSequence(): bool { return $this->choiceSequence !== null; } diff --git a/src/qtism/data/results/ResultTemplateVariable.php b/src/qtism/data/results/ResultTemplateVariable.php index 38f0f2e9a..b70d9898b 100644 --- a/src/qtism/data/results/ResultTemplateVariable.php +++ b/src/qtism/data/results/ResultTemplateVariable.php @@ -63,7 +63,7 @@ public function __construct(QtiIdentifier $identifier, $cardinality, $baseType = * * @return string A QTI class name. */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'templateVariable'; } @@ -73,7 +73,7 @@ public function getQtiClassName() * * @return QtiComponentCollection A collection of QtiComponent objects. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $components = []; if ($this->hasValues()) { @@ -85,9 +85,9 @@ public function getComponents() /** * Get the template values * - * @return ValueCollection + * @return ValueCollection|null */ - public function getValues() + public function getValues(): ?ValueCollection { return $this->values; } @@ -98,7 +98,7 @@ public function getValues() * @param ValueCollection $values * @return $this */ - public function setValues(ValueCollection $values = null) + public function setValues(ValueCollection $values = null): self { $this->values = $values; return $this; @@ -109,7 +109,7 @@ public function setValues(ValueCollection $values = null) * * @return bool */ - public function hasValues() + public function hasValues(): bool { return $this->values !== null; } diff --git a/src/qtism/data/results/SessionIdentifier.php b/src/qtism/data/results/SessionIdentifier.php index 05ac4f007..19990ef20 100644 --- a/src/qtism/data/results/SessionIdentifier.php +++ b/src/qtism/data/results/SessionIdentifier.php @@ -75,7 +75,7 @@ public function __construct(QtiUri $sourceID, QtiIdentifier $identifier) * * @return string A QTI class name. */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'sessionIdentifier'; } @@ -85,7 +85,7 @@ public function getQtiClassName() * * @return QtiComponentCollection A collection of QtiComponent objects. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } @@ -95,7 +95,7 @@ public function getComponents() * * @return QtiUri */ - public function getSourceID() + public function getSourceID(): QtiUri { return $this->sourceID; } @@ -117,7 +117,7 @@ public function setSourceID(QtiUri $sourceID) * * @return QtiIdentifier */ - public function getIdentifier() + public function getIdentifier(): QtiIdentifier { return $this->identifier; } diff --git a/src/qtism/data/results/SessionIdentifierCollection.php b/src/qtism/data/results/SessionIdentifierCollection.php index 7007a17ac..b956af984 100644 --- a/src/qtism/data/results/SessionIdentifierCollection.php +++ b/src/qtism/data/results/SessionIdentifierCollection.php @@ -37,7 +37,7 @@ class SessionIdentifierCollection extends QtiComponentCollection * @param mixed $value The value of which we want to test the type. * @throws InvalidArgumentException If the given $value is not an instance of SessionIdentifier. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof SessionIdentifier) { throw new InvalidArgumentException(sprintf( diff --git a/src/qtism/data/results/SessionStatus.php b/src/qtism/data/results/SessionStatus.php index 7715c9b91..422c0d236 100644 --- a/src/qtism/data/results/SessionStatus.php +++ b/src/qtism/data/results/SessionStatus.php @@ -34,20 +34,20 @@ class SessionStatus implements Enumeration * The value to use when the item variables represent the values at the end of an attempt after response processing has taken place. * In other words, after the outcome values have been updated to reflect the values of the response variables. */ - const STATUS_FINAL = 0; + public const STATUS_FINAL = 0; /** * The value to use for sessions in the initial state, as described above. This value can only be used to describe sessions * for which the response variable numAttempts is 0. The values of the variables are set according to the rules * defined in the appropriate declarations (see responseDeclaration, outcomeDeclaration and templateDeclaration). */ - const STATUS_INITIAL = 1; + public const STATUS_INITIAL = 1; /** * The value to use when the item variables represent the values of the response variables after submission but before response processing has taken place. * Again, the outcomes are those assigned at the end of the previous attempt as they are awaiting response processing. */ - const STATUS_PENDING_RESPONSE_PROCESSING = 2; + public const STATUS_PENDING_RESPONSE_PROCESSING = 2; /** * The value to use when the item variables represent a snapshot of the current values during an attempt @@ -56,14 +56,14 @@ class SessionStatus implements Enumeration * The values of the outcome variables represent the values assigned during response processing at the end of the previous attempt or, * in the case of the first attempt, the default values given in the variable declarations. */ - const STATUS_PENDING_SUBMISSION = 3; + public const STATUS_PENDING_SUBMISSION = 3; /** * Get the array representation of SessionStatuses * * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'STATUS_FINAL' => self::STATUS_FINAL, @@ -82,7 +82,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'final': return self::STATUS_FINAL; break; diff --git a/src/qtism/data/results/TestResult.php b/src/qtism/data/results/TestResult.php index ba1a228bd..7c0bd6a23 100644 --- a/src/qtism/data/results/TestResult.php +++ b/src/qtism/data/results/TestResult.php @@ -87,7 +87,7 @@ public function __construct(QtiIdentifier $identifier, DateTime $datestamp, Item * * @return string A QTI class name. */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'testResult'; } @@ -97,7 +97,7 @@ public function getQtiClassName() * * @return QtiComponentCollection A collection of QtiComponent objects. */ - public function getComponents() + public function getComponents(): QtiComponentCollection { if ($this->hasItemVariables()) { $components = $this->getItemVariables()->toArray(); @@ -112,7 +112,7 @@ public function getComponents() * * @return QtiIdentifier */ - public function getIdentifier() + public function getIdentifier(): QtiIdentifier { return $this->identifier; } @@ -134,7 +134,7 @@ public function setIdentifier(QtiIdentifier $identifier) * * @return DateTime */ - public function getDatestamp() + public function getDatestamp(): DateTime { return $this->datestamp; } @@ -154,9 +154,9 @@ public function setDatestamp(DateTime $datestamp) /** * Get all test variables. Can be outcome, response, candidate or tempalte variable * - * @return ItemVariableCollection + * @return ItemVariableCollection|null */ - public function getItemVariables() + public function getItemVariables(): ?ItemVariableCollection { return $this->itemVariables; } @@ -178,7 +178,7 @@ public function setItemVariables(ItemVariableCollection $itemVariables = null) * * @return bool */ - public function hasItemVariables() + public function hasItemVariables(): bool { return $this->itemVariables !== null; } diff --git a/src/qtism/data/results/TestResultCollection.php b/src/qtism/data/results/TestResultCollection.php index ef6665fcb..e5206dbea 100644 --- a/src/qtism/data/results/TestResultCollection.php +++ b/src/qtism/data/results/TestResultCollection.php @@ -37,7 +37,7 @@ class TestResultCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of ItemResult. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof TestResult) { $msg = "TestResultCollection only accepts to store TestResult objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/rules/BranchRule.php b/src/qtism/data/rules/BranchRule.php index c21ff1893..d6eaed45f 100644 --- a/src/qtism/data/rules/BranchRule.php +++ b/src/qtism/data/rules/BranchRule.php @@ -88,7 +88,7 @@ public function __construct(Expression $expression, $target) * * @return Expression A QTI Expression. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -98,7 +98,7 @@ public function getExpression() * * @param Expression $expression A QTI Expression. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -108,7 +108,7 @@ public function setExpression(Expression $expression) * * @return string A QTI Identifier. */ - public function getTarget() + public function getTarget(): string { return $this->target; } @@ -119,7 +119,7 @@ public function getTarget() * @param string $target A QTI Identifier. * @throws InvalidArgumentException If $target is not a valid QTI Identifier. */ - public function setTarget($target) + public function setTarget($target): void { if (Format::isIdentifier($target)) { $this->target = $target; @@ -132,7 +132,7 @@ public function setTarget($target) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'branchRule'; } @@ -140,7 +140,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = [$this->getExpression()]; diff --git a/src/qtism/data/rules/BranchRuleCollection.php b/src/qtism/data/rules/BranchRuleCollection.php index aa84025a5..39e17c052 100644 --- a/src/qtism/data/rules/BranchRuleCollection.php +++ b/src/qtism/data/rules/BranchRuleCollection.php @@ -37,7 +37,7 @@ class BranchRuleCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of BranchRule. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof BranchRule) { $msg = "BranchRuleCollection only accepts to store BranchRule objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/rules/ExitResponse.php b/src/qtism/data/rules/ExitResponse.php index d72dd60a8..424f7be58 100644 --- a/src/qtism/data/rules/ExitResponse.php +++ b/src/qtism/data/rules/ExitResponse.php @@ -40,7 +40,7 @@ class ExitResponse extends QtiComponent implements ResponseRule /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'exitResponse'; } @@ -55,7 +55,7 @@ public function __construct() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/rules/ExitTemplate.php b/src/qtism/data/rules/ExitTemplate.php index fd774ab7a..79171a4a7 100644 --- a/src/qtism/data/rules/ExitTemplate.php +++ b/src/qtism/data/rules/ExitTemplate.php @@ -43,7 +43,7 @@ public function __construct() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'exitTemplate'; } @@ -51,7 +51,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/rules/ExitTest.php b/src/qtism/data/rules/ExitTest.php index d861fab96..5938d1b5c 100644 --- a/src/qtism/data/rules/ExitTest.php +++ b/src/qtism/data/rules/ExitTest.php @@ -36,7 +36,7 @@ class ExitTest extends QtiComponent implements OutcomeRule /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'exitTest'; } @@ -51,7 +51,7 @@ public function __construct() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/rules/LookupOutcomeValue.php b/src/qtism/data/rules/LookupOutcomeValue.php index e07d2f9c8..31e694688 100644 --- a/src/qtism/data/rules/LookupOutcomeValue.php +++ b/src/qtism/data/rules/LookupOutcomeValue.php @@ -76,7 +76,7 @@ public function __construct($identifier, Expression $expression) * * @return string A QTI Identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -87,7 +87,7 @@ public function getIdentifier() * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false)) { $this->identifier = $identifier; @@ -102,7 +102,7 @@ public function setIdentifier($identifier) * * @return Expression A QTI Expression object. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -112,7 +112,7 @@ public function getExpression() * * @param Expression $expression A QTI Expression object. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -120,7 +120,7 @@ public function setExpression(Expression $expression) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'lookupOutcomeValue'; } @@ -128,7 +128,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = [$this->getExpression()]; diff --git a/src/qtism/data/rules/Ordering.php b/src/qtism/data/rules/Ordering.php index d4b2caa38..bfbb3b3a7 100644 --- a/src/qtism/data/rules/Ordering.php +++ b/src/qtism/data/rules/Ordering.php @@ -59,7 +59,7 @@ public function __construct($shuffle = false) * * @return bool true if they must be randomized, false otherwise. */ - public function getShuffle() + public function getShuffle(): bool { return $this->shuffle; } @@ -70,7 +70,7 @@ public function getShuffle() * @param bool $shuffle true if they must be randomized, false otherwise. * @throws InvalidArgumentException If $shuffle is not a boolean. */ - public function setShuffle($shuffle) + public function setShuffle($shuffle): void { if (is_bool($shuffle)) { $this->shuffle = $shuffle; @@ -83,7 +83,7 @@ public function setShuffle($shuffle) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'ordering'; } @@ -91,7 +91,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/rules/OutcomeCondition.php b/src/qtism/data/rules/OutcomeCondition.php index d782645fe..bedfdd466 100644 --- a/src/qtism/data/rules/OutcomeCondition.php +++ b/src/qtism/data/rules/OutcomeCondition.php @@ -83,7 +83,7 @@ public function __construct(OutcomeIf $outcomeIf, OutcomeElseIfCollection $outco * * @return OutcomeIf An OutcomeIf object. */ - public function getOutcomeIf() + public function getOutcomeIf(): OutcomeIf { return $this->outcomeIf; } @@ -93,7 +93,7 @@ public function getOutcomeIf() * * @param OutcomeIf $outcomeIf An OutcomeIf object. */ - public function setOutcomeIf(OutcomeIf $outcomeIf) + public function setOutcomeIf(OutcomeIf $outcomeIf): void { $this->outcomeIf = $outcomeIf; } @@ -103,7 +103,7 @@ public function setOutcomeIf(OutcomeIf $outcomeIf) * * @return OutcomeElseIfCollection An OutcomeElseIfCollection object. */ - public function getOutcomeElseIfs() + public function getOutcomeElseIfs(): OutcomeElseIfCollection { return $this->outcomeElseIfs; } @@ -113,7 +113,7 @@ public function getOutcomeElseIfs() * * @param OutcomeElseIfCollection $outcomeElseIfs An OutcomeElseIfCollection object. */ - public function setOutcomeElseIfs(OutcomeElseIfCollection $outcomeElseIfs) + public function setOutcomeElseIfs(OutcomeElseIfCollection $outcomeElseIfs): void { $this->outcomeElseIfs = $outcomeElseIfs; } @@ -121,9 +121,9 @@ public function setOutcomeElseIfs(OutcomeElseIfCollection $outcomeElseIfs) /** * Get the optional OutcomeElse object. Returns null if not specified. * - * @return OutcomeElse An OutcomeElse object. + * @return OutcomeElse|null An OutcomeElse object. */ - public function getOutcomeElse() + public function getOutcomeElse(): ?OutcomeElse { return $this->outcomeElse; } @@ -133,7 +133,7 @@ public function getOutcomeElse() * * @param OutcomeElse $outcomeElse An OutcomeElse object. */ - public function setOutcomeElse(OutcomeElse $outcomeElse = null) + public function setOutcomeElse(OutcomeElse $outcomeElse = null): void { $this->outcomeElse = $outcomeElse; } @@ -143,7 +143,7 @@ public function setOutcomeElse(OutcomeElse $outcomeElse = null) * * @return bool */ - public function hasOutcomeElse() + public function hasOutcomeElse(): bool { return $this->getOutcomeElse() !== null; } @@ -151,7 +151,7 @@ public function hasOutcomeElse() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'outcomeCondition'; } @@ -159,7 +159,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge( [$this->getOutcomeIf()], diff --git a/src/qtism/data/rules/OutcomeElse.php b/src/qtism/data/rules/OutcomeElse.php index fc01ccdd6..31d51d9b0 100644 --- a/src/qtism/data/rules/OutcomeElse.php +++ b/src/qtism/data/rules/OutcomeElse.php @@ -56,7 +56,7 @@ public function __construct(OutcomeRuleCollection $outcomeRules) * * @return OutcomeRuleCollection A collection of OutcomeRule objects. */ - public function getOutcomeRules() + public function getOutcomeRules(): OutcomeRuleCollection { return $this->outcomeRules; } @@ -67,7 +67,7 @@ public function getOutcomeRules() * @param OutcomeRuleCollection $outcomeRules A collection of OutcomeRule objects. * @throws InvalidArgumentException If $outcomeRules is an empty collection. */ - public function setOutcomeRules(OutcomeRuleCollection $outcomeRules) + public function setOutcomeRules(OutcomeRuleCollection $outcomeRules): void { if (count($outcomeRules) <= 0) { $msg = 'An OutcomeElse object must be bound to at least one OutcomeRule object.'; @@ -80,7 +80,7 @@ public function setOutcomeRules(OutcomeRuleCollection $outcomeRules) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'outcomeElse'; } @@ -88,7 +88,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = $this->getOutcomeRules()->getArrayCopy(); diff --git a/src/qtism/data/rules/OutcomeElseIf.php b/src/qtism/data/rules/OutcomeElseIf.php index 02270a3a7..6e5dd4b83 100644 --- a/src/qtism/data/rules/OutcomeElseIf.php +++ b/src/qtism/data/rules/OutcomeElseIf.php @@ -70,7 +70,7 @@ public function __construct(Expression $expression, OutcomeRuleCollection $outco * * @return Expression An Expression object. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -80,7 +80,7 @@ public function getExpression() * * @param Expression $expression An Expression object. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -91,7 +91,7 @@ public function setExpression(Expression $expression) * * @return OutcomeRuleCollection A collection of OutcomeRule objects. */ - public function getOutcomeRules() + public function getOutcomeRules(): OutcomeRuleCollection { return $this->outcomeRules; } @@ -103,7 +103,7 @@ public function getOutcomeRules() * @param OutcomeRuleCollection $outcomeRules A collection of OutcomeRule objects. * @throws InvalidArgumentException If $outcomeRules is an empty collection. */ - public function setOutcomeRules(OutcomeRuleCollection $outcomeRules) + public function setOutcomeRules(OutcomeRuleCollection $outcomeRules): void { if (count($outcomeRules) > 0) { $this->outcomeRules = $outcomeRules; @@ -116,7 +116,7 @@ public function setOutcomeRules(OutcomeRuleCollection $outcomeRules) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'outcomeElseIf'; } @@ -124,7 +124,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge([$this->getExpression()], $this->getOutcomeRules()->getArrayCopy()); diff --git a/src/qtism/data/rules/OutcomeElseIfCollection.php b/src/qtism/data/rules/OutcomeElseIfCollection.php index aa22ddac6..02d988d98 100644 --- a/src/qtism/data/rules/OutcomeElseIfCollection.php +++ b/src/qtism/data/rules/OutcomeElseIfCollection.php @@ -37,7 +37,7 @@ class OutcomeElseIfCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of OutcomeElseIf. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof OutcomeElseIf) { $msg = "OutcomeElseIfCollection only accepts to store OutcomeElseIf objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/rules/OutcomeIf.php b/src/qtism/data/rules/OutcomeIf.php index 5c61b95a8..23a3e2de2 100644 --- a/src/qtism/data/rules/OutcomeIf.php +++ b/src/qtism/data/rules/OutcomeIf.php @@ -74,7 +74,7 @@ public function __construct(Expression $expression, OutcomeRuleCollection $outco * * @return Expression An expression. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -84,7 +84,7 @@ public function getExpression() * * @param Expression $expression An expression. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -96,7 +96,7 @@ public function setExpression(Expression $expression) * @param OutcomeRuleCollection $outcomeRules A collection of OutcomeRule objects. * @throws InvalidArgumentException If $outcomeRules is an empty collection. */ - public function setOutcomeRules(OutcomeRuleCollection $outcomeRules) + public function setOutcomeRules(OutcomeRuleCollection $outcomeRules): void { if (count($outcomeRules) > 0) { $this->outcomeRules = $outcomeRules; @@ -112,7 +112,7 @@ public function setOutcomeRules(OutcomeRuleCollection $outcomeRules) * * @return OutcomeRuleCollection A collection of Outcomeule objects. */ - public function getOutcomeRules() + public function getOutcomeRules(): OutcomeRuleCollection { return $this->outcomeRules; } @@ -120,7 +120,7 @@ public function getOutcomeRules() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'outcomeIf'; } @@ -128,7 +128,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge( [$this->getExpression()], diff --git a/src/qtism/data/rules/OutcomeRuleCollection.php b/src/qtism/data/rules/OutcomeRuleCollection.php index 4877274de..ca6012d55 100644 --- a/src/qtism/data/rules/OutcomeRuleCollection.php +++ b/src/qtism/data/rules/OutcomeRuleCollection.php @@ -37,7 +37,7 @@ class OutcomeRuleCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of OutcomeRule. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof OutcomeRule) { $msg = "OutcomeRuleCollection only accepts to store OutcomeRule objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/rules/PreCondition.php b/src/qtism/data/rules/PreCondition.php index f394270d7..e1b69fa1c 100644 --- a/src/qtism/data/rules/PreCondition.php +++ b/src/qtism/data/rules/PreCondition.php @@ -62,7 +62,7 @@ public function __construct(Expression $expression) * * @return Expression A QTI Expression. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -72,7 +72,7 @@ public function getExpression() * * @param Expression $expression A QTI Expression. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -80,7 +80,7 @@ public function setExpression(Expression $expression) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'preCondition'; } @@ -88,7 +88,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection([$this->getExpression()]); } diff --git a/src/qtism/data/rules/PreConditionCollection.php b/src/qtism/data/rules/PreConditionCollection.php index bffb7112a..6cd9a2502 100644 --- a/src/qtism/data/rules/PreConditionCollection.php +++ b/src/qtism/data/rules/PreConditionCollection.php @@ -37,7 +37,7 @@ class PreConditionCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of PreCondition. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof PreCondition) { $msg = "PreConditionCollection only accepts to store PreCondition objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/rules/ResponseCondition.php b/src/qtism/data/rules/ResponseCondition.php index 6188541b6..4d402ebd6 100644 --- a/src/qtism/data/rules/ResponseCondition.php +++ b/src/qtism/data/rules/ResponseCondition.php @@ -83,7 +83,7 @@ public function __construct(ResponseIf $responseIf, ResponseElseIfCollection $re * * @return ResponseIf A ResponseIf object. */ - public function getResponseIf() + public function getResponseIf(): ResponseIf { return $this->responseIf; } @@ -93,7 +93,7 @@ public function getResponseIf() * * @param ResponseIf $responseIf A ResponseIf object. */ - public function setResponseIf(ResponseIf $responseIf) + public function setResponseIf(ResponseIf $responseIf): void { $this->responseIf = $responseIf; } @@ -103,7 +103,7 @@ public function setResponseIf(ResponseIf $responseIf) * * @return ResponseElseIfCollection A ResponseElseIfCollection object. */ - public function getResponseElseIfs() + public function getResponseElseIfs(): ResponseElseIfCollection { return $this->responseElseIfs; } @@ -113,7 +113,7 @@ public function getResponseElseIfs() * * @param ResponseElseIfCollection $responseElseIfs A ResponseElseIfCollection object. */ - public function setResponseElseIfs(ResponseElseIfCollection $responseElseIfs) + public function setResponseElseIfs(ResponseElseIfCollection $responseElseIfs): void { $this->responseElseIfs = $responseElseIfs; } @@ -121,9 +121,9 @@ public function setResponseElseIfs(ResponseElseIfCollection $responseElseIfs) /** * Get the optional ResponseElse object. Returns null if not specified. * - * @return ResponseElse A ResponseElse object. + * @return ResponseElse|null A ResponseElse object. */ - public function getResponseElse() + public function getResponseElse(): ?ResponseElse { return $this->responseElse; } @@ -133,7 +133,7 @@ public function getResponseElse() * * @param ResponseElse $responseElse A ResponseElse object. */ - public function setResponseElse(ResponseElse $responseElse = null) + public function setResponseElse(ResponseElse $responseElse = null): void { $this->responseElse = $responseElse; } @@ -143,7 +143,7 @@ public function setResponseElse(ResponseElse $responseElse = null) * * @return bool */ - public function hasResponseElse() + public function hasResponseElse(): bool { return $this->getResponseElse() !== null; } @@ -151,7 +151,7 @@ public function hasResponseElse() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'responseCondition'; } @@ -159,7 +159,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge( [$this->getResponseIf()], diff --git a/src/qtism/data/rules/ResponseElse.php b/src/qtism/data/rules/ResponseElse.php index dc4008da0..7df3b14f1 100644 --- a/src/qtism/data/rules/ResponseElse.php +++ b/src/qtism/data/rules/ResponseElse.php @@ -56,7 +56,7 @@ public function __construct(ResponseRuleCollection $responseRules) * * @return ResponseRuleCollection A collection of ResponseRule objects. */ - public function getResponseRules() + public function getResponseRules(): ResponseRuleCollection { return $this->responseRules; } @@ -67,7 +67,7 @@ public function getResponseRules() * @param ResponseRuleCollection $responseRules A collection of ResponseRule objects. * @throws InvalidArgumentException If $responseRules is an empty collection. */ - public function setOutcomeRules(ResponseRuleCollection $responseRules) + public function setOutcomeRules(ResponseRuleCollection $responseRules): void { if (count($responseRules) > 0) { $this->responseRules = $responseRules; @@ -80,7 +80,7 @@ public function setOutcomeRules(ResponseRuleCollection $responseRules) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'responseElse'; } @@ -88,7 +88,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = $this->getResponseRules()->getArrayCopy(); diff --git a/src/qtism/data/rules/ResponseElseIf.php b/src/qtism/data/rules/ResponseElseIf.php index bc21a240e..48b361ac8 100644 --- a/src/qtism/data/rules/ResponseElseIf.php +++ b/src/qtism/data/rules/ResponseElseIf.php @@ -68,7 +68,7 @@ public function __construct(Expression $expression, ResponseRuleCollection $resp * * @return Expression An Expression object. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -78,7 +78,7 @@ public function getExpression() * * @param Expression $expression An Expression object. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -89,7 +89,7 @@ public function setExpression(Expression $expression) * * @return ResponseRuleCollection A collection of OutcomeRule objects. */ - public function getResponseRules() + public function getResponseRules(): ResponseRuleCollection { return $this->responseRules; } @@ -100,7 +100,7 @@ public function getResponseRules() * * @param ResponseRuleCollection $responseRules A collection of ResponseRule objects. */ - public function setResponseRules(ResponseRuleCollection $responseRules) + public function setResponseRules(ResponseRuleCollection $responseRules): void { $this->responseRules = $responseRules; } @@ -108,7 +108,7 @@ public function setResponseRules(ResponseRuleCollection $responseRules) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'responseElseIf'; } @@ -116,7 +116,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge( [$this->getExpression()], diff --git a/src/qtism/data/rules/ResponseElseIfCollection.php b/src/qtism/data/rules/ResponseElseIfCollection.php index fc7847883..b973a9c08 100644 --- a/src/qtism/data/rules/ResponseElseIfCollection.php +++ b/src/qtism/data/rules/ResponseElseIfCollection.php @@ -37,7 +37,7 @@ class ResponseElseIfCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of ResponseElseIf. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof ResponseElseIf) { $msg = "ResponseElseIfCollection only accepts to store ResponseElseIf objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/rules/ResponseIf.php b/src/qtism/data/rules/ResponseIf.php index aeb92d701..cfab4ef83 100644 --- a/src/qtism/data/rules/ResponseIf.php +++ b/src/qtism/data/rules/ResponseIf.php @@ -73,7 +73,7 @@ public function __construct(Expression $expression, ResponseRuleCollection $resp * * @return Expression An expression. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -83,7 +83,7 @@ public function getExpression() * * @param Expression $expression An expression. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -94,7 +94,7 @@ public function setExpression(Expression $expression) * * @param ResponseRuleCollection $responseRules A collection of ResponseRule objects. */ - public function setResponseRules(ResponseRuleCollection $responseRules) + public function setResponseRules(ResponseRuleCollection $responseRules): void { $this->responseRules = $responseRules; } @@ -105,7 +105,7 @@ public function setResponseRules(ResponseRuleCollection $responseRules) * * @return ResponseRuleCollection A collection of ResponseRule objects. */ - public function getResponseRules() + public function getResponseRules(): ResponseRuleCollection { return $this->responseRules; } @@ -113,7 +113,7 @@ public function getResponseRules() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'responseIf'; } @@ -121,7 +121,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge( [$this->getExpression()], diff --git a/src/qtism/data/rules/ResponseRuleCollection.php b/src/qtism/data/rules/ResponseRuleCollection.php index ffe9e1697..048b828cd 100644 --- a/src/qtism/data/rules/ResponseRuleCollection.php +++ b/src/qtism/data/rules/ResponseRuleCollection.php @@ -37,7 +37,7 @@ class ResponseRuleCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of ResponseRule. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof ResponseRule) { $msg = "ResponseRuleCollection only accepts to store ResponseRule objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/rules/Selection.php b/src/qtism/data/rules/Selection.php index 8bd21696a..6f43047fb 100644 --- a/src/qtism/data/rules/Selection.php +++ b/src/qtism/data/rules/Selection.php @@ -91,7 +91,7 @@ public function __construct($select, $withReplacement = false, $xmlString = '') * * @return int An integer. */ - public function getSelect() + public function getSelect(): int { return $this->select; } @@ -102,7 +102,7 @@ public function getSelect() * @param int $select An integer. * @throws InvalidArgumentException If $select is not an integer. */ - public function setSelect($select) + public function setSelect($select): void { if (is_int($select)) { $this->select = $select; @@ -117,7 +117,7 @@ public function setSelect($select) * * @return bool true if it must be with replacements, false otherwise. */ - public function isWithReplacement() + public function isWithReplacement(): bool { return $this->withReplacement; } @@ -128,7 +128,7 @@ public function isWithReplacement() * @param bool $withReplacement true if it must be with replacements, false otherwise. * @throws InvalidArgumentException If $withReplacement is not a boolean. */ - public function setWithReplacement($withReplacement) + public function setWithReplacement($withReplacement): void { if (is_bool($withReplacement)) { $this->withReplacement = $withReplacement; @@ -143,7 +143,7 @@ public function setWithReplacement($withReplacement) * * @param string $xmlString */ - public function setXmlString($xmlString) + public function setXmlString($xmlString): void { $this->xmlString = $xmlString; @@ -157,7 +157,7 @@ public function setXmlString($xmlString) * * @return string */ - public function getXmlString() + public function getXmlString(): string { return $this->xmlString; } @@ -167,7 +167,7 @@ public function getXmlString() * * @param ExternalQtiComponent $externalComponent */ - private function setExternalComponent(ExternalQtiComponent $externalComponent) + private function setExternalComponent(ExternalQtiComponent $externalComponent): void { $this->externalComponent = $externalComponent; } @@ -175,9 +175,9 @@ private function setExternalComponent(ExternalQtiComponent $externalComponent) /** * Get the encapsulated external component. * - * @return ExternalQtiComponent + * @return ExternalQtiComponent|null */ - private function getExternalComponent() + private function getExternalComponent(): ?ExternalQtiComponent { return $this->externalComponent; } @@ -192,15 +192,15 @@ public function getXml(): ?SerializableDomDocument { if (($externalComponent = $this->getExternalComponent()) !== null) { return $this->getExternalComponent()->getXml(); - } else { - return null; } + + return null; } /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'selection'; } @@ -208,7 +208,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/rules/SetCorrectResponse.php b/src/qtism/data/rules/SetCorrectResponse.php index 312882537..149889af0 100644 --- a/src/qtism/data/rules/SetCorrectResponse.php +++ b/src/qtism/data/rules/SetCorrectResponse.php @@ -71,7 +71,7 @@ public function __construct($identifier, Expression $expression) * @param string $identifier A valid QTI identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false) === true) { $this->identifier = $identifier; @@ -86,7 +86,7 @@ public function setIdentifier($identifier) * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -97,7 +97,7 @@ public function getIdentifier() * * @param Expression $expression An Expression object. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -108,7 +108,7 @@ public function setExpression(Expression $expression) * * @return Expression An Expression object. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -116,7 +116,7 @@ public function getExpression() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'setCorrectResponse'; } @@ -124,7 +124,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection([$this->getExpression()]); } diff --git a/src/qtism/data/rules/SetDefaultValue.php b/src/qtism/data/rules/SetDefaultValue.php index eb7c7d041..ecb23f037 100644 --- a/src/qtism/data/rules/SetDefaultValue.php +++ b/src/qtism/data/rules/SetDefaultValue.php @@ -73,7 +73,7 @@ public function __construct($identifier, Expression $expression) * @param string $identifier A valid QTI identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false) === true) { $this->identifier = $identifier; @@ -89,7 +89,7 @@ public function setIdentifier($identifier) * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -99,7 +99,7 @@ public function getIdentifier() * * @param Expression $expression An Expression object. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -109,7 +109,7 @@ public function setExpression(Expression $expression) * * @return Expression An Expression object. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -117,7 +117,7 @@ public function getExpression() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'setDefaultValue'; } @@ -125,7 +125,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection([$this->getExpression()]); } diff --git a/src/qtism/data/rules/SetOutcomeValue.php b/src/qtism/data/rules/SetOutcomeValue.php index 36e21084c..c6949cc69 100644 --- a/src/qtism/data/rules/SetOutcomeValue.php +++ b/src/qtism/data/rules/SetOutcomeValue.php @@ -82,7 +82,7 @@ public function __construct($identifier, Expression $expression) * * @return string A QTI Identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -93,7 +93,7 @@ public function getIdentifier() * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false)) { $this->identifier = $identifier; @@ -108,7 +108,7 @@ public function setIdentifier($identifier) * * @param Expression $expression A QTI Expression. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -118,7 +118,7 @@ public function setExpression(Expression $expression) * * @return Expression */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -126,7 +126,7 @@ public function getExpression() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'setOutcomeValue'; } @@ -134,7 +134,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection([$this->getExpression()]); } diff --git a/src/qtism/data/rules/SetTemplateValue.php b/src/qtism/data/rules/SetTemplateValue.php index a81c20e24..36e0deca5 100644 --- a/src/qtism/data/rules/SetTemplateValue.php +++ b/src/qtism/data/rules/SetTemplateValue.php @@ -79,7 +79,7 @@ public function __construct($identifier, Expression $expression) * * @param string $identifier A valid QTI identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false) === true) { $this->identifier = $identifier; @@ -94,7 +94,7 @@ public function setIdentifier($identifier) * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -104,7 +104,7 @@ public function getIdentifier() * * @param Expression $expression An Expression object. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -114,7 +114,7 @@ public function setExpression(Expression $expression) * * @return Expression An expression object. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -122,7 +122,7 @@ public function getExpression() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'setTemplateValue'; } @@ -130,7 +130,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection([$this->getExpression()]); } diff --git a/src/qtism/data/rules/TemplateCondition.php b/src/qtism/data/rules/TemplateCondition.php index 38fafd9c9..dcdb28711 100644 --- a/src/qtism/data/rules/TemplateCondition.php +++ b/src/qtism/data/rules/TemplateCondition.php @@ -82,7 +82,7 @@ public function __construct(TemplateIf $templateIf, TemplateElseIfCollection $te * * @param TemplateIf $templateIf A TemplateIf object. */ - public function setTemplateIf(TemplateIf $templateIf) + public function setTemplateIf(TemplateIf $templateIf): void { $this->templateIf = $templateIf; } @@ -92,7 +92,7 @@ public function setTemplateIf(TemplateIf $templateIf) * * @return TemplateIf A TemplateIf object. */ - public function getTemplateIf() + public function getTemplateIf(): TemplateIf { return $this->templateIf; } @@ -102,7 +102,7 @@ public function getTemplateIf() * * @param TemplateElseIfCollection $templateElseIfs A collection of TemplateElseIf objects. */ - public function setTemplateElseIfs(TemplateElseIfCollection $templateElseIfs) + public function setTemplateElseIfs(TemplateElseIfCollection $templateElseIfs): void { $this->templateElseIfs = $templateElseIfs; } @@ -112,7 +112,7 @@ public function setTemplateElseIfs(TemplateElseIfCollection $templateElseIfs) * * @return TemplateElseIfCollection A collection of TemplateElseIf objects. */ - public function getTemplateElseIfs() + public function getTemplateElseIfs(): TemplateElseIfCollection { return $this->templateElseIfs; } @@ -122,7 +122,7 @@ public function getTemplateElseIfs() * * @param TemplateElse $templateElse A TemplateElse object. */ - public function setTemplateElse(TemplateElse $templateElse = null) + public function setTemplateElse(TemplateElse $templateElse = null): void { $this->templateElse = $templateElse; } @@ -130,9 +130,9 @@ public function setTemplateElse(TemplateElse $templateElse = null) /** * Get the TemplateElse object composing the template condition. * - * @return TemplateElse A TemplateElse object. + * @return TemplateElse|null A TemplateElse object. */ - public function getTemplateElse() + public function getTemplateElse(): ?TemplateElse { return $this->templateElse; } @@ -142,15 +142,15 @@ public function getTemplateElse() * * @return bool */ - public function hasTemplateElse() + public function hasTemplateElse(): bool { return $this->getTemplateElse() !== null; } /** - * @return array|QtiComponentCollection + * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $merge = array_merge([$this->getTemplateIf()], $this->getTemplateElseIfs()->getArrayCopy()); $components = new QtiComponentCollection($merge); @@ -164,7 +164,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'templateCondition'; } diff --git a/src/qtism/data/rules/TemplateConstraint.php b/src/qtism/data/rules/TemplateConstraint.php index 88ce2fdbd..f3f7bfc9e 100644 --- a/src/qtism/data/rules/TemplateConstraint.php +++ b/src/qtism/data/rules/TemplateConstraint.php @@ -82,7 +82,7 @@ public function __construct(Expression $expression) * * @param Expression $expression An Expression object. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -92,7 +92,7 @@ public function setExpression(Expression $expression) * * @return Expression An Expression object. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -100,7 +100,7 @@ public function getExpression() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'templateConstraint'; } @@ -108,7 +108,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection([$this->getExpression()]); } diff --git a/src/qtism/data/rules/TemplateElse.php b/src/qtism/data/rules/TemplateElse.php index 090392edb..9ddebb7e8 100644 --- a/src/qtism/data/rules/TemplateElse.php +++ b/src/qtism/data/rules/TemplateElse.php @@ -54,7 +54,7 @@ public function __construct(TemplateRuleCollection $templateRules) * * @param TemplateRuleCollection $templateRules A collection of TemplateRule objects. */ - public function setTemplateRules(TemplateRuleCollection $templateRules) + public function setTemplateRules(TemplateRuleCollection $templateRules): void { $this->templateRules = $templateRules; } @@ -64,7 +64,7 @@ public function setTemplateRules(TemplateRuleCollection $templateRules) * * @return TemplateRuleCollection A collection of TemplateRule objects. */ - public function getTemplateRules() + public function getTemplateRules(): TemplateRuleCollection { return $this->templateRules; } @@ -72,7 +72,7 @@ public function getTemplateRules() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection($this->getTemplateRules()->getArrayCopy()); } @@ -80,7 +80,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'templateElse'; } diff --git a/src/qtism/data/rules/TemplateElseIf.php b/src/qtism/data/rules/TemplateElseIf.php index 2b5e05dfd..772cd05a9 100644 --- a/src/qtism/data/rules/TemplateElseIf.php +++ b/src/qtism/data/rules/TemplateElseIf.php @@ -68,7 +68,7 @@ public function __construct(Expression $expression, TemplateRuleCollection $temp * * @param Expression $expression An Expression object. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -78,7 +78,7 @@ public function setExpression(Expression $expression) * * @return Expression An Expression object. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -89,7 +89,7 @@ public function getExpression() * * @param TemplateRuleCollection $templateRules A collection of TemplateRule objects. */ - public function setTemplateRules(TemplateRuleCollection $templateRules) + public function setTemplateRules(TemplateRuleCollection $templateRules): void { $this->templateRules = $templateRules; } @@ -100,7 +100,7 @@ public function setTemplateRules(TemplateRuleCollection $templateRules) * * @return TemplateRuleCollection A collection of TemplateRule objects. */ - public function getTemplateRules() + public function getTemplateRules(): TemplateRuleCollection { return $this->templateRules; } @@ -108,7 +108,7 @@ public function getTemplateRules() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $merge = array_merge([$this->getExpression()], $this->getTemplateRules()->getArrayCopy()); return new QtiComponentCollection($merge); @@ -117,7 +117,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'templateElseIf'; } diff --git a/src/qtism/data/rules/TemplateElseIfCollection.php b/src/qtism/data/rules/TemplateElseIfCollection.php index 0f654ee61..34014e955 100644 --- a/src/qtism/data/rules/TemplateElseIfCollection.php +++ b/src/qtism/data/rules/TemplateElseIfCollection.php @@ -38,7 +38,7 @@ class TemplateElseIfCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of TemplateElseIf. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof TemplateElseIf) { $msg = 'A TemplateElseIfCollection aims at storing TemplateElseIf objects only.'; diff --git a/src/qtism/data/rules/TemplateIf.php b/src/qtism/data/rules/TemplateIf.php index d639e5abc..5cfac72fa 100644 --- a/src/qtism/data/rules/TemplateIf.php +++ b/src/qtism/data/rules/TemplateIf.php @@ -73,7 +73,7 @@ public function __construct(Expression $expression, TemplateRuleCollection $temp * * @param Expression $expression An Expression object. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -83,7 +83,7 @@ public function setExpression(Expression $expression) * * @return Expression An Expression object. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -94,7 +94,7 @@ public function getExpression() * * @param TemplateRuleCollection $templateRules A collection of TemplateRule objects. */ - public function setTemplateRules(TemplateRuleCollection $templateRules) + public function setTemplateRules(TemplateRuleCollection $templateRules): void { $this->templateRules = $templateRules; } @@ -105,7 +105,7 @@ public function setTemplateRules(TemplateRuleCollection $templateRules) * * @return TemplateRuleCollection A collection of TemplateRule objects. */ - public function getTemplateRules() + public function getTemplateRules(): TemplateRuleCollection { return $this->templateRules; } @@ -113,7 +113,7 @@ public function getTemplateRules() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(array_merge([$this->getExpression()], $this->getTemplateRules()->getArrayCopy())); } @@ -121,7 +121,7 @@ public function getComponents() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'templateIf'; } diff --git a/src/qtism/data/rules/TemplateRuleCollection.php b/src/qtism/data/rules/TemplateRuleCollection.php index b6a72d8f2..5bad57df4 100644 --- a/src/qtism/data/rules/TemplateRuleCollection.php +++ b/src/qtism/data/rules/TemplateRuleCollection.php @@ -38,7 +38,7 @@ class TemplateRuleCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of TemplateRule. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof TemplateRule) { $msg = 'A TemplateRuleCollection only accepts to store TemplateRule objects.'; diff --git a/src/qtism/data/state/AreaMapEntry.php b/src/qtism/data/state/AreaMapEntry.php index 09727097c..1a46e807b 100644 --- a/src/qtism/data/state/AreaMapEntry.php +++ b/src/qtism/data/state/AreaMapEntry.php @@ -86,7 +86,7 @@ public function __construct($shape, QtiCoords $coords, $mappedValue) * @param int $shape A value from the Shape enumeration. * @throws InvalidArgumentException If $shape is not a value from the Shape enumeration. */ - public function setShape($shape) + public function setShape($shape): void { if (in_array($shape, QtiShape::asArray())) { $this->shape = $shape; @@ -101,7 +101,7 @@ public function setShape($shape) * * @return int A value from the Shape enumeration. */ - public function getShape() + public function getShape(): int { return $this->shape; } @@ -112,7 +112,7 @@ public function getShape() * * @param QtiCoords $coords A QtiCoords object. */ - public function setCoords(QtiCoords $coords) + public function setCoords(QtiCoords $coords): void { $this->coords = $coords; } @@ -123,7 +123,7 @@ public function setCoords(QtiCoords $coords) * * @return QtiCoords A QtiCoords object. */ - public function getCoords() + public function getCoords(): QtiCoords { return $this->coords; } @@ -134,7 +134,7 @@ public function getCoords() * @param float $mappedValue A mapped value. * @throws InvalidArgumentException If $mappedValue is not a float value. */ - public function setMappedValue($mappedValue) + public function setMappedValue($mappedValue): void { if (is_float($mappedValue)) { $this->mappedValue = $mappedValue; @@ -149,7 +149,7 @@ public function setMappedValue($mappedValue) * * @return float A mapped value. */ - public function getMappedValue() + public function getMappedValue(): float { return $this->mappedValue; } @@ -157,7 +157,7 @@ public function getMappedValue() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'areaMapEntry'; } @@ -165,7 +165,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/state/AreaMapEntryCollection.php b/src/qtism/data/state/AreaMapEntryCollection.php index eefb40eb1..be5930f3d 100644 --- a/src/qtism/data/state/AreaMapEntryCollection.php +++ b/src/qtism/data/state/AreaMapEntryCollection.php @@ -37,7 +37,7 @@ class AreaMapEntryCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of AreaMapEntry. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof AreaMapEntry) { $msg = "AreaMapEntryCollection only accepts to store AreaMapEntry objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/AreaMapping.php b/src/qtism/data/state/AreaMapping.php index 662db1567..a11948b70 100644 --- a/src/qtism/data/state/AreaMapping.php +++ b/src/qtism/data/state/AreaMapping.php @@ -93,7 +93,7 @@ public function __construct(AreaMapEntryCollection $areaMapEntries, $defaultValu * @param bool|float $lowerBound A lower bound. * @throws InvalidArgumentException If $lowerBound is not a float value nor false. */ - public function setLowerBound($lowerBound) + public function setLowerBound($lowerBound): void { if (is_float($lowerBound) || (is_bool($lowerBound) && $lowerBound === false)) { $this->lowerBound = $lowerBound; @@ -106,8 +106,9 @@ public function setLowerBound($lowerBound) /** * Get the lower bound. * - * @return float A lower bound. + * @return float|false A lower bound. */ + #[\ReturnTypeWillChange] public function getLowerBound() { return $this->lowerBound; @@ -119,7 +120,7 @@ public function getLowerBound() * @param bool|float $upperBound An upper bound. * @throws InvalidArgumentException If $upperBound is not a float value nor false. */ - public function setUpperBound($upperBound) + public function setUpperBound($upperBound): void { if (is_float($upperBound) || (is_bool($upperBound) && $upperBound === false)) { $this->upperBound = $upperBound; @@ -132,8 +133,9 @@ public function setUpperBound($upperBound) /** * Get the upper bound. * - * @return float An upper bound. + * @return float|false An upper bound. */ + #[\ReturnTypeWillChange] public function getUpperBound() { return $this->upperBound; @@ -145,7 +147,7 @@ public function getUpperBound() * @param float $defaultValue A default value. * @throws InvalidArgumentException If $defaultValue is not a float value. */ - public function setDefaultValue($defaultValue) + public function setDefaultValue($defaultValue): void { if (is_float($defaultValue)) { $this->defaultValue = $defaultValue; @@ -160,7 +162,7 @@ public function setDefaultValue($defaultValue) * * @return float A default value. */ - public function getDefaultValue() + public function getDefaultValue(): float { return $this->defaultValue; } @@ -170,7 +172,7 @@ public function getDefaultValue() * * @param AreaMapEntryCollection $areaMapEntries A collection of AreaMapEntry objects. */ - public function setAreaMapEntries(AreaMapEntryCollection $areaMapEntries) + public function setAreaMapEntries(AreaMapEntryCollection $areaMapEntries): void { if (count($areaMapEntries) >= 1) { $this->areaMapEntries = $areaMapEntries; @@ -185,7 +187,7 @@ public function setAreaMapEntries(AreaMapEntryCollection $areaMapEntries) * * @return AreaMapEntryCollection A collection of AreaMapEntry objects. */ - public function getAreaMapEntries() + public function getAreaMapEntries(): AreaMapEntryCollection { return $this->areaMapEntries; } @@ -195,7 +197,7 @@ public function getAreaMapEntries() * * @return bool */ - public function hasLowerBound() + public function hasLowerBound(): bool { return $this->getLowerBound() !== false; } @@ -205,7 +207,7 @@ public function hasLowerBound() * * @return bool */ - public function hasUpperBound() + public function hasUpperBound(): bool { return $this->getUpperBound() !== false; } @@ -213,7 +215,7 @@ public function hasUpperBound() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'areaMapping'; } @@ -221,7 +223,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = $this->getAreaMapEntries()->getArrayCopy(); diff --git a/src/qtism/data/state/AssociationValidityConstraint.php b/src/qtism/data/state/AssociationValidityConstraint.php index 4753baf3b..0872b1d02 100644 --- a/src/qtism/data/state/AssociationValidityConstraint.php +++ b/src/qtism/data/state/AssociationValidityConstraint.php @@ -82,7 +82,7 @@ public function __construct($identifier, $minConstraint, $maxConstraint) * @param int $identifier * @throws InvalidArgumentException If $identifier is an empty string. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (is_string($identifier) === false || empty($identifier)) { throw new InvalidArgumentException( @@ -98,7 +98,7 @@ public function setIdentifier($identifier) * * @return string */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -109,7 +109,7 @@ public function getIdentifier() * @param int $minConstraint A non negative integer (>= 0) integer value. * @throws InvalidArgumentException If $minConstraint is not a non negative (>= 0) integer value. */ - public function setMinConstraint($minConstraint) + public function setMinConstraint($minConstraint): void { if (is_int($minConstraint) === false || $minConstraint < 0) { throw new InvalidArgumentException( @@ -125,7 +125,7 @@ public function setMinConstraint($minConstraint) * * @return int A non negative (>= 0) integer value. */ - public function getMinConstraint() + public function getMinConstraint(): int { return $this->minConstraint; } @@ -138,7 +138,7 @@ public function getMinConstraint() * @param int $maxConstraint An integer value which is greater than the 'minConstraint' in place. * @throws InvalidArgumentException If $maxConstraint is not an integer greater or equal to the 'minConstraint' in place. */ - public function setMaxConstraint($maxConstraint) + public function setMaxConstraint($maxConstraint): void { if (is_int($maxConstraint) === false) { throw new InvalidArgumentException( @@ -164,7 +164,7 @@ public function setMaxConstraint($maxConstraint) * * @return int */ - public function getMaxConstraint() + public function getMaxConstraint(): int { return $this->maxConstraint; } @@ -172,7 +172,7 @@ public function getMaxConstraint() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'associationValidityConstraint'; } @@ -180,7 +180,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/state/AssociationValidityConstraintCollection.php b/src/qtism/data/state/AssociationValidityConstraintCollection.php index d2bfe2fd5..97040240e 100644 --- a/src/qtism/data/state/AssociationValidityConstraintCollection.php +++ b/src/qtism/data/state/AssociationValidityConstraintCollection.php @@ -37,7 +37,7 @@ class AssociationValidityConstraintCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of AssociationValidityConstraint. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof AssociationValidityConstraint) { $msg = "AssociationValidityConstraintCollection only accepts to store AssociationValidityConstraint objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/CorrectResponse.php b/src/qtism/data/state/CorrectResponse.php index 962da2cc7..3c1a1232b 100644 --- a/src/qtism/data/state/CorrectResponse.php +++ b/src/qtism/data/state/CorrectResponse.php @@ -72,7 +72,7 @@ public function __construct(ValueCollection $values, $interpretation = '') * * @return string An interpretation. */ - public function getInterpretation() + public function getInterpretation(): string { return $this->interpretation; } @@ -84,7 +84,7 @@ public function getInterpretation() * @param string $interpretation An interpretation. * @throws InvalidArgumentException If $interpretation is not a string. */ - public function setInterpretation($interpretation) + public function setInterpretation($interpretation): void { if (is_string($interpretation)) { $this->interpretation = $interpretation; @@ -99,7 +99,7 @@ public function setInterpretation($interpretation) * * @return ValueCollection A ValueCollection containing at least one Value object. */ - public function getValues() + public function getValues(): ValueCollection { return $this->values; } @@ -110,7 +110,7 @@ public function getValues() * @param ValueCollection $values A collection of Value objects containing at least one Value object. * @throws InvalidArgumentException If $values does not contain at least one Value object. */ - public function setValues(ValueCollection $values) + public function setValues(ValueCollection $values): void { if (count($values) > 0) { $this->values = $values; @@ -123,7 +123,7 @@ public function setValues(ValueCollection $values) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'correctResponse'; } @@ -131,7 +131,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection($this->getValues()->getArrayCopy()); } diff --git a/src/qtism/data/state/DefaultValue.php b/src/qtism/data/state/DefaultValue.php index 22d006255..69535331a 100644 --- a/src/qtism/data/state/DefaultValue.php +++ b/src/qtism/data/state/DefaultValue.php @@ -72,7 +72,7 @@ public function __construct(ValueCollection $values, $interpretation = '') * * @return string An interpretation. */ - public function getInterpretation() + public function getInterpretation(): string { return $this->interpretation; } @@ -84,7 +84,7 @@ public function getInterpretation() * @param string $interpretation An interpretation. * @throws InvalidArgumentException If $interpretation is not a string. */ - public function setInterpretation($interpretation) + public function setInterpretation($interpretation): void { if (is_string($interpretation)) { $this->interpretation = $interpretation; @@ -99,7 +99,7 @@ public function setInterpretation($interpretation) * * @return ValueCollection A ValueCollection containing at least one Value object. */ - public function getValues() + public function getValues(): ValueCollection { return $this->values; } @@ -110,7 +110,7 @@ public function getValues() * @param ValueCollection $values A collection of Value objects containing at least one Value object. * @throws InvalidArgumentException If $values does not contain at least one Value object. */ - public function setValues(ValueCollection $values) + public function setValues(ValueCollection $values): void { if (count($values) > 0) { $this->values = $values; @@ -123,7 +123,7 @@ public function setValues(ValueCollection $values) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'defaultValue'; } @@ -131,7 +131,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection($this->getValues()->getArrayCopy()); } diff --git a/src/qtism/data/state/ExternalScored.php b/src/qtism/data/state/ExternalScored.php index 386934048..602cb1123 100644 --- a/src/qtism/data/state/ExternalScored.php +++ b/src/qtism/data/state/ExternalScored.php @@ -31,16 +31,16 @@ */ class ExternalScored implements Enumeration { - const HUMAN = 1; + public const HUMAN = 1; - const EXTERNAL_MACHINE = 2; + public const EXTERNAL_MACHINE = 2; /** * Return the possible values of the enumeration as an array. * * @return array An associative array where keys are constant names (as they appear in the code) and values are constant values. */ - public static function asArray() + public static function asArray(): array { return [ 'HUMAN' => self::HUMAN, diff --git a/src/qtism/data/state/InterpolationTable.php b/src/qtism/data/state/InterpolationTable.php index 1237fa0a7..9a5f87cd1 100644 --- a/src/qtism/data/state/InterpolationTable.php +++ b/src/qtism/data/state/InterpolationTable.php @@ -65,7 +65,7 @@ public function __construct(InterpolationTableEntryCollection $interpolationTabl * * @return InterpolationTableEntryCollection A collection of InterpolationTableEntry objects. */ - public function getInterpolationTableEntries() + public function getInterpolationTableEntries(): InterpolationTableEntryCollection { return $this->interpolationTableEntries; } @@ -76,7 +76,7 @@ public function getInterpolationTableEntries() * @param InterpolationTableEntryCollection $interpolationTableEntries A collection of InterpolationTableEntry objects. * @throws InvalidArgumentException If $interpolationTableEntries is an empty collection. */ - public function setInterpolationTableEntries(InterpolationTableEntryCollection $interpolationTableEntries) + public function setInterpolationTableEntries(InterpolationTableEntryCollection $interpolationTableEntries): void { if (count($interpolationTableEntries) > 0) { $this->interpolationTableEntries = $interpolationTableEntries; @@ -89,7 +89,7 @@ public function setInterpolationTableEntries(InterpolationTableEntryCollection $ /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'interpolationTable'; } @@ -97,7 +97,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge( parent::getComponents()->getArrayCopy(), diff --git a/src/qtism/data/state/InterpolationTableEntry.php b/src/qtism/data/state/InterpolationTableEntry.php index ff895ca6d..d1dba0e59 100644 --- a/src/qtism/data/state/InterpolationTableEntry.php +++ b/src/qtism/data/state/InterpolationTableEntry.php @@ -84,7 +84,7 @@ public function __construct($sourceValue, $targetValue, $includeBoundary = true) * * @return float A float value. */ - public function getSourceValue() + public function getSourceValue(): float { return $this->sourceValue; } @@ -95,7 +95,7 @@ public function getSourceValue() * @param float $sourceValue A float value. * @throws InvalidArgumentException If $sourceValue is not a float. */ - public function setSourceValue($sourceValue) + public function setSourceValue($sourceValue): void { if (is_float($sourceValue)) { $this->sourceValue = $sourceValue; @@ -110,6 +110,7 @@ public function setSourceValue($sourceValue) * * @return mixed A value that satisfies the QTI baseType datatype. */ + #[\ReturnTypeWillChange] public function getTargetValue() { return $this->targetValue; @@ -120,7 +121,7 @@ public function getTargetValue() * * @param mixed $targetValue A value that satisfies the QTI baseType datatype. */ - public function setTargetValue($targetValue) + public function setTargetValue($targetValue): void { $this->targetValue = $targetValue; } @@ -131,7 +132,7 @@ public function setTargetValue($targetValue) * @param bool $includeBoundary A boolean value. * @throws InvalidArgumentException If $includeBoundary is not a boolean. */ - public function setIncludeBoundary($includeBoundary) + public function setIncludeBoundary($includeBoundary): void { if (is_bool($includeBoundary)) { $this->includeBoundary = $includeBoundary; @@ -146,7 +147,7 @@ public function setIncludeBoundary($includeBoundary) * * @return bool A boolean value. */ - public function doesIncludeBoundary() + public function doesIncludeBoundary(): bool { return $this->includeBoundary; } @@ -154,7 +155,7 @@ public function doesIncludeBoundary() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'interpolationTableEntry'; } @@ -162,7 +163,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/state/InterpolationTableEntryCollection.php b/src/qtism/data/state/InterpolationTableEntryCollection.php index a71b0ac72..a2733c19d 100644 --- a/src/qtism/data/state/InterpolationTableEntryCollection.php +++ b/src/qtism/data/state/InterpolationTableEntryCollection.php @@ -37,7 +37,7 @@ class InterpolationTableEntryCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of InterpolationTableEntry. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof InterpolationTableEntry) { $msg = "InterpolationTableEntryCollection only accepts to store InterpolationTableEntry objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/LookupTable.php b/src/qtism/data/state/LookupTable.php index 62eff787c..48427e83b 100644 --- a/src/qtism/data/state/LookupTable.php +++ b/src/qtism/data/state/LookupTable.php @@ -65,6 +65,7 @@ public function __construct($defaultValue = null) * * @return mixed A value. */ + #[\ReturnTypeWillChange] public function getDefaultValue() { return $this->defaultValue; @@ -75,7 +76,7 @@ public function getDefaultValue() * * @param mixed $defaultValue A value. */ - public function setDefaultValue($defaultValue) + public function setDefaultValue($defaultValue): void { $this->defaultValue = $defaultValue; } @@ -83,7 +84,7 @@ public function setDefaultValue($defaultValue) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'lookupTable'; } @@ -91,7 +92,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/state/MapEntry.php b/src/qtism/data/state/MapEntry.php index 9ee0c67af..d4c01f567 100644 --- a/src/qtism/data/state/MapEntry.php +++ b/src/qtism/data/state/MapEntry.php @@ -88,7 +88,7 @@ public function __construct($mapKey, $mappedValue, $caseSensitive = true) * * @param mixed $mapKey A qti:valueType value. */ - public function setMapKey($mapKey) + public function setMapKey($mapKey): void { $this->mapKey = $mapKey; } @@ -98,6 +98,7 @@ public function setMapKey($mapKey) * * @return mixed A qti:valueType value. */ + #[\ReturnTypeWillChange] public function getMapKey() { return $this->mapKey; @@ -109,7 +110,7 @@ public function getMapKey() * @param float $mappedValue A mapped value. * @throws InvalidArgumentException If $mappedValue is not a float value. */ - public function setMappedValue($mappedValue) + public function setMappedValue($mappedValue): void { if (is_float($mappedValue)) { $this->mappedValue = $mappedValue; @@ -124,7 +125,7 @@ public function setMappedValue($mappedValue) * * @return float A mapped value. */ - public function getMappedValue() + public function getMappedValue(): float { return $this->mappedValue; } @@ -135,7 +136,7 @@ public function getMappedValue() * @param bool $caseSensitive * @throws InvalidArgumentException If $caseSensitive is not a boolean value. */ - public function setCaseSensitive($caseSensitive) + public function setCaseSensitive($caseSensitive): void { if (is_bool($caseSensitive)) { $this->caseSensitive = $caseSensitive; @@ -150,7 +151,7 @@ public function setCaseSensitive($caseSensitive) * * @return bool */ - public function isCaseSensitive() + public function isCaseSensitive(): bool { return $this->caseSensitive; } @@ -158,7 +159,7 @@ public function isCaseSensitive() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'mapEntry'; } @@ -166,7 +167,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/state/MapEntryCollection.php b/src/qtism/data/state/MapEntryCollection.php index 93cdac5bd..a9f37ad21 100644 --- a/src/qtism/data/state/MapEntryCollection.php +++ b/src/qtism/data/state/MapEntryCollection.php @@ -37,7 +37,7 @@ class MapEntryCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of MapEntry. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof MapEntry) { $msg = "MapEntryCollection only accepts to store MapEntry objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/Mapping.php b/src/qtism/data/state/Mapping.php index d9f8add43..a60dcd8f8 100644 --- a/src/qtism/data/state/Mapping.php +++ b/src/qtism/data/state/Mapping.php @@ -106,7 +106,7 @@ public function __construct(MapEntryCollection $mapEntries, $defaultValue = 0.0, * @param bool|float $lowerBound A float or false if not lower bound. * @throws InvalidArgumentException If $lowerBound is not a float nor false. */ - public function setLowerBound($lowerBound) + public function setLowerBound($lowerBound): void { if (is_float($lowerBound) || (is_bool($lowerBound) && $lowerBound === false)) { $this->lowerBound = $lowerBound; @@ -131,7 +131,7 @@ public function getLowerBound() * * @return bool */ - public function hasLowerBound() + public function hasLowerBound(): bool { return $this->getLowerBound() !== false; } @@ -142,7 +142,7 @@ public function hasLowerBound() * @param bool|float $upperBound A float value or false if not specified. * @throws InvalidArgumentException If $upperBound is not a float nor false. */ - public function setUpperBound($upperBound) + public function setUpperBound($upperBound): void { if (is_float($upperBound) || (is_bool($upperBound) && $upperBound === false)) { $this->upperBound = $upperBound; @@ -167,7 +167,7 @@ public function getUpperBound() * * @return bool */ - public function hasUpperBound() + public function hasUpperBound(): bool { return $this->getUpperBound() !== false; } @@ -178,7 +178,7 @@ public function hasUpperBound() * @param float $defaultValue A float value. * @throws InvalidArgumentException If $defaultValue is not a float value. */ - public function setDefaultValue($defaultValue) + public function setDefaultValue($defaultValue): void { if (is_numeric($defaultValue)) { $this->defaultValue = $defaultValue; @@ -193,7 +193,7 @@ public function setDefaultValue($defaultValue) * * @return float A default value as a float. */ - public function getDefaultValue() + public function getDefaultValue(): float { return $this->defaultValue; } @@ -204,7 +204,7 @@ public function getDefaultValue() * @param MapEntryCollection $mapEntries A collection of MapEntry objects with at least one item. * @throws InvalidArgumentException If $mapEnties is an empty collection. */ - public function setMapEntries(MapEntryCollection $mapEntries) + public function setMapEntries(MapEntryCollection $mapEntries): void { if (count($mapEntries) > 0) { $this->mapEntries = $mapEntries; @@ -219,7 +219,7 @@ public function setMapEntries(MapEntryCollection $mapEntries) * * @return MapEntryCollection A collection of MapEntry objects. */ - public function getMapEntries() + public function getMapEntries(): MapEntryCollection { return $this->mapEntries; } @@ -227,7 +227,7 @@ public function getMapEntries() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'mapping'; } @@ -235,7 +235,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection($this->getMapEntries()->getArrayCopy()); } diff --git a/src/qtism/data/state/MatchTable.php b/src/qtism/data/state/MatchTable.php index ecd9d4c08..5b5cd48e9 100644 --- a/src/qtism/data/state/MatchTable.php +++ b/src/qtism/data/state/MatchTable.php @@ -60,7 +60,7 @@ public function __construct(MatchTableEntryCollection $matchTableEntries, $defau * * @return MatchTableEntryCollection A collection of MatchTableEntry objects. */ - public function getMatchTableEntries() + public function getMatchTableEntries(): MatchTableEntryCollection { return $this->matchTableEntries; } @@ -71,7 +71,7 @@ public function getMatchTableEntries() * @param MatchTableEntryCollection $matchTableEntries A collection of MatchTableEntry objects. * @throws InvalidArgumentException If $matchTableEntries is an empty collection. */ - public function setMatchTableEntries(MatchTableEntryCollection $matchTableEntries) + public function setMatchTableEntries(MatchTableEntryCollection $matchTableEntries): void { if (count($matchTableEntries) > 0) { $this->matchTableEntries = $matchTableEntries; @@ -84,7 +84,7 @@ public function setMatchTableEntries(MatchTableEntryCollection $matchTableEntrie /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'matchTable'; } @@ -92,7 +92,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = array_merge( parent::getComponents()->getArrayCopy(), diff --git a/src/qtism/data/state/MatchTableEntry.php b/src/qtism/data/state/MatchTableEntry.php index 223807e22..3b8ba65b2 100644 --- a/src/qtism/data/state/MatchTableEntry.php +++ b/src/qtism/data/state/MatchTableEntry.php @@ -70,7 +70,7 @@ public function __construct($sourceValue, $targetValue) * * @return int An integer value. */ - public function getSourceValue() + public function getSourceValue(): int { return $this->sourceValue; } @@ -81,7 +81,7 @@ public function getSourceValue() * @param int $sourceValue An integer value. * @throws InvalidArgumentException If $sourceValue is not an integer. */ - public function setSourceValue($sourceValue) + public function setSourceValue($sourceValue): void { if (is_int($sourceValue)) { $this->sourceValue = $sourceValue; @@ -96,6 +96,7 @@ public function setSourceValue($sourceValue) * * @return mixed A value compliant with the QTI baseType datatype. */ + #[\ReturnTypeWillChange] public function getTargetValue() { return $this->targetValue; @@ -106,7 +107,7 @@ public function getTargetValue() * * @param mixed $targetValue A Value object. */ - public function setTargetValue($targetValue) + public function setTargetValue($targetValue): void { $this->targetValue = $targetValue; } @@ -114,7 +115,7 @@ public function setTargetValue($targetValue) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'matchTableEntry'; } @@ -122,7 +123,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/state/MatchTableEntryCollection.php b/src/qtism/data/state/MatchTableEntryCollection.php index c2572edf8..cfcf45efa 100644 --- a/src/qtism/data/state/MatchTableEntryCollection.php +++ b/src/qtism/data/state/MatchTableEntryCollection.php @@ -37,7 +37,7 @@ class MatchTableEntryCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of MatchTableEntry. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof MatchTableEntry) { $msg = "MatchTableEntryCollection only accepts to store MatchTableEntry objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/OutcomeDeclaration.php b/src/qtism/data/state/OutcomeDeclaration.php index b1293b106..c76b6eedc 100644 --- a/src/qtism/data/state/OutcomeDeclaration.php +++ b/src/qtism/data/state/OutcomeDeclaration.php @@ -181,7 +181,7 @@ public function __construct($identifier, $baseType = -1, $cardinality = Cardinal * * @return ViewCollection A Collection of values that are values from the View enumeration. */ - public function getViews() + public function getViews(): ViewCollection { return $this->views; } @@ -192,7 +192,7 @@ public function getViews() * * @param ViewCollection $views A collection of values that are values from the View enumeration. */ - public function setViews(ViewCollection $views) + public function setViews(ViewCollection $views): void { $this->views = $views; } @@ -203,7 +203,7 @@ public function setViews(ViewCollection $views) * * @return string A string. */ - public function getInterpretation() + public function getInterpretation(): string { return $this->interpretation; } @@ -214,7 +214,7 @@ public function getInterpretation() * @param string $interpretation A string. * @throws InvalidArgumentException If $interpretation is not a string. */ - public function setInterpretation($interpretation) + public function setInterpretation($interpretation): void { if (is_string($interpretation)) { $this->interpretation = $interpretation; @@ -229,7 +229,7 @@ public function setInterpretation($interpretation) * * @return string A URI. */ - public function getLongInterpretation() + public function getLongInterpretation(): string { return $this->longInterpretation; } @@ -240,7 +240,7 @@ public function getLongInterpretation() * @param string $longInterpretation A string. * @throws InvalidArgumentException If $longInterpretation is not a string. */ - public function setLongInterpretation($longInterpretation) + public function setLongInterpretation($longInterpretation): void { if (is_string($longInterpretation)) { $this->longInterpretation = $longInterpretation; @@ -266,7 +266,7 @@ public function getNormalMinimum() * @param mixed $normalMinimum A numeric value. * @throws InvalidArgumentException If $normalMinimum is not numeric nor false. */ - public function setNormalMinimum($normalMinimum) + public function setNormalMinimum($normalMinimum): void { if (is_numeric($normalMinimum) || (is_bool($normalMinimum) && $normalMinimum === false)) { $this->normalMinimum = $normalMinimum; @@ -292,7 +292,7 @@ public function getNormalMaximum() * @param bool|number $normalMaximum A numeric value. * @throws InvalidArgumentException If $normalMaximum is not a numeric value nor false. */ - public function setNormalMaximum($normalMaximum) + public function setNormalMaximum($normalMaximum): void { if (is_numeric($normalMaximum) || (is_bool($normalMaximum) && $normalMaximum === false)) { $this->normalMaximum = $normalMaximum; @@ -318,7 +318,7 @@ public function getMasteryValue() * @param bool|number $masteryValue A numeric value or false. * @throws InvalidArgumentException If $masteryValue is not numeric nor false. */ - public function setMasteryValue($masteryValue) + public function setMasteryValue($masteryValue): void { if (is_numeric($masteryValue) || (is_bool($masteryValue) && $masteryValue === false)) { $this->masteryValue = $masteryValue; @@ -333,7 +333,7 @@ public function setMasteryValue($masteryValue) * * @return LookupTable A LookupTable or null value if not specified. */ - public function getLookupTable() + public function getLookupTable(): ?LookupTable { return $this->lookupTable; } @@ -343,7 +343,7 @@ public function getLookupTable() * * @param LookupTable $lookupTable A LookupTable object. */ - public function setLookupTable(LookupTable $lookupTable = null) + public function setLookupTable(LookupTable $lookupTable = null): void { $this->lookupTable = $lookupTable; } @@ -351,7 +351,7 @@ public function setLookupTable(LookupTable $lookupTable = null) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'outcomeDeclaration'; } @@ -359,7 +359,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = parent::getComponents()->getArrayCopy(); @@ -375,7 +375,7 @@ public function getComponents() * * @param int|null $externalScored */ - public function setExternalScored($externalScored = null) + public function setExternalScored($externalScored = null): void { if ($externalScored !== null && !in_array($externalScored, ExternalScored::asArray(), true)) { throw new InvalidArgumentException(sprintf('Value %s is invalid in externalScored attribute', $externalScored)); @@ -388,7 +388,7 @@ public function setExternalScored($externalScored = null) * * @return int|null */ - public function getExternalScored() + public function getExternalScored(): ?int { return $this->externalScored; } @@ -398,7 +398,7 @@ public function getExternalScored() * * @return bool */ - public function isExternallyScored() + public function isExternallyScored(): bool { return $this->externalScored !== null; } @@ -408,7 +408,7 @@ public function isExternallyScored() * * @return bool */ - public function isScoredByHuman() + public function isScoredByHuman(): bool { return $this->externalScored === ExternalScored::HUMAN; } @@ -418,7 +418,7 @@ public function isScoredByHuman() * * @return bool */ - public function isScoredByExternalMachine() + public function isScoredByExternalMachine(): bool { return $this->externalScored === ExternalScored::EXTERNAL_MACHINE; } diff --git a/src/qtism/data/state/OutcomeDeclarationCollection.php b/src/qtism/data/state/OutcomeDeclarationCollection.php index 66ebf5e07..9ae56faad 100644 --- a/src/qtism/data/state/OutcomeDeclarationCollection.php +++ b/src/qtism/data/state/OutcomeDeclarationCollection.php @@ -37,7 +37,7 @@ class OutcomeDeclarationCollection extends QtiIdentifiableCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of OutcomeDeclaration. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof OutcomeDeclaration) { $msg = "OutcomeDeclarationCollection only accepts to store OutcomeDeclaration objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/ResponseDeclaration.php b/src/qtism/data/state/ResponseDeclaration.php index 2c13f7077..0d9bb6643 100644 --- a/src/qtism/data/state/ResponseDeclaration.php +++ b/src/qtism/data/state/ResponseDeclaration.php @@ -125,7 +125,7 @@ public function __construct($identifier, $baseType = -1, $cardinality = Cardinal * * @param CorrectResponse $correctResponse A CorrectResponse object or null. */ - public function setCorrectResponse(CorrectResponse $correctResponse = null) + public function setCorrectResponse(CorrectResponse $correctResponse = null): void { $this->correctResponse = $correctResponse; } @@ -135,7 +135,7 @@ public function setCorrectResponse(CorrectResponse $correctResponse = null) * * @return CorrectResponse A CorrectResponse object or null if no correct response is specified. */ - public function getCorrectResponse() + public function getCorrectResponse(): ?CorrectResponse { return $this->correctResponse; } @@ -145,7 +145,7 @@ public function getCorrectResponse() * * @param Mapping $mapping A Mapping object or null if no mapping is specified. */ - public function setMapping(Mapping $mapping = null) + public function setMapping(Mapping $mapping = null): void { $this->mapping = $mapping; } @@ -155,7 +155,7 @@ public function setMapping(Mapping $mapping = null) * * @return Mapping A Mapping object or null if no mapping specified. */ - public function getMapping() + public function getMapping(): ?Mapping { return $this->mapping; } @@ -165,7 +165,7 @@ public function getMapping() * * @param AreaMapping $areaMapping An AreaMapping object or null if no area mapping was specified. */ - public function setAreaMapping(AreaMapping $areaMapping = null) + public function setAreaMapping(AreaMapping $areaMapping = null): void { $this->areaMapping = $areaMapping; } @@ -173,9 +173,9 @@ public function setAreaMapping(AreaMapping $areaMapping = null) /** * Get the area mapping * - * @return AreaMapping An AreaMapping object or null if not area mapping is specified. + * @return AreaMapping|null An AreaMapping object or null if not area mapping is specified. */ - public function getAreaMapping() + public function getAreaMapping(): ?AreaMapping { return $this->areaMapping; } @@ -183,7 +183,7 @@ public function getAreaMapping() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'responseDeclaration'; } @@ -191,7 +191,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = parent::getComponents()->getArrayCopy(); diff --git a/src/qtism/data/state/ResponseDeclarationCollection.php b/src/qtism/data/state/ResponseDeclarationCollection.php index bdacd555c..8517986eb 100644 --- a/src/qtism/data/state/ResponseDeclarationCollection.php +++ b/src/qtism/data/state/ResponseDeclarationCollection.php @@ -37,7 +37,7 @@ class ResponseDeclarationCollection extends QtiIdentifiableCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of ResponseDeclaration. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof ResponseDeclaration) { $msg = "ResponseDeclarationCollection only accepts to store ResponseDeclaration objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/ResponseValidityConstraint.php b/src/qtism/data/state/ResponseValidityConstraint.php index f159b712e..cb7f42b23 100644 --- a/src/qtism/data/state/ResponseValidityConstraint.php +++ b/src/qtism/data/state/ResponseValidityConstraint.php @@ -96,7 +96,7 @@ public function __construct($responseIdentifier, $minConstraint, $maxConstraint, * @param int $responseIdentifier * @throws InvalidArgumentException If $responseIdentifier is not a non-empty string. */ - public function setResponseIdentifier($responseIdentifier) + public function setResponseIdentifier($responseIdentifier): void { if (is_string($responseIdentifier) === false || empty($responseIdentifier)) { throw new InvalidArgumentException( @@ -112,7 +112,7 @@ public function setResponseIdentifier($responseIdentifier) * * @return string */ - public function getResponseIdentifier() + public function getResponseIdentifier(): string { return $this->responseIdentifier; } @@ -123,7 +123,7 @@ public function getResponseIdentifier() * @param int $minConstraint A non negative integer (>= 0) integer value. * @throws InvalidArgumentException If $minConstraint is not a non negative (>= 0) integer value. */ - public function setMinConstraint($minConstraint) + public function setMinConstraint($minConstraint): void { if (is_int($minConstraint) === false || $minConstraint < 0) { throw new InvalidArgumentException( @@ -139,7 +139,7 @@ public function setMinConstraint($minConstraint) * * @return int A non negative (>= 0) integer value. */ - public function getMinConstraint() + public function getMinConstraint(): int { return $this->minConstraint; } @@ -152,7 +152,7 @@ public function getMinConstraint() * @param int $maxConstraint An integer value which is greater than the 'minConstraint' in place. * @throws InvalidArgumentException If $maxConstraint is not an integer greater or equal to the 'minConstraint' in place. */ - public function setMaxConstraint($maxConstraint) + public function setMaxConstraint($maxConstraint): void { if (is_int($maxConstraint) === false) { throw new InvalidArgumentException( @@ -178,7 +178,7 @@ public function setMaxConstraint($maxConstraint) * * @return int */ - public function getMaxConstraint() + public function getMaxConstraint(): int { return $this->maxConstraint; } @@ -192,7 +192,7 @@ public function getMaxConstraint() * * @param string $patternMask An XML Schema regular expression. */ - public function setPatternMask($patternMask) + public function setPatternMask($patternMask): void { if (is_string($patternMask) === false) { throw new InvalidArgumentException( @@ -212,7 +212,7 @@ public function setPatternMask($patternMask) * * @return string an XML Schema regulax expression. */ - public function getPatternMask() + public function getPatternMask(): string { return $this->patternMask; } @@ -222,8 +222,9 @@ public function getPatternMask() * * @param AssociationValidityConstraintCollection $associationValidityConstraints */ - public function setAssociationValidityConstraints(AssociationValidityConstraintCollection $associationValidityConstraints) - { + public function setAssociationValidityConstraints( + AssociationValidityConstraintCollection $associationValidityConstraints + ): void { $this->associationValidityConstraints = $associationValidityConstraints; } @@ -232,7 +233,7 @@ public function setAssociationValidityConstraints(AssociationValidityConstraintC * * @return AssociationValidityConstraintCollection */ - public function getAssociationValidityConstraints() + public function getAssociationValidityConstraints(): AssociationValidityConstraintCollection { return $this->associationValidityConstraints; } @@ -242,7 +243,7 @@ public function getAssociationValidityConstraints() * * @param AssociationValidityConstraint $associationValidityConstraint */ - public function addAssociationValidityConstraint(AssociationValidityConstraint $associationValidityConstraint) + public function addAssociationValidityConstraint(AssociationValidityConstraint $associationValidityConstraint): void { $this->getAssociationValidityConstraints()->attach($associationValidityConstraint); } @@ -254,15 +255,16 @@ public function addAssociationValidityConstraint(AssociationValidityConstraint $ * * @param AssociationValidityConstraint $associationValidityConstraint */ - public function removeAssociationValidityConstraint(AssociationValidityConstraint $associationValidityConstraint) - { + public function removeAssociationValidityConstraint( + AssociationValidityConstraint $associationValidityConstraint + ): void { $this->getAssociationValidityConstraints()->remove($associationValidityConstraint); } /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'responseValidityConstraint'; } @@ -270,7 +272,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection( $this->getAssociationValidityConstraints()->getArrayCopy() diff --git a/src/qtism/data/state/ResponseValidityConstraintCollection.php b/src/qtism/data/state/ResponseValidityConstraintCollection.php index a7d472aba..a35ffb578 100644 --- a/src/qtism/data/state/ResponseValidityConstraintCollection.php +++ b/src/qtism/data/state/ResponseValidityConstraintCollection.php @@ -37,7 +37,7 @@ class ResponseValidityConstraintCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of ResponseValidityConstraint. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof ResponseValidityConstraint) { $msg = "ResponseValidityConstraintCollection only accepts to store ResponseValidityConstraint objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/Shuffling.php b/src/qtism/data/state/Shuffling.php index ba6f552e4..8c374ef9b 100644 --- a/src/qtism/data/state/Shuffling.php +++ b/src/qtism/data/state/Shuffling.php @@ -73,7 +73,7 @@ public function __construct($responseIdentifier, ShufflingGroupCollection $shuff * * @param string $responseIdentifier */ - public function setResponseIdentifier($responseIdentifier) + public function setResponseIdentifier($responseIdentifier): void { $this->responseIdentifier = $responseIdentifier; } @@ -83,7 +83,7 @@ public function setResponseIdentifier($responseIdentifier) * * @return string */ - public function getResponseIdentifier() + public function getResponseIdentifier(): string { return $this->responseIdentifier; } @@ -94,7 +94,7 @@ public function getResponseIdentifier() * @param ShufflingGroupCollection $shufflingGroups * @throws InvalidArgumentException If $shufflingGroups does not contain 1 to 2 ShufflingGroup objects. */ - public function setShufflingGroups(ShufflingGroupCollection $shufflingGroups) + public function setShufflingGroups(ShufflingGroupCollection $shufflingGroups): void { if (count($shufflingGroups) === 0) { $msg = 'A Shuffling object must be composed of at least 1 ShufflingGroup object. None given'; @@ -112,7 +112,7 @@ public function setShufflingGroups(ShufflingGroupCollection $shufflingGroups) * * @return ShufflingGroupCollection */ - public function getShufflingGroups() + public function getShufflingGroups(): ShufflingGroupCollection { return $this->shufflingGroups; } @@ -125,7 +125,7 @@ public function getShufflingGroups() * * @return Shuffling */ - public function shuffle() + public function shuffle(): self { $shuffling = clone $this; $groups = $shuffling->getShufflingGroups(); @@ -170,7 +170,7 @@ public function shuffle() * @return string * @throws OutOfBoundsException */ - public function getIdentifierAt($index) + public function getIdentifierAt($index): string { $i = 0; @@ -204,7 +204,7 @@ public function __clone() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'shuffling'; } @@ -212,7 +212,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection($this->getShufflingGroups()->getArrayCopy()); } diff --git a/src/qtism/data/state/ShufflingCollection.php b/src/qtism/data/state/ShufflingCollection.php index 94bb00a01..5a721626f 100644 --- a/src/qtism/data/state/ShufflingCollection.php +++ b/src/qtism/data/state/ShufflingCollection.php @@ -37,7 +37,7 @@ class ShufflingCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of Shuffling. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Shuffling) { $msg = "ShufflingCollection only accepts to store Shuffling objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/ShufflingGroup.php b/src/qtism/data/state/ShufflingGroup.php index 878288527..3e9f83f99 100644 --- a/src/qtism/data/state/ShufflingGroup.php +++ b/src/qtism/data/state/ShufflingGroup.php @@ -66,7 +66,7 @@ public function __construct(IdentifierCollection $identifiers) * * @param IdentifierCollection $identifiers */ - public function setIdentifiers(IdentifierCollection $identifiers) + public function setIdentifiers(IdentifierCollection $identifiers): void { $this->identifiers = $identifiers; } @@ -76,7 +76,7 @@ public function setIdentifiers(IdentifierCollection $identifiers) * * @return IdentifierCollection */ - public function getIdentifiers() + public function getIdentifiers(): IdentifierCollection { return $this->identifiers; } @@ -86,7 +86,7 @@ public function getIdentifiers() * * @param IdentifierCollection $fixedIdentifiers */ - public function setFixedIdentifiers(IdentifierCollection $fixedIdentifiers) + public function setFixedIdentifiers(IdentifierCollection $fixedIdentifiers): void { $this->fixedIdentifiers = $fixedIdentifiers; } @@ -96,7 +96,7 @@ public function setFixedIdentifiers(IdentifierCollection $fixedIdentifiers) * * @return IdentifierCollection */ - public function getFixedIdentifiers() + public function getFixedIdentifiers(): IdentifierCollection { return $this->fixedIdentifiers; } @@ -112,7 +112,7 @@ public function __clone() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'shufflingGroup'; } @@ -120,7 +120,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/state/ShufflingGroupCollection.php b/src/qtism/data/state/ShufflingGroupCollection.php index 490155760..318c81cce 100644 --- a/src/qtism/data/state/ShufflingGroupCollection.php +++ b/src/qtism/data/state/ShufflingGroupCollection.php @@ -37,7 +37,7 @@ class ShufflingGroupCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of ShufflingGroup. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof ShufflingGroup) { $msg = "ShufflingGroupCollection only accepts to store ShufflingGroup objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/TemplateDeclaration.php b/src/qtism/data/state/TemplateDeclaration.php index 4b208baab..bc2ed647f 100644 --- a/src/qtism/data/state/TemplateDeclaration.php +++ b/src/qtism/data/state/TemplateDeclaration.php @@ -83,7 +83,7 @@ public function __construct($identifier, $baseType = -1, $cardinality = Cardinal * @param bool $paramVariable A boolean value. * @throws InvalidArgumentException If $paramVariable is not a boolean value. */ - public function setParamVariable($paramVariable) + public function setParamVariable($paramVariable): void { if (is_bool($paramVariable)) { $this->paramVariable = $paramVariable; @@ -99,7 +99,7 @@ public function setParamVariable($paramVariable) * * @return bool */ - public function isParamVariable() + public function isParamVariable(): bool { return $this->paramVariable; } @@ -111,7 +111,7 @@ public function isParamVariable() * @param bool $mathVariable A boolean value. * @throws InvalidArgumentException If $mathVariable is not a boolean value. */ - public function setMathVariable($mathVariable) + public function setMathVariable($mathVariable): void { if (is_bool($mathVariable)) { $this->mathVariable = $mathVariable; @@ -127,7 +127,7 @@ public function setMathVariable($mathVariable) * * @return bool */ - public function isMathVariable() + public function isMathVariable(): bool { return $this->mathVariable; } @@ -135,7 +135,7 @@ public function isMathVariable() /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'templateDeclaration'; } diff --git a/src/qtism/data/state/TemplateDeclarationCollection.php b/src/qtism/data/state/TemplateDeclarationCollection.php index d5806d2e8..9a803dced 100644 --- a/src/qtism/data/state/TemplateDeclarationCollection.php +++ b/src/qtism/data/state/TemplateDeclarationCollection.php @@ -37,7 +37,7 @@ class TemplateDeclarationCollection extends QtiIdentifiableCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of TemplateDeclaration. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof TemplateDeclaration) { $msg = "TemplateDeclarationCollection only accepts to store TemplateDeclaration objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/TemplateDefault.php b/src/qtism/data/state/TemplateDefault.php index b99e23712..e7dc936ee 100644 --- a/src/qtism/data/state/TemplateDefault.php +++ b/src/qtism/data/state/TemplateDefault.php @@ -75,7 +75,7 @@ public function __construct($templateIdentifier, Expression $expression) * * @return string A QTI identifier. */ - public function getTemplateIdentifier() + public function getTemplateIdentifier(): string { return $this->templateIdentifier; } @@ -86,7 +86,7 @@ public function getTemplateIdentifier() * @param string $templateIdentifier A QTI identifier. * @throws InvalidArgumentException If $templateIdentifier is not a valid QTI Identifier. */ - public function setTemplateIdentifier($templateIdentifier) + public function setTemplateIdentifier($templateIdentifier): void { if (Format::isIdentifier($templateIdentifier)) { $this->templateIdentifier = $templateIdentifier; @@ -101,7 +101,7 @@ public function setTemplateIdentifier($templateIdentifier) * * @return Expression A QTI Expression. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -111,7 +111,7 @@ public function getExpression() * * @param Expression $expression A QTI Expression. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $this->expression = $expression; } @@ -119,7 +119,7 @@ public function setExpression(Expression $expression) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'templateDefault'; } @@ -127,7 +127,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection([$this->getExpression()]); } diff --git a/src/qtism/data/state/TemplateDefaultCollection.php b/src/qtism/data/state/TemplateDefaultCollection.php index 0b2ca52d9..d11d36376 100644 --- a/src/qtism/data/state/TemplateDefaultCollection.php +++ b/src/qtism/data/state/TemplateDefaultCollection.php @@ -37,7 +37,7 @@ class TemplateDefaultCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of TemplateDefault. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof TemplateDefault) { $msg = "TemplateDefaultCollection only accepts to store TemplateDefault objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/Value.php b/src/qtism/data/state/Value.php index a15f7f2d7..761193219 100644 --- a/src/qtism/data/state/Value.php +++ b/src/qtism/data/state/Value.php @@ -105,7 +105,7 @@ public function __construct($value, $baseType = -1, $fieldIdentifier = '') * @param bool $partOfRecord * @throws InvalidArgumentException If $partOfRecord is not a boolean. */ - public function setPartOfRecord($partOfRecord) + public function setPartOfRecord($partOfRecord): void { if (is_bool($partOfRecord)) { $this->isPartOfRecord = $partOfRecord; @@ -120,7 +120,7 @@ public function setPartOfRecord($partOfRecord) * * @return bool */ - public function isPartOfRecord() + public function isPartOfRecord(): bool { return $this->isPartOfRecord; } @@ -130,7 +130,7 @@ public function isPartOfRecord() * * @return string A QTI identifier. */ - public function getFieldIdentifier() + public function getFieldIdentifier(): string { return $this->fieldIdentifier; } @@ -141,7 +141,7 @@ public function getFieldIdentifier() * @param string $fieldIdentifier A QTI identifier. * @throws InvalidArgumentException If $fieldIdentifier is not a valid QTI Identifier. */ - public function setFieldIdentifier($fieldIdentifier) + public function setFieldIdentifier($fieldIdentifier): void { if ($fieldIdentifier == '' || Format::isIdentifier($fieldIdentifier)) { $this->fieldIdentifier = $fieldIdentifier; @@ -156,7 +156,7 @@ public function setFieldIdentifier($fieldIdentifier) * * @return bool */ - public function hasFieldIdentifier() + public function hasFieldIdentifier(): bool { return $this->getFieldIdentifier() !== ''; } @@ -166,7 +166,7 @@ public function hasFieldIdentifier() * * @return int A value of the BaseType enumeration or a negative value (< 0) if there is no baseType. */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -177,7 +177,7 @@ public function getBaseType() * @param int $baseType A value of the BaseType enumeration. A negative value (< 0) means there is no baseType. * @throws InvalidArgumentException If $baseType is not a value from the BaseType operation. */ - public function setBaseType($baseType) + public function setBaseType($baseType): void { if (in_array($baseType, BaseType::asArray()) || $baseType === -1) { $this->baseType = $baseType; @@ -192,7 +192,7 @@ public function setBaseType($baseType) * * @return bool */ - public function hasBaseType() + public function hasBaseType(): bool { return $this->getBaseType() !== -1; } @@ -202,6 +202,7 @@ public function hasBaseType() * * @return mixed A value with a datatype depending on the baseType of the Value. */ + #[\ReturnTypeWillChange] public function getValue() { return $this->value; @@ -213,7 +214,7 @@ public function getValue() * * @param mixed $value A value with a correct datatype regarding the baseType. */ - public function setValue($value) + public function setValue($value): void { $this->value = $value; } @@ -221,7 +222,7 @@ public function setValue($value) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'value'; } @@ -229,7 +230,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/state/ValueCollection.php b/src/qtism/data/state/ValueCollection.php index 0c1ca38e9..3efcc6045 100644 --- a/src/qtism/data/state/ValueCollection.php +++ b/src/qtism/data/state/ValueCollection.php @@ -37,7 +37,7 @@ class ValueCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of Value. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Value) { $msg = "ValueCollection only accepts to store Value objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/VariableDeclaration.php b/src/qtism/data/state/VariableDeclaration.php index e3c26eddf..d559b5400 100644 --- a/src/qtism/data/state/VariableDeclaration.php +++ b/src/qtism/data/state/VariableDeclaration.php @@ -122,7 +122,7 @@ public function __construct($identifier, $baseType = -1, $cardinality = Cardinal * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -133,7 +133,7 @@ public function getIdentifier() * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI Identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false)) { $this->identifier = $identifier; @@ -149,7 +149,7 @@ public function setIdentifier($identifier) * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -160,7 +160,7 @@ public function getBaseType() * @param int $baseType A value from the BaseType enumeration. * @throws InvalidArgumentException If $baseType is not a value from the BaseType enumeration. */ - public function setBaseType($baseType) + public function setBaseType($baseType): void { if (in_array($baseType, BaseType::asArray()) || $baseType === -1) { $this->baseType = $baseType; @@ -176,7 +176,7 @@ public function setBaseType($baseType) * * @return bool */ - public function hasBaseType() + public function hasBaseType(): bool { return $this->getBaseType() !== -1; } @@ -187,7 +187,7 @@ public function hasBaseType() * * @return DefaultValue A DefaultValue object. */ - public function getDefaultValue() + public function getDefaultValue(): ?DefaultValue { return $this->defaultValue; } @@ -198,7 +198,7 @@ public function getDefaultValue() * * @param DefaultValue $defaultValue A DefaultValue object. */ - public function setDefaultValue(DefaultValue $defaultValue = null) + public function setDefaultValue(DefaultValue $defaultValue = null): void { $this->defaultValue = $defaultValue; } @@ -208,7 +208,7 @@ public function setDefaultValue(DefaultValue $defaultValue = null) * * @return bool */ - public function hasDefaultValue() + public function hasDefaultValue(): bool { return $this->getDefaultValue() !== null; } @@ -218,7 +218,7 @@ public function hasDefaultValue() * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return $this->cardinality; } @@ -229,7 +229,7 @@ public function getCardinality() * @param int $cardinality A value from the Cardinality enumeration. * @throws InvalidArgumentException If $cardinality is not a value from the Cardinality enumeration. */ - public function setCardinality($cardinality) + public function setCardinality($cardinality): void { if (in_array($cardinality, Cardinality::asArray())) { $this->cardinality = $cardinality; @@ -242,7 +242,7 @@ public function setCardinality($cardinality) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'variableDeclaration'; } @@ -250,7 +250,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { $comp = []; diff --git a/src/qtism/data/state/VariableDeclarationCollection.php b/src/qtism/data/state/VariableDeclarationCollection.php index 256d513c3..a672a976e 100644 --- a/src/qtism/data/state/VariableDeclarationCollection.php +++ b/src/qtism/data/state/VariableDeclarationCollection.php @@ -37,7 +37,7 @@ class VariableDeclarationCollection extends QtiIdentifiableCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of VariableDeclaration. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof VariableDeclaration) { $msg = "InterpolationTableEntryCollection only accepts to store VariableDeclaration objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/VariableMapping.php b/src/qtism/data/state/VariableMapping.php index 887922f17..d353c60ef 100644 --- a/src/qtism/data/state/VariableMapping.php +++ b/src/qtism/data/state/VariableMapping.php @@ -72,7 +72,7 @@ public function __construct($source, $target) * * @return string A QTI identifier. */ - public function getSource() + public function getSource(): string { return $this->source; } @@ -83,7 +83,7 @@ public function getSource() * @param string $source A valid QTI identifier. * @throws InvalidArgumentException If $source is not a valid QTI identifier. */ - public function setSource($source) + public function setSource($source): void { if (Format::isIdentifier($source)) { $this->source = $source; @@ -98,7 +98,7 @@ public function setSource($source) * * @return string A QTI identifier. */ - public function getTarget() + public function getTarget(): string { return $this->target; } @@ -109,7 +109,7 @@ public function getTarget() * @param string $target A valid QTI identifier. * @throws InvalidArgumentException If $target is not a valid QTI identifier. */ - public function setTarget($target) + public function setTarget($target): void { if (Format::isIdentifier($target)) { $this->target = $target; @@ -122,7 +122,7 @@ public function setTarget($target) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'variableMapping'; } @@ -130,7 +130,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/state/VariableMappingCollection.php b/src/qtism/data/state/VariableMappingCollection.php index aaa811133..97a4127e5 100644 --- a/src/qtism/data/state/VariableMappingCollection.php +++ b/src/qtism/data/state/VariableMappingCollection.php @@ -37,7 +37,7 @@ class VariableMappingCollection extends QtiComponentCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of VariableMapping. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof VariableMapping) { $msg = "VariableMappingCollection only accepts to store VariableMapping objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/state/Weight.php b/src/qtism/data/state/Weight.php index 7fa5be0fb..2b4531c2e 100644 --- a/src/qtism/data/state/Weight.php +++ b/src/qtism/data/state/Weight.php @@ -79,7 +79,7 @@ public function __construct($identifier, $value) * * @return string A QTI identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -90,7 +90,7 @@ public function getIdentifier() * @param string $identifier A QTI Identifier. * @throws InvalidArgumentException If $identifier is not a valid QTI identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { if (Format::isIdentifier($identifier, false)) { $this->identifier = $identifier; @@ -117,7 +117,7 @@ public function getValue() * @param int|float $value A in integer/float value. * @throws InvalidArgumentException If $value is not an integer nor a float. */ - public function setValue($value) + public function setValue($value): void { if (is_int($value) || is_float($value)) { $this->value = $value; @@ -130,7 +130,7 @@ public function setValue($value) /** * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return 'weight'; } @@ -138,7 +138,7 @@ public function getQtiClassName() /** * @return QtiComponentCollection */ - public function getComponents() + public function getComponents(): QtiComponentCollection { return new QtiComponentCollection(); } diff --git a/src/qtism/data/state/WeightCollection.php b/src/qtism/data/state/WeightCollection.php index e5eebeed2..f6d066957 100644 --- a/src/qtism/data/state/WeightCollection.php +++ b/src/qtism/data/state/WeightCollection.php @@ -37,7 +37,7 @@ class WeightCollection extends QtiIdentifiableCollection * @param mixed $value * @throws InvalidArgumentException If the given $value is not an instance of Weight. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Weight) { $msg = "WeightCollection only accepts to store Weight objects, '" . gettype($value) . "' given."; diff --git a/src/qtism/data/storage/FileResolver.php b/src/qtism/data/storage/FileResolver.php index d8e6c73d9..698e94f9e 100644 --- a/src/qtism/data/storage/FileResolver.php +++ b/src/qtism/data/storage/FileResolver.php @@ -55,7 +55,7 @@ public function __construct($basePath = '') * @param string $basePath A base path. * @throws InvalidArgumentException If $basePath is not a string value. */ - public function setBasePath($basePath = '') + public function setBasePath($basePath = ''): void { if (is_string($basePath)) { $this->basePath = $basePath; @@ -70,7 +70,7 @@ public function setBasePath($basePath = '') * * @return string A base path. */ - public function getBasePath() + public function getBasePath(): string { return $this->basePath; } diff --git a/src/qtism/data/storage/LocalFileResolver.php b/src/qtism/data/storage/LocalFileResolver.php index ef151f68c..b55622282 100644 --- a/src/qtism/data/storage/LocalFileResolver.php +++ b/src/qtism/data/storage/LocalFileResolver.php @@ -51,7 +51,7 @@ public function __construct($basePath = '') * @return string href * @throws ResolutionException If $url cannot be resolved. */ - public function resolve($url) + public function resolve($url): string { $baseUrl = Utils::sanitizeUri($this->getBasePath()); $baseDir = pathinfo($baseUrl, PATHINFO_DIRNAME); diff --git a/src/qtism/data/storage/StorageException.php b/src/qtism/data/storage/StorageException.php index bb9e18445..8b5ebd5bd 100644 --- a/src/qtism/data/storage/StorageException.php +++ b/src/qtism/data/storage/StorageException.php @@ -37,28 +37,28 @@ class StorageException extends Exception implements QtiSdkPackageContentExceptio * * @var int */ - const UNKNOWN = 0; + public const UNKNOWN = 0; /** * The error occurred while reading. * * @var int */ - const READ = 1; + public const READ = 1; /** * The error occurred while writing. * * @var int */ - const WRITE = 2; + public const WRITE = 2; /** * The error is related to a version issue. * * @var int */ - const VERSION = 3; + public const VERSION = 3; /** * Create a new StorageException object. diff --git a/src/qtism/data/storage/Utils.php b/src/qtism/data/storage/Utils.php index fe7759382..2c5a81f9b 100644 --- a/src/qtism/data/storage/Utils.php +++ b/src/qtism/data/storage/Utils.php @@ -49,6 +49,7 @@ class Utils * @throws InvalidArgumentException If $baseType is not a value from the BaseType enumeration. * @throws UnexpectedValueException If $string cannot be transformed in a Value expression with the given $baseType. */ + #[\ReturnTypeWillChange] public static function stringToDatatype(?string $string, int $baseType) { $string = $string ?? ''; @@ -141,7 +142,7 @@ public static function stringToDatatype(?string $string, int $baseType) throw new RuntimeException('Unsupported baseType: file.'); case BaseType::STRING: - return '' . $string; + return (string)$string; case BaseType::POINT: if (!Format::isPoint($string)) { @@ -180,7 +181,7 @@ public static function stringToBoolean(string $string): bool * @throws UnexpectedValueException If $string cannot be converted to a Coords object. * @throws InvalidArgumentException If $string is are not valid coordinates or $shape is not a value from the Shape enumeration. */ - public static function stringToCoords(string $string, int $shape) + public static function stringToCoords(string $string, int $shape): QtiCoords { if (Format::isCoords($string)) { $stringCoords = explode(',', $string); @@ -209,7 +210,7 @@ public static function stringToCoords(string $string, int $shape) * @return string A sanitized Uniform Resource Identifier. * @throws InvalidArgumentException If $uri is not a string. */ - public static function sanitizeUri($uri) + public static function sanitizeUri($uri): string { if (is_string($uri)) { return rtrim($uri, '/'); diff --git a/src/qtism/data/storage/php/PhpArgument.php b/src/qtism/data/storage/php/PhpArgument.php index 4aadb7a76..ce8fdc69a 100644 --- a/src/qtism/data/storage/php/PhpArgument.php +++ b/src/qtism/data/storage/php/PhpArgument.php @@ -61,7 +61,7 @@ public function __construct($value) * @param mixed $value A PHP scalar value or a PhpVariable object or null or a PhpVariable object. * @throws InvalidArgumentException If $value is not a PHP scalar value nor a PhpVariable object nor null. */ - public function setValue($value) + public function setValue($value): void { if ($value instanceof PhpVariable || Utils::isScalar($value)) { $this->value = $value; @@ -77,6 +77,7 @@ public function setValue($value) * * @return mixed A PhpVariable object or a PHP scalar value or null. */ + #[\ReturnTypeWillChange] public function getValue() { return $this->value; @@ -88,7 +89,7 @@ public function getValue() * * @return bool */ - public function isVariableReference() + public function isVariableReference(): bool { return $this->getValue() instanceof PhpVariable; } @@ -98,7 +99,7 @@ public function isVariableReference() * * @return bool */ - public function isScalar() + public function isScalar(): bool { return Utils::isScalar($this->getValue()); } diff --git a/src/qtism/data/storage/php/PhpArgumentCollection.php b/src/qtism/data/storage/php/PhpArgumentCollection.php index 0431ac339..f5d4d51af 100644 --- a/src/qtism/data/storage/php/PhpArgumentCollection.php +++ b/src/qtism/data/storage/php/PhpArgumentCollection.php @@ -37,7 +37,7 @@ class PhpArgumentCollection extends AbstractCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of PhpArgumentCollection. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof PhpArgument) { $msg = 'A PhpArgumentCollection only accepts PhpArgument objects to be stored.'; diff --git a/src/qtism/data/storage/php/PhpDocument.php b/src/qtism/data/storage/php/PhpDocument.php index 9913b6ce1..1c21ca8fe 100644 --- a/src/qtism/data/storage/php/PhpDocument.php +++ b/src/qtism/data/storage/php/PhpDocument.php @@ -95,7 +95,7 @@ public function save(string $url): void * @throws ReflectionException * @throws StreamAccessException */ - protected function transformToPhp() + protected function transformToPhp(): MemoryStream { $stack = new SplStack(); $stack->push($this->getDocumentComponent()); @@ -208,7 +208,7 @@ public function load(string $url): void * @param $object * @return string */ - protected static function getBaseImplementation($object) + protected static function getBaseImplementation($object): string { if ($object instanceof ExtendedAssessmentTest) { return ExtendedAssessmentTest::class; diff --git a/src/qtism/data/storage/php/PhpStreamAccess.php b/src/qtism/data/storage/php/PhpStreamAccess.php index b5c8ebc23..94b4d5518 100644 --- a/src/qtism/data/storage/php/PhpStreamAccess.php +++ b/src/qtism/data/storage/php/PhpStreamAccess.php @@ -57,7 +57,7 @@ public function __construct(IStream $stream) * @throws InvalidArgumentException If $scalar is not a PHP scalar value nor null. * @throws StreamAccessException If an error occurs while writing the scalar value. */ - public function writeScalar($scalar) + public function writeScalar($scalar): void { if (Utils::isScalar($scalar) === false) { $msg = "A '" . gettype($scalar) . "' value is not a PHP scalar value nor null."; @@ -92,7 +92,7 @@ public function writeScalar($scalar) * @param bool $spaces Whether to surround the equality symbol with spaces. * @throws StreamAccessException If an error occurs while writing the equality symbol. */ - public function writeEquals($spaces = true) + public function writeEquals($spaces = true): void { try { if ($spaces === true) { @@ -111,7 +111,7 @@ public function writeEquals($spaces = true) * * @throws StreamAccessException If an error occurs while writing the equality symbol. */ - public function writeNewline() + public function writeNewline(): void { try { $this->getStream()->write("\n"); @@ -127,7 +127,7 @@ public function writeNewline() * @param bool $newline Whether a newline escape sequence must be written after the opening tag. * @throws StreamAccessException If an error occurs while writing the opening tag. */ - public function writeOpeningTag($newline = true) + public function writeOpeningTag($newline = true): void { try { $this->getStream()->write('getStream()->write(';'); @@ -183,7 +183,7 @@ public function writeSemicolon($newline = true) * * @throws StreamAccessException If an error occurs while writing the colon. */ - public function writeColon() + public function writeColon(): void { try { $this->getStream()->write(':'); @@ -198,7 +198,7 @@ public function writeColon() * * @throws StreamAccessException If an error occurs while writing the scope resolution operator. */ - public function writeScopeResolution() + public function writeScopeResolution(): void { try { $this->getStream()->write('::'); @@ -214,7 +214,7 @@ public function writeScopeResolution() * @throws StreamAccessException If an error occurs while writing the "Paamayim Nekudotayim". * @see PhpStreamAccess::writeScopeResolution */ - public function writePaamayimNekudotayim() + public function writePaamayimNekudotayim(): void { try { $this->writeScopeResolution(); @@ -229,7 +229,7 @@ public function writePaamayimNekudotayim() * * @throws StreamAccessException If an error occurs while writing the opening parenthesis. */ - public function writeOpeningParenthesis() + public function writeOpeningParenthesis(): void { try { $this->getStream()->write('('); @@ -244,7 +244,7 @@ public function writeOpeningParenthesis() * * @throws StreamAccessException If an error occurs while writing the closing parenthesis. */ - public function writeClosingParenthesis() + public function writeClosingParenthesis(): void { try { $this->getStream()->write(')'); @@ -260,7 +260,7 @@ public function writeClosingParenthesis() * @param bool $space Whether a white space must be written after the comma. * @throws StreamAccessException If an error occurs while writing the comma. */ - public function writeComma($space = true) + public function writeComma($space = true): void { try { $this->getStream()->write(','); @@ -278,7 +278,7 @@ public function writeComma($space = true) * * @throws StreamAccessException If an error occurs while writing the white space. */ - public function writeSpace() + public function writeSpace(): void { try { $this->getStream()->write(' '); @@ -294,7 +294,7 @@ public function writeSpace() * @param string $varname The name of the variable reference to write. * @throws StreamAccessException If an error occurs while writing the variable reference. */ - public function writeVariable($varname) + public function writeVariable($varname): void { try { $this->getStream()->write('$' . $varname); @@ -309,7 +309,7 @@ public function writeVariable($varname) * * @throws StreamAccessException If an error occurs while writing the object operator. */ - public function writeObjectOperator() + public function writeObjectOperator(): void { try { $this->getStream()->write('->'); @@ -326,7 +326,7 @@ public function writeObjectOperator() * @param PhpArgumentCollection $arguments A collection of PhpArgument objects representing the arguments to be given to the function call. * @throws StreamAccessException If an error occurs while writing the function call. */ - public function writeFunctionCall($funcname, PhpArgumentCollection $arguments = null) + public function writeFunctionCall($funcname, PhpArgumentCollection $arguments = null): void { try { $this->getStream()->write($funcname); @@ -352,8 +352,12 @@ public function writeFunctionCall($funcname, PhpArgumentCollection $arguments = * @param bool $static Whether or not the call is static. * @throws StreamAccessException If an error occurs while writing the method call. */ - public function writeMethodCall($objectname, $methodname, PhpArgumentCollection $arguments = null, $static = false) - { + public function writeMethodCall( + $objectname, + $methodname, + PhpArgumentCollection $arguments = null, + $static = false + ): void { try { $this->writeVariable($objectname); @@ -383,7 +387,7 @@ public function writeMethodCall($objectname, $methodname, PhpArgumentCollection * @param bool $space Whether to write an extra white space after the new operator. * @throws StreamAccessException If an error occurs while writing the new operator. */ - public function writeNew($space = true) + public function writeNew($space = true): void { try { $this->getStream()->write('new'); @@ -403,7 +407,7 @@ public function writeNew($space = true) * @param PhpArgumentCollection $arguments A collection of PhpArgument objects. * @throws StreamAccessException */ - public function writeInstantiation($classname, PhpArgumentCollection $arguments = null) + public function writeInstantiation($classname, PhpArgumentCollection $arguments = null): void { try { $this->writeNew(); @@ -427,7 +431,7 @@ public function writeInstantiation($classname, PhpArgumentCollection $arguments * @param PhpArgumentCollection $arguments A collection of PhpArgument objects. * @throws StreamAccessException If an error occurs while writing the sequence of arguments. */ - public function writeArguments(PhpArgumentCollection $arguments) + public function writeArguments(PhpArgumentCollection $arguments): void { try { $argsCount = count($arguments); @@ -451,7 +455,7 @@ public function writeArguments(PhpArgumentCollection $arguments) * @param PhpArgument $argument A PhpArgument object. * @throws StreamAccessException If an error occurs while writing the PHP argument. */ - public function writeArgument(PhpArgument $argument) + public function writeArgument(PhpArgument $argument): void { try { $value = $argument->getValue(); diff --git a/src/qtism/data/storage/php/PhpVariable.php b/src/qtism/data/storage/php/PhpVariable.php index 282e2356b..37fdae7ed 100644 --- a/src/qtism/data/storage/php/PhpVariable.php +++ b/src/qtism/data/storage/php/PhpVariable.php @@ -54,7 +54,7 @@ public function __construct($name) * @param string $name The name of the variable without the leading dollar sign ('$'). * @throws InvalidArgumentException If $name is not a string value. */ - public function setName($name) + public function setName($name): void { if (is_string($name) === false) { $msg = "The 'name' argument must be a string value, '" . gettype($name) . "' given."; @@ -69,7 +69,7 @@ public function setName($name) * * @return string A variable name without the leading dollar sign ('$'). */ - public function getName() + public function getName(): string { return $this->name; } diff --git a/src/qtism/data/storage/php/Utils.php b/src/qtism/data/storage/php/Utils.php index 5f6542fab..2a577f15d 100644 --- a/src/qtism/data/storage/php/Utils.php +++ b/src/qtism/data/storage/php/Utils.php @@ -37,7 +37,7 @@ class Utils * @param mixed $value * @return bool */ - public static function isScalar($value) + public static function isScalar($value): bool { return is_scalar($value) || $value === null; } @@ -48,7 +48,7 @@ public static function isScalar($value) * @param string $string * @return bool */ - public static function isVariableReference($string) + public static function isVariableReference($string): bool { return is_string($string) && mb_strpos($string, '$') === 0 && mb_strlen($string, 'UTF-8') > 1; } @@ -59,7 +59,7 @@ public static function isVariableReference($string) * @param string $string The string to be quoted (e.g. blabla). * @return string The quoted string (e.g. "blabla"). */ - public static function doubleQuotedPhpString($string) + public static function doubleQuotedPhpString($string): string { $escapes = ["\\", '"', "\n", "\t", "\v", "\r", "\f", '$']; $replace = ["\\\\", '\\"', "\\n", "\\t", "\\v", "\\r", "\\f", "\\$"]; diff --git a/src/qtism/data/storage/php/marshalling/PhpArrayMarshaller.php b/src/qtism/data/storage/php/marshalling/PhpArrayMarshaller.php index b2134a94c..f280882e1 100644 --- a/src/qtism/data/storage/php/marshalling/PhpArrayMarshaller.php +++ b/src/qtism/data/storage/php/marshalling/PhpArrayMarshaller.php @@ -40,7 +40,7 @@ class PhpArrayMarshaller extends PhpMarshaller * @throws PhpMarshallingException If something wrong happens during marshalling. * @throws StreamAccessException */ - public function marshall() + public function marshall(): void { $ctx = $this->getContext(); $access = $ctx->getStreamAccess(); @@ -73,7 +73,7 @@ public function marshall() * * @return bool */ - protected function isMarshallable($toMarshall) + protected function isMarshallable($toMarshall): bool { return is_array($toMarshall); } diff --git a/src/qtism/data/storage/php/marshalling/PhpCollectionMarshaller.php b/src/qtism/data/storage/php/marshalling/PhpCollectionMarshaller.php index 0df72c574..244b490e6 100644 --- a/src/qtism/data/storage/php/marshalling/PhpCollectionMarshaller.php +++ b/src/qtism/data/storage/php/marshalling/PhpCollectionMarshaller.php @@ -40,7 +40,7 @@ class PhpCollectionMarshaller extends PhpMarshaller * * @throws PhpMarshallingException If something wrong happens during marshalling. */ - public function marshall() + public function marshall(): void { $collection = $this->getToMarshall(); $ctx = $this->getContext(); @@ -83,7 +83,7 @@ public function marshall() * @param mixed $toMarshall * @return bool */ - protected function isMarshallable($toMarshall) + protected function isMarshallable($toMarshall): bool { return $toMarshall instanceof AbstractCollection; } diff --git a/src/qtism/data/storage/php/marshalling/PhpMarshaller.php b/src/qtism/data/storage/php/marshalling/PhpMarshaller.php index f3ce5e4c2..ae0d6c2f7 100644 --- a/src/qtism/data/storage/php/marshalling/PhpMarshaller.php +++ b/src/qtism/data/storage/php/marshalling/PhpMarshaller.php @@ -63,7 +63,7 @@ public function __construct(PhpMarshallingContext $context, $toMarshall) * @param mixed $toMarshall The value to be marshalled. * @throws InvalidArgumentException If the value $toMarshall cannot be managed by this implementation. */ - public function setToMarshall($toMarshall) + public function setToMarshall($toMarshall): void { if ($this->isMarshallable($toMarshall) === false) { $msg = 'The value to marshall cannot be managed by this implementation.'; @@ -78,6 +78,7 @@ public function setToMarshall($toMarshall) * * @return mixed A value to be marshalled. */ + #[\ReturnTypeWillChange] protected function getToMarshall() { return $this->toMarshall; @@ -88,7 +89,7 @@ protected function getToMarshall() * * @param PhpMarshallingContext $context A PhpMarshallingContext object. */ - protected function setContext(PhpMarshallingContext $context) + protected function setContext(PhpMarshallingContext $context): void { $this->context = $context; } @@ -98,7 +99,7 @@ protected function setContext(PhpMarshallingContext $context) * * @return PhpMarshallingContext A PhpMarshallingContext object. */ - protected function getContext() + protected function getContext(): PhpMarshallingContext { return $this->context; } @@ -119,5 +120,5 @@ abstract public function marshall(); * @param mixed $toMarshall The value the current PhpMarshaller implementation has to deal with. * @return bool Whether or not the value $toMarshall can be marshalled or not by this implementation. */ - abstract protected function isMarshallable($toMarshall); + abstract protected function isMarshallable($toMarshall): bool; } diff --git a/src/qtism/data/storage/php/marshalling/PhpMarshallingContext.php b/src/qtism/data/storage/php/marshalling/PhpMarshallingContext.php index b67281e44..4a963ce44 100644 --- a/src/qtism/data/storage/php/marshalling/PhpMarshallingContext.php +++ b/src/qtism/data/storage/php/marshalling/PhpMarshallingContext.php @@ -95,7 +95,7 @@ public function __construct(PhpStreamAccess $streamAccess) * * @param array $objectCount */ - protected function setObjectCount(array $objectCount) + protected function setObjectCount(array $objectCount): void { $this->objectCount = $objectCount; } @@ -105,7 +105,7 @@ protected function setObjectCount(array $objectCount) * * @return array */ - protected function getObjectCount() + protected function getObjectCount(): array { return $this->objectCount; } @@ -115,7 +115,7 @@ protected function getObjectCount() * * @param array $datatypeCount */ - protected function setDatatypeCount(array $datatypeCount) + protected function setDatatypeCount(array $datatypeCount): void { $this->datatypeCount = $datatypeCount; } @@ -125,7 +125,7 @@ protected function setDatatypeCount(array $datatypeCount) * * @return array */ - protected function getDatatypeCount() + protected function getDatatypeCount(): array { return $this->datatypeCount; } @@ -135,7 +135,7 @@ protected function getDatatypeCount() * * @param SplStack $variableStack */ - protected function setVariableStack(SplStack $variableStack) + protected function setVariableStack(SplStack $variableStack): void { $this->variableStack = $variableStack; } @@ -145,7 +145,7 @@ protected function setVariableStack(SplStack $variableStack) * * @return SplStack */ - protected function getVariableStack() + protected function getVariableStack(): SplStack { return $this->variableStack; } @@ -155,7 +155,7 @@ protected function getVariableStack() * * @param bool $formatOutput */ - public function setFormatOutput($formatOutput) + public function setFormatOutput($formatOutput): void { $this->formatOutput = $formatOutput; } @@ -165,7 +165,7 @@ public function setFormatOutput($formatOutput) * * @return bool */ - public function mustFormatOutput() + public function mustFormatOutput(): bool { return $this->formatOutput; } @@ -175,7 +175,7 @@ public function mustFormatOutput() * * @param PhpStreamAccess $streamAccess An access to a PHP source code stream. */ - protected function setStreamAccess(PhpStreamAccess $streamAccess) + protected function setStreamAccess(PhpStreamAccess $streamAccess): void { $this->streamAccess = $streamAccess; } @@ -185,7 +185,7 @@ protected function setStreamAccess(PhpStreamAccess $streamAccess) * * @return PhpStreamAccess An access to a PHP source code stream. */ - public function getStreamAccess() + public function getStreamAccess(): PhpStreamAccess { return $this->streamAccess; } @@ -196,7 +196,7 @@ public function getStreamAccess() * @param string|array $values A string or an array of strings to be pushed on the variable names stack. * @throws InvalidArgumentException If $value or an item of $value is not a non-empty string. */ - public function pushOnVariableStack($values) + public function pushOnVariableStack($values): void { if (is_array($values) === false) { $values = [$values]; @@ -220,7 +220,7 @@ public function pushOnVariableStack($values) * @throws RuntimeException If the the quantity of elements in the stack before popping is less than $quantity. * @throws InvalidArgumentException If $quantity < 1. */ - public function popFromVariableStack($quantity = 1) + public function popFromVariableStack($quantity = 1): array { $quantity = (int)$quantity; if ($quantity < 1) { @@ -250,7 +250,7 @@ public function popFromVariableStack($quantity = 1) * @param mixed $value A value. * @return string A variable name without the leading dollar sign ('$'). */ - public function generateVariableName($value) + public function generateVariableName($value): string { $occurence = 0; diff --git a/src/qtism/data/storage/php/marshalling/PhpMarshallingException.php b/src/qtism/data/storage/php/marshalling/PhpMarshallingException.php index 490967fd6..25cde5666 100644 --- a/src/qtism/data/storage/php/marshalling/PhpMarshallingException.php +++ b/src/qtism/data/storage/php/marshalling/PhpMarshallingException.php @@ -36,7 +36,7 @@ class PhpMarshallingException extends Exception implements QtiSdkPackageContentE * * @var int */ - const UNKNOWN = 0; + public const UNKNOWN = 0; /** * Error code to use when a runtime error occurs @@ -44,7 +44,7 @@ class PhpMarshallingException extends Exception implements QtiSdkPackageContentE * * @var int */ - const RUNTIME = 1; + public const RUNTIME = 1; /** * Error code to use while dealing with the stream where @@ -52,7 +52,7 @@ class PhpMarshallingException extends Exception implements QtiSdkPackageContentE * * @var int */ - const STREAM = 2; + public const STREAM = 2; /** * Create a new PhpMarshallingException object. diff --git a/src/qtism/data/storage/php/marshalling/PhpQtiComponentMarshaller.php b/src/qtism/data/storage/php/marshalling/PhpQtiComponentMarshaller.php index bca4c301e..b54481e30 100644 --- a/src/qtism/data/storage/php/marshalling/PhpQtiComponentMarshaller.php +++ b/src/qtism/data/storage/php/marshalling/PhpQtiComponentMarshaller.php @@ -68,7 +68,7 @@ public function __construct(PhpMarshallingContext $context, $toMarshall) * * @param string $asInstanceOf */ - public function setAsInstanceOf($asInstanceOf) + public function setAsInstanceOf($asInstanceOf): void { $this->asInstanceOf = $asInstanceOf; } @@ -78,7 +78,7 @@ public function setAsInstanceOf($asInstanceOf) * * @return string */ - public function getAsInstanceOf() + public function getAsInstanceOf(): string { return $this->asInstanceOf; } @@ -88,7 +88,7 @@ public function getAsInstanceOf() * * @param string $variableName */ - public function setVariableName($variableName) + public function setVariableName($variableName): void { $this->variableName = $variableName; } @@ -98,12 +98,12 @@ public function setVariableName($variableName) * * @return string */ - public function getVariableName() + public function getVariableName(): string { return $this->variableName; } - public function marshall() + public function marshall(): void { $ctx = $this->getContext(); $access = $ctx->getStreamAccess(); @@ -161,7 +161,7 @@ public function marshall() * @param mixed $toMarshall * @return bool */ - protected function isMarshallable($toMarshall) + protected function isMarshallable($toMarshall): bool { return $toMarshall instanceof QtiComponent; } diff --git a/src/qtism/data/storage/php/marshalling/PhpQtiDatatypeMarshaller.php b/src/qtism/data/storage/php/marshalling/PhpQtiDatatypeMarshaller.php index 60d15c44f..487566f41 100644 --- a/src/qtism/data/storage/php/marshalling/PhpQtiDatatypeMarshaller.php +++ b/src/qtism/data/storage/php/marshalling/PhpQtiDatatypeMarshaller.php @@ -44,7 +44,7 @@ class PhpQtiDatatypeMarshaller extends PhpMarshaller * * @throws PhpMarshallingException If an error occurs during marshalling. */ - public function marshall() + public function marshall(): void { $toMarshall = $this->getToMarshall(); @@ -86,7 +86,7 @@ public function marshall() * @param mixed $toMarshall * @return bool. */ - protected function isMarshallable($toMarshall) + protected function isMarshallable($toMarshall): bool { return $toMarshall instanceof QtiDatatype; } @@ -96,7 +96,7 @@ protected function isMarshallable($toMarshall) * * @throws PhpMarshallingException */ - protected function marshallCoords() + protected function marshallCoords(): void { // Retrieve the coordinates array. $coords = $this->getToMarshall(); @@ -142,7 +142,7 @@ protected function marshallCoords() * * @throws PhpMarshallingException */ - protected function marshallPair() + protected function marshallPair(): void { $pair = $this->getToMarshall(); $ctx = $this->getContext(); @@ -168,7 +168,7 @@ protected function marshallPair() * * @throws PhpMarshallingException */ - protected function marshallDuration() + protected function marshallDuration(): void { $duration = $this->getToMarshall(); $ctx = $this->getContext(); @@ -194,7 +194,7 @@ protected function marshallDuration() * * @throws PhpMarshallingException */ - protected function marshallIdentifier() + protected function marshallIdentifier(): void { $identifier = $this->getToMarshall(); $ctx = $this->getContext(); @@ -220,7 +220,7 @@ protected function marshallIdentifier() * * @throws PhpMarshallingException */ - protected function marshallPoint() + protected function marshallPoint(): void { $point = $this->getToMarshall(); $ctx = $this->getContext(); diff --git a/src/qtism/data/storage/php/marshalling/PhpScalarMarshaller.php b/src/qtism/data/storage/php/marshalling/PhpScalarMarshaller.php index ebdf3ab50..9a3904356 100644 --- a/src/qtism/data/storage/php/marshalling/PhpScalarMarshaller.php +++ b/src/qtism/data/storage/php/marshalling/PhpScalarMarshaller.php @@ -51,7 +51,7 @@ public function __construct(PhpMarshallingContext $context, $toMarshall) * @param mixed $toMarshall * @return bool */ - protected function isMarshallable($toMarshall) + protected function isMarshallable($toMarshall): bool { return PhpUtils::isScalar($toMarshall); } @@ -61,7 +61,7 @@ protected function isMarshallable($toMarshall) * * @throws PhpMarshallingException If an error occurs while marshalling. */ - public function marshall() + public function marshall(): void { $ctx = $this->getContext(); $streamAccess = $ctx->getStreamAccess(); diff --git a/src/qtism/data/storage/php/marshalling/Utils.php b/src/qtism/data/storage/php/marshalling/Utils.php index 0f593bdd5..6576c450e 100644 --- a/src/qtism/data/storage/php/marshalling/Utils.php +++ b/src/qtism/data/storage/php/marshalling/Utils.php @@ -57,7 +57,7 @@ class Utils * @return string A variable name. * @throws InvalidArgumentException If $occurence is not a positive integer or if $value cannot be handled by this method. */ - public static function variableName($value, $occurence = 0) + public static function variableName($value, $occurence = 0): string { if (is_int($occurence) === false || $occurence < 0) { $msg = "The 'occurence' argument must be a positive integer (>= 0)."; diff --git a/src/qtism/data/storage/xml/LibXmlErrorCollection.php b/src/qtism/data/storage/xml/LibXmlErrorCollection.php index 00dfe4cad..80537d831 100644 --- a/src/qtism/data/storage/xml/LibXmlErrorCollection.php +++ b/src/qtism/data/storage/xml/LibXmlErrorCollection.php @@ -40,7 +40,7 @@ class LibXmlErrorCollection extends AbstractCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a LibXMLError object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof LibXMLError) { $msg = 'LibXmlErrorCollection class only accept LibXMLError objects.'; diff --git a/src/qtism/data/storage/xml/Utils.php b/src/qtism/data/storage/xml/Utils.php index 22f27dd7b..e62ac3284 100644 --- a/src/qtism/data/storage/xml/Utils.php +++ b/src/qtism/data/storage/xml/Utils.php @@ -80,7 +80,7 @@ public static function getXsdLocation(DOMDocument $document, $namespaceUri) * * @return DOMElement */ - public static function changeElementName(DOMElement $element, $name) + public static function changeElementName(DOMElement $element, $name): DOMElement { $newElement = $element->ownerDocument->createElement($name); @@ -112,7 +112,7 @@ public static function changeElementName(DOMElement $element, $name) * @param DOMElement $element The DOMElement to be anonimized. * @return DOMElement The anonimized DOMElement copy of $element. */ - public static function anonimizeElement(DOMElement $element) + public static function anonimizeElement(DOMElement $element): DOMElement { $stack = new SplStack(); $traversed = []; @@ -160,7 +160,7 @@ public static function anonimizeElement(DOMElement $element) * @param DOMElement $into The target DOMElement. * @param bool $deep Whether or not to import the whole node hierarchy. */ - public static function importChildNodes(DOMElement $from, DOMElement $into, $deep = true) + public static function importChildNodes(DOMElement $from, DOMElement $into, $deep = true): void { for ($i = 0; $i < $from->childNodes->length; $i++) { $node = $into->ownerDocument->importNode($from->childNodes->item($i), $deep); @@ -175,7 +175,7 @@ public static function importChildNodes(DOMElement $from, DOMElement $into, $dee * @param DOMElement $from The source DOMElement. * @param DOMElement $into The target DOMElement. */ - public static function importAttributes(DOMElement $from, DOMElement $into) + public static function importAttributes(DOMElement $from, DOMElement $into): void { for ($i = 0; $i < $from->attributes->length; $i++) { $attr = $from->attributes->item($i); @@ -205,7 +205,7 @@ public static function importAttributes(DOMElement $from, DOMElement $into) * @param bool $isAttribute Whether or not to escape ', >, < which do not have to be escaped in attributes. * @return string An escaped string. */ - public static function escapeXmlSpecialChars($string, $isAttribute = false) + public static function escapeXmlSpecialChars($string, $isAttribute = false): string { if ($isAttribute !== false) { return str_replace(['&', '"'], ['&', '"'], $string); @@ -227,7 +227,7 @@ public static function escapeXmlSpecialChars($string, $isAttribute = false) * @param string $qtiName * @return string */ - public static function webComponentFriendlyAttributeName($qtiName) + public static function webComponentFriendlyAttributeName($qtiName): string { return strtolower(preg_replace('/([A-Z])/', '-$1', $qtiName)); } @@ -242,7 +242,7 @@ public static function webComponentFriendlyAttributeName($qtiName) * @param string $qtiName * @return string */ - public static function webComponentFriendlyClassName($qtiName) + public static function webComponentFriendlyClassName($qtiName): string { return 'qti-' . self::webComponentFriendlyAttributeName($qtiName); } @@ -257,7 +257,7 @@ public static function webComponentFriendlyClassName($qtiName) * @param string $wcName * @return string */ - public static function qtiFriendlyName($wcName) + public static function qtiFriendlyName($wcName): string { $qtiName = strtolower($wcName); $qtiName = preg_replace('/^qti-/', '', $qtiName); @@ -274,6 +274,7 @@ public static function qtiFriendlyName($wcName) * @return mixed The attribute value with the provided $datatype, or null if the attribute does not exist in $element. * @throws InvalidArgumentException If $datatype is not in the range of possible values. */ + #[\ReturnTypeWillChange] public static function getDOMElementAttributeAs(DOMElement $element, string $attribute, $datatype = 'string') { $attr = $element->getAttribute($attribute); @@ -321,7 +322,7 @@ public static function getDOMElementAttributeAs(DOMElement $element, string $att * @param string $attribute An XML attribute name. * @param mixed $value A given value. */ - public static function setDOMElementAttribute(DOMElement $element, string $attribute, $value) + public static function setDOMElementAttribute(DOMElement $element, string $attribute, $value): void { $element->setAttribute($attribute, self::valueAsString($value, false)); } @@ -332,7 +333,7 @@ public static function setDOMElementAttribute(DOMElement $element, string $attri * @param DOMElement $element A DOMElement object. * @param mixed $value A given value. */ - public static function setDOMElementValue(DOMElement $element, $value) + public static function setDOMElementValue(DOMElement $element, $value): void { $element->nodeValue = self::valueAsString($value); } @@ -346,13 +347,13 @@ public static function setDOMElementValue(DOMElement $element, $value) * @param bool $encode * @return string */ - public static function valueAsString($value, $encode = true) + public static function valueAsString($value, $encode = true): string { if (is_bool($value)) { return $value === true ? 'true' : 'false'; } if ($encode) { - return htmlspecialchars($value, ENT_XML1, 'UTF-8'); + return htmlspecialchars((string)$value, ENT_XML1, 'UTF-8'); } return (string)$value; } @@ -368,7 +369,7 @@ public static function valueAsString($value, $encode = true) * @param bool $withText (optional) Whether text nodes must be returned or not. * @return array An array of DOMElement objects. */ - public static function getChildElementsByTagName($element, $tagName, $exclude = false, $withText = false) + public static function getChildElementsByTagName($element, $tagName, $exclude = false, $withText = false): array { if (!is_array($tagName)) { $tagName = [$tagName]; @@ -393,7 +394,7 @@ public static function getChildElementsByTagName($element, $tagName, $exclude = * @param bool $withText Whether text nodes must be returned or not. * @return array An array of DOMNode objects. */ - public static function getChildElements($element, $withText = false) + public static function getChildElements($element, $withText = false): array { $children = $element->childNodes; $returnValue = []; diff --git a/src/qtism/data/storage/xml/XmlCompactDocument.php b/src/qtism/data/storage/xml/XmlCompactDocument.php index 015df08e3..9719b0dbc 100644 --- a/src/qtism/data/storage/xml/XmlCompactDocument.php +++ b/src/qtism/data/storage/xml/XmlCompactDocument.php @@ -101,7 +101,7 @@ public function __construct($version = '2.1.0', QtiComponent $documentComponent * @param string $versionNumber A QTI Compact version number e.g. '2.1.0'. * @throws QtiVersionException when version is not supported for QTI Compact. */ - public function setVersion(string $versionNumber) + public function setVersion(string $versionNumber): void { $this->version = CompactVersion::create($versionNumber); } @@ -121,7 +121,7 @@ public function setVersion(string $versionNumber) * * @param bool $explodeRubricBlocks Whether rubrickBlock components must be exploded into multiple documents and replaced by rubricBlockRef components. */ - public function setExplodeRubricBlocks($explodeRubricBlocks) + public function setExplodeRubricBlocks($explodeRubricBlocks): void { $this->explodeRubricBlocks = $explodeRubricBlocks; } @@ -131,7 +131,7 @@ public function setExplodeRubricBlocks($explodeRubricBlocks) * * @return bool */ - public function mustExplodeRubricBlocks() + public function mustExplodeRubricBlocks(): bool { return $this->explodeRubricBlocks; } @@ -147,7 +147,7 @@ public function mustExplodeRubricBlocks() * * @param bool $explodeTestFeedbacks */ - public function setExplodeTestFeedbacks($explodeTestFeedbacks) + public function setExplodeTestFeedbacks($explodeTestFeedbacks): void { $this->explodeTestFeedbacks = $explodeTestFeedbacks; } @@ -157,7 +157,7 @@ public function setExplodeTestFeedbacks($explodeTestFeedbacks) * * @return bool */ - public function mustExplodeTestFeedbacks() + public function mustExplodeTestFeedbacks(): bool { return $this->explodeTestFeedbacks; } @@ -172,7 +172,7 @@ public function mustExplodeTestFeedbacks() * @throws XmlStorageException If an error occurs while transforming the XmlAssessmentTestDocument object into an XmlCompactAssessmentTestDocument object. * @throws ReflectionException */ - public static function createFromXmlAssessmentTestDocument(XmlDocument $xmlAssessmentTestDocument, FileResolver $resolver = null, $version = '2.1') + public static function createFromXmlAssessmentTestDocument(XmlDocument $xmlAssessmentTestDocument, FileResolver $resolver = null, $version = '2.1'): XmlCompactDocument { $compactAssessmentTest = new XmlCompactDocument($version); $compactAssessmentTest->setFilesystem($xmlAssessmentTestDocument->getFilesystem()); @@ -301,8 +301,11 @@ public static function createFromXmlAssessmentTestDocument(XmlDocument $xmlAsses * @param FileResolver $resolver The Resolver to be used to resolver AssessmentItemRef's href attribute. * @throws XmlStorageException If an error occurs (e.g. file not found at URI or unmarshalling issue) during the dereferencing. */ - protected static function resolveAssessmentItemRef(XmlDocument $sourceDocument, ExtendedAssessmentItemRef $compactAssessmentItemRef, FileResolver $resolver) - { + protected static function resolveAssessmentItemRef( + XmlDocument $sourceDocument, + ExtendedAssessmentItemRef $compactAssessmentItemRef, + FileResolver $resolver + ): void { try { $href = $resolver->resolve($compactAssessmentItemRef->getHref()); @@ -366,8 +369,11 @@ protected static function resolveAssessmentItemRef(XmlDocument $sourceDocument, * @throws XmlStorageException If an error occurs while dereferencing the referenced file. * @throws ReflectionException */ - protected static function resolveAssessmentSectionRef(XmlDocument $sourceDocument, AssessmentSectionRef $assessmentSectionRef, FileResolver $resolver) - { + protected static function resolveAssessmentSectionRef( + XmlDocument $sourceDocument, + AssessmentSectionRef $assessmentSectionRef, + FileResolver $resolver + ): XmlDocument { try { $href = $resolver->resolve($assessmentSectionRef->getHref()); @@ -389,7 +395,7 @@ protected static function resolveAssessmentSectionRef(XmlDocument $sourceDocumen * @throws XmlStorageException * @throws marshalling\MarshallingException */ - public function beforeSave(QtiComponent $documentComponent, $uri) + public function beforeSave(QtiComponent $documentComponent, $uri): void { // Take care of rubricBlock explosion. Transform actual rubricBlocks in rubricBlockRefs. if ($this->mustExplodeRubricBlocks() === true) { @@ -464,7 +470,7 @@ public function beforeSave(QtiComponent $documentComponent, $uri) * * @return array where keys are RubricBlockRefs href and values are RubricBlocs as QtiComponent objets. */ - public function explodeRubricBlocks() + public function explodeRubricBlocks(): array { // Get all rubricBlock elements... $iterator = new QtiComponentIterator($this->getDocumentComponent(), ['rubricBlock']); diff --git a/src/qtism/data/storage/xml/XmlDocument.php b/src/qtism/data/storage/xml/XmlDocument.php index e946606f4..88ddca155 100644 --- a/src/qtism/data/storage/xml/XmlDocument.php +++ b/src/qtism/data/storage/xml/XmlDocument.php @@ -91,7 +91,7 @@ public function __toString(): string * * @param SerializableDomDocument $domDocument A SerializableDomDocument object. */ - protected function setDomDocument(SerializableDomDocument $domDocument) + protected function setDomDocument(SerializableDomDocument $domDocument): void { $this->domDocument = $domDocument; } @@ -101,7 +101,7 @@ protected function setDomDocument(SerializableDomDocument $domDocument) * * @return DOMDocument */ - public function getDomDocument() + public function getDomDocument(): DOMDocument { return $this->domDocument->getDom(); } @@ -115,7 +115,7 @@ public function getDomDocument() * * @param Filesystem|FilesystemInterface|null $filesystem */ - public function setFilesystem($filesystem = null) + public function setFilesystem(FilesystemInterface $filesystem = null): void { if (!$filesystem) { $filesystem = FilesystemFactory::local(); @@ -144,7 +144,7 @@ public function setFilesystem($filesystem = null) * * @return FilesystemInterface|null */ - protected function getFilesystem(): FilesystemInterface + protected function getFilesystem(): ?FilesystemInterface { if ($this->filesystem === null) { $this->setFilesystem(); @@ -258,7 +258,7 @@ protected function unmarshallElement(DomElement $element): QtiComponent protected function loadXml($data): void { Utils::executeSafeXmlCommand( - function () use ($data) { + function () use ($data): void { $this->domDocument->loadXML($data, self::LIB_XML_FLAGS); }, 'An internal error occurred while parsing QTI-XML', @@ -275,7 +275,7 @@ function () use ($data) { public function schemaValidate(): void { Utils::executeSafeXmlCommand( - function () { + function (): void { $schema = realpath($this->version->getLocalXsd()); $this->domDocument->schemaValidate($schema); }, @@ -343,7 +343,7 @@ protected function assertComponentNotNull(): void * @param QtiComponent $documentComponent The root component of the model that will be saved. * @param string $uri The URI where the saved file is supposed to be stored. */ - protected function beforeSave(QtiComponent $documentComponent, $uri) + protected function beforeSave(QtiComponent $documentComponent, $uri): void { } @@ -354,7 +354,7 @@ protected function beforeSave(QtiComponent $documentComponent, $uri) * @return string * @throws XmlStorageException */ - protected function saveImplementation($formatOutput = true) + protected function saveImplementation($formatOutput = true): string { $element = $this->marshallElement($this->getDocumentComponent()); @@ -456,7 +456,7 @@ protected function saveToFile(string $url, string $content): bool * @throws XmlStorageException If an error occurred while parsing or validating files to be included. * @throws ReflectionException */ - public function xInclude($validate = false) + public function xInclude($validate = false): void { if (($root = $this->getDocumentComponent()) !== null) { $baseUri = str_replace('\\', '/', $this->getUrl()); @@ -517,7 +517,7 @@ public function xInclude($validate = false) * @throws LogicException If the method is called prior the load or loadFromString method was called. * @throws XmlStorageException If an error occurred while parsing or validating files to be included. */ - public function resolveTemplateLocation($validate = false) + public function resolveTemplateLocation($validate = false): void { if (($root = $this->getDocumentComponent()) !== null) { if ( @@ -564,7 +564,7 @@ public function resolveTemplateLocation($validate = false) * @throws LogicException If the method is called prior the load or loadFromString method was called. * @throws XmlStorageException If an error occurred while parsing or validating files to be included. */ - public function includeAssessmentSectionRefs($validate = false) + public function includeAssessmentSectionRefs($validate = false): void { if (($root = $this->getDocumentComponent()) !== null) { $baseUri = str_replace('\\', '/', $this->getUrl()); @@ -617,7 +617,7 @@ public function includeAssessmentSectionRefs($validate = false) * * @param string $toVersionNumber */ - public function changeVersion(string $toVersionNumber) + public function changeVersion(string $toVersionNumber): void { $this->setVersion($toVersionNumber); $this->setNamespaces($this->domDocument); diff --git a/src/qtism/data/storage/xml/XmlResultDocument.php b/src/qtism/data/storage/xml/XmlResultDocument.php index 97057673e..5705a3d10 100644 --- a/src/qtism/data/storage/xml/XmlResultDocument.php +++ b/src/qtism/data/storage/xml/XmlResultDocument.php @@ -38,7 +38,7 @@ class XmlResultDocument extends XmlDocument * @param string $versionNumber A QTI Result version number e.g. '2.1.0'. * @throws QtiVersionException when version is not supported for QTI Result. */ - public function setVersion(string $versionNumber) + public function setVersion(string $versionNumber): void { $this->version = ResultVersion::create($versionNumber); } diff --git a/src/qtism/data/storage/xml/XmlStorageException.php b/src/qtism/data/storage/xml/XmlStorageException.php index 3f214d443..a59a42c59 100644 --- a/src/qtism/data/storage/xml/XmlStorageException.php +++ b/src/qtism/data/storage/xml/XmlStorageException.php @@ -37,14 +37,14 @@ class XmlStorageException extends StorageException * * @var int */ - const RESOLUTION = 10; + public const RESOLUTION = 10; /** * The error is related to XSD validation. * * @var int */ - const XSD_VALIDATION = 11; + public const XSD_VALIDATION = 11; /** * An array containing libxml errors. @@ -105,7 +105,7 @@ public static function unsupportedComponentInVersion( * * @param LibXmlErrorCollection $errors A collection of LibXMLError objects. */ - protected function setErrors(LibXmlErrorCollection $errors = null) + protected function setErrors(LibXmlErrorCollection $errors = null): void { $this->errors = $errors; } @@ -115,7 +115,7 @@ protected function setErrors(LibXmlErrorCollection $errors = null) * * @return LibXmlErrorCollection A collection of LibXMLError objects. */ - public function getErrors() + public function getErrors(): LibXmlErrorCollection { return $this->errors; } diff --git a/src/qtism/data/storage/xml/marshalling/AnyNMarshaller.php b/src/qtism/data/storage/xml/marshalling/AnyNMarshaller.php index e4cb27d2e..281aaedf9 100644 --- a/src/qtism/data/storage/xml/marshalling/AnyNMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/AnyNMarshaller.php @@ -42,7 +42,7 @@ class AnyNMarshaller extends OperatorMarshaller * @param DOMElement[] $elements An array of child DOMEelement objects. * @return DOMElement The marshalled QTI anyN element. */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'min', $component->getMin()); @@ -63,7 +63,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @return QtiComponent An AnyN object. * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($min = $this->getDOMElementAttributeAs($element, 'min')) !== null) { if (Format::isInteger($min)) { diff --git a/src/qtism/data/storage/xml/marshalling/AreaMapEntryMarshaller.php b/src/qtism/data/storage/xml/marshalling/AreaMapEntryMarshaller.php index 2c607adcb..980be7238 100644 --- a/src/qtism/data/storage/xml/marshalling/AreaMapEntryMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/AreaMapEntryMarshaller.php @@ -41,7 +41,7 @@ class AreaMapEntryMarshaller extends Marshaller * @param QtiComponent $component An AreaMapEntry object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -56,10 +56,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI areaMapEntry element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An AreaMapEntry object. + * @return AreaMapEntry An AreaMapEntry object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): AreaMapEntry { if (($shape = $this->getDOMElementAttributeAs($element, 'shape')) !== null) { $shapeVal = QtiShape::getConstantByName($shape); @@ -100,7 +100,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'areaMapEntry'; } diff --git a/src/qtism/data/storage/xml/marshalling/AreaMappingMarshaller.php b/src/qtism/data/storage/xml/marshalling/AreaMappingMarshaller.php index a658eb6a0..9e5c4647e 100644 --- a/src/qtism/data/storage/xml/marshalling/AreaMappingMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/AreaMappingMarshaller.php @@ -41,7 +41,7 @@ class AreaMappingMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -68,10 +68,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI areaMapping element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An AreaMapping object. + * @return AreaMapping An AreaMapping object. * @throws MarshallerNotFoundException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): AreaMapping { $areaMapEntries = new AreaMapEntryCollection(); $areaMapEntryElts = $this->getChildElementsByTagName($element, 'areaMapEntry'); @@ -101,7 +101,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'areaMapping'; } diff --git a/src/qtism/data/storage/xml/marshalling/AssessmentItemMarshaller.php b/src/qtism/data/storage/xml/marshalling/AssessmentItemMarshaller.php index 837fbf726..d312268c9 100644 --- a/src/qtism/data/storage/xml/marshalling/AssessmentItemMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/AssessmentItemMarshaller.php @@ -45,7 +45,7 @@ class AssessmentItemMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -121,12 +121,12 @@ protected function marshall(QtiComponent $component) * a new one. * * @param DOMElement $element A DOMElement object. - * @param AssessmentItem $assessmentItem An optional AssessmentItem object to be decorated. - * @return QtiComponent An AssessmentItem object. + * @param AssessmentItem|null $assessmentItem An optional AssessmentItem object to be decorated. + * @return AssessmentItem An AssessmentItem object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element, AssessmentItem $assessmentItem = null) + protected function unmarshall(DOMElement $element, AssessmentItem $assessmentItem = null): AssessmentItem { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { if (($timeDependent = $this->getDOMElementAttributeAs($element, 'timeDependent', 'boolean')) !== null) { @@ -255,7 +255,7 @@ protected function unmarshall(DOMElement $element, AssessmentItem $assessmentIte /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'assessmentItem'; } diff --git a/src/qtism/data/storage/xml/marshalling/AssessmentItemRefMarshaller.php b/src/qtism/data/storage/xml/marshalling/AssessmentItemRefMarshaller.php index 9cf90baca..9887298a8 100644 --- a/src/qtism/data/storage/xml/marshalling/AssessmentItemRefMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/AssessmentItemRefMarshaller.php @@ -44,7 +44,7 @@ class AssessmentItemRefMarshaller extends SectionPartMarshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = parent::marshall($component); @@ -84,11 +84,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI assessmentItemRef element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An AssessmentItemRef object. + * @return AssessmentItemRef An AssessmentItemRef object. * @throws MarshallerNotFoundException * @throws UnmarshallingException If the mandatory attribute 'href' is missing. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): AssessmentItemRef { $baseComponent = parent::unmarshall($element); @@ -143,7 +143,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'assessmentItemRef'; } diff --git a/src/qtism/data/storage/xml/marshalling/AssessmentResultMarshaller.php b/src/qtism/data/storage/xml/marshalling/AssessmentResultMarshaller.php index 41985029b..407890e4c 100644 --- a/src/qtism/data/storage/xml/marshalling/AssessmentResultMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/AssessmentResultMarshaller.php @@ -45,7 +45,7 @@ class AssessmentResultMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -70,11 +70,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI sessionIdentifier element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A QtiComponent object. + * @return AssessmentResult A QtiComponent object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): AssessmentResult { try { /** @var Context $context */ @@ -121,7 +121,7 @@ protected function unmarshall(DOMElement $element) * * @return string A QTI class name or an empty string. */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'assessmentResult'; } diff --git a/src/qtism/data/storage/xml/marshalling/AssessmentSectionMarshaller.php b/src/qtism/data/storage/xml/marshalling/AssessmentSectionMarshaller.php index a39fdd5dd..2bddbf140 100644 --- a/src/qtism/data/storage/xml/marshalling/AssessmentSectionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/AssessmentSectionMarshaller.php @@ -45,8 +45,11 @@ class AssessmentSectionMarshaller extends RecursiveMarshaller * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children, AssessmentSection $assessmentSection = null) - { + protected function unmarshallChildrenKnown( + DOMElement $element, + QtiComponentCollection $children, + AssessmentSection $assessmentSection = null + ): QtiComponent { $baseMarshaller = new SectionPartMarshaller($this->getVersion()); $baseComponent = $baseMarshaller->unmarshall($element); @@ -125,7 +128,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $baseMarshaller = new SectionPartMarshaller($this->getVersion()); $element = $baseMarshaller->marshall($component); @@ -167,7 +170,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @param DOMNode $element * @return bool */ - protected function isElementFinal(DOMNode $element) + protected function isElementFinal(DOMNode $element): bool { return $element->localName != 'assessmentSection'; } @@ -176,7 +179,7 @@ protected function isElementFinal(DOMNode $element) * @param QtiComponent $component * @return bool */ - protected function isComponentFinal(QtiComponent $component) + protected function isComponentFinal(QtiComponent $component): bool { return !$component instanceof AssessmentSection; } @@ -185,7 +188,7 @@ protected function isComponentFinal(QtiComponent $component) * @param DOMElement $element * @return array */ - protected function getChildrenElements(DOMElement $element) + protected function getChildrenElements(DOMElement $element): array { if ($element->localName == 'assessmentSection') { $doc = $element->ownerDocument; @@ -193,7 +196,7 @@ protected function getChildrenElements(DOMElement $element) $nodeList = $xpath->query('assessmentSection | assessmentSectionRef | assessmentItemRef', $element); if ($nodeList->length == 0) { - $xpath->registerNamespace('qti', $doc->lookupNamespaceURI($doc->namespaceURI)); + $xpath->registerNamespace('qti', (string)$doc->lookupNamespaceURI($doc->namespaceURI)); $nodeList = $xpath->query('qti:assessmentSection | qti:assessmentSectionRef | qti:assessmentItemRef', $element); } @@ -213,7 +216,7 @@ protected function getChildrenElements(DOMElement $element) * @param QtiComponent $component * @return array */ - protected function getChildrenComponents(QtiComponent $component) + protected function getChildrenComponents(QtiComponent $component): array { if ($component instanceof AssessmentSection) { return $component->getSectionParts()->getArrayCopy(); @@ -226,7 +229,7 @@ protected function getChildrenComponents(QtiComponent $component) * @param DOMElement $currentNode * @return SectionPartCollection */ - protected function createCollection(DOMElement $currentNode) + protected function createCollection(DOMElement $currentNode): SectionPartCollection { return new SectionPartCollection(); } @@ -234,7 +237,7 @@ protected function createCollection(DOMElement $currentNode) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return ''; } diff --git a/src/qtism/data/storage/xml/marshalling/AssessmentSectionRefMarshaller.php b/src/qtism/data/storage/xml/marshalling/AssessmentSectionRefMarshaller.php index d05248f87..91cbb811b 100644 --- a/src/qtism/data/storage/xml/marshalling/AssessmentSectionRefMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/AssessmentSectionRefMarshaller.php @@ -40,7 +40,7 @@ class AssessmentSectionRefMarshaller extends SectionPartMarshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = parent::marshall($component); @@ -53,11 +53,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI assessmentSectionRef element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An AssessmentSectionRef object. + * @return AssessmentSectionRef An AssessmentSectionRef object. * @throws UnmarshallingException If the mandatory attribute 'href' is missing. * @throws MarshallerNotFoundException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): AssessmentSectionRef { $baseComponent = parent::unmarshall($element); @@ -80,7 +80,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'assessmentSectionRef'; } diff --git a/src/qtism/data/storage/xml/marshalling/AssessmentTestMarshaller.php b/src/qtism/data/storage/xml/marshalling/AssessmentTestMarshaller.php index 844544094..848190271 100644 --- a/src/qtism/data/storage/xml/marshalling/AssessmentTestMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/AssessmentTestMarshaller.php @@ -43,7 +43,7 @@ class AssessmentTestMarshaller extends SectionPartMarshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -96,12 +96,12 @@ protected function marshall(QtiComponent $component) * instead of creating a new AssessmentTest object. * * @param DOMElement $element A DOMElement object. - * @param AssessmentTest $assessmentTest An AssessmentTest object to decorate. - * @return QtiComponent An OutcomeProcessing object. + * @param AssessmentTest|null $assessmentTest An AssessmentTest object to decorate. + * @return AssessmentTest An OutcomeProcessing object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element, AssessmentTest $assessmentTest = null) + protected function unmarshall(DOMElement $element, AssessmentTest $assessmentTest = null): AssessmentTest { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { if (($title = $this->getDOMElementAttributeAs($element, 'title')) !== null) { @@ -188,7 +188,7 @@ protected function unmarshall(DOMElement $element, AssessmentTest $assessmentTes /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'assessmentTest'; } diff --git a/src/qtism/data/storage/xml/marshalling/AssociateInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/AssociateInteractionMarshaller.php index a4ccaf650..deba68907 100644 --- a/src/qtism/data/storage/xml/marshalling/AssociateInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/AssociateInteractionMarshaller.php @@ -41,7 +41,7 @@ class AssociateInteractionMarshaller extends ContentMarshaller * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { // responseIdentifier. if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { @@ -99,7 +99,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -142,7 +142,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/AssociationValidityConstraintMarshaller.php b/src/qtism/data/storage/xml/marshalling/AssociationValidityConstraintMarshaller.php index e65ffcdd0..e2e4353a3 100644 --- a/src/qtism/data/storage/xml/marshalling/AssociationValidityConstraintMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/AssociationValidityConstraintMarshaller.php @@ -39,7 +39,7 @@ class AssociationValidityConstraintMarshaller extends Marshaller * @param QtiComponent $component * @return DOMElement */ - public function marshall(QtiComponent $component) + public function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'identifier', $component->getIdentifier()); @@ -53,10 +53,10 @@ public function marshall(QtiComponent $component) * Unmarshall a DOMElement to its AssociationValidityConstraint data model representation. * * @param DOMElement $element - * @return QtiComponent An AssociationValidityConstraint object. + * @return AssociationValidityConstraint An AssociationValidityConstraint object. * @throws UnmarshallingException */ - public function unmarshall(DOMElement $element) + public function unmarshall(DOMElement $element): AssociationValidityConstraint { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { if (($minConstraint = $this->getDOMElementAttributeAs($element, 'minConstraint', 'integer')) !== null) { @@ -93,7 +93,7 @@ public function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'associationValidityConstraint'; } diff --git a/src/qtism/data/storage/xml/marshalling/AtomicBlockMarshaller.php b/src/qtism/data/storage/xml/marshalling/AtomicBlockMarshaller.php index 39b8c5cad..30bc21f4c 100644 --- a/src/qtism/data/storage/xml/marshalling/AtomicBlockMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/AtomicBlockMarshaller.php @@ -39,7 +39,7 @@ class AtomicBlockMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); $component = new $fqClass(); @@ -58,7 +58,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -75,7 +75,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\xhtml\\text"]; } diff --git a/src/qtism/data/storage/xml/marshalling/BaseValueMarshaller.php b/src/qtism/data/storage/xml/marshalling/BaseValueMarshaller.php index 420f88f91..a00ef17b9 100644 --- a/src/qtism/data/storage/xml/marshalling/BaseValueMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/BaseValueMarshaller.php @@ -40,7 +40,7 @@ class BaseValueMarshaller extends Marshaller * @param QtiComponent $component A BaseValue object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -54,10 +54,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI baseValue element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A BaseValue object. + * @return BaseValue A BaseValue object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): BaseValue { if (($baseType = $this->getDOMElementAttributeAs($element, 'baseType', 'string')) !== null) { $value = $element->nodeValue; @@ -78,7 +78,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'baseValue'; } diff --git a/src/qtism/data/storage/xml/marshalling/BlockquoteMarshaller.php b/src/qtism/data/storage/xml/marshalling/BlockquoteMarshaller.php index 96cd06c33..c7d49020f 100644 --- a/src/qtism/data/storage/xml/marshalling/BlockquoteMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/BlockquoteMarshaller.php @@ -40,7 +40,7 @@ class BlockquoteMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); $component = new $fqClass(); @@ -74,7 +74,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -95,7 +95,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\xhtml\\text"]; } diff --git a/src/qtism/data/storage/xml/marshalling/BrMarshaller.php b/src/qtism/data/storage/xml/marshalling/BrMarshaller.php index 6b05c6b0f..83dfeabf0 100644 --- a/src/qtism/data/storage/xml/marshalling/BrMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/BrMarshaller.php @@ -38,12 +38,12 @@ class BrMarshaller extends Marshaller * @param QtiComponent $component A Br object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); if ($component->hasXmlBase() === true) { - self::setXmlBase($element, $component->setXmlBase()); + self::setXmlBase($element, $component->getXmlBase()); } $this->fillElement($element, $component); @@ -55,10 +55,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an XHTML br element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Br object. + * @return Br A Br object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Br { $component = new Br(); @@ -74,7 +74,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'br'; } diff --git a/src/qtism/data/storage/xml/marshalling/BranchRuleMarshaller.php b/src/qtism/data/storage/xml/marshalling/BranchRuleMarshaller.php index 188e07ece..7802468c7 100644 --- a/src/qtism/data/storage/xml/marshalling/BranchRuleMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/BranchRuleMarshaller.php @@ -40,7 +40,7 @@ class BranchRuleMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getExpression()); @@ -54,11 +54,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI branchRule element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A BranchRule object. + * @return BranchRule A BranchRule object. * @throws MarshallerNotFoundException * @throws UnmarshallingException If the mandatory expression child element is missing from $element or if the 'target' element is missing. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): BranchRule { if (($target = $this->getDOMElementAttributeAs($element, 'target')) !== null) { $expressionElt = self::getFirstChildElement($element); @@ -79,7 +79,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'branchRule'; } diff --git a/src/qtism/data/storage/xml/marshalling/CandidateResponseMarshaller.php b/src/qtism/data/storage/xml/marshalling/CandidateResponseMarshaller.php index 8884ce7c4..79ac4e439 100644 --- a/src/qtism/data/storage/xml/marshalling/CandidateResponseMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/CandidateResponseMarshaller.php @@ -40,7 +40,7 @@ class CandidateResponseMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -59,10 +59,10 @@ protected function marshall(QtiComponent $component) /** * @param DOMElement $element - * @return QtiComponent|CandidateResponse + * @return CandidateResponse * @throws MarshallerNotFoundException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): CandidateResponse { $valuesElements = $this->getChildElementsByTagName($element, 'value'); if (!empty($valuesElements)) { @@ -83,7 +83,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'candidateResponse'; } diff --git a/src/qtism/data/storage/xml/marshalling/CaptionMarshaller.php b/src/qtism/data/storage/xml/marshalling/CaptionMarshaller.php index 0e72a6d89..075792d7e 100644 --- a/src/qtism/data/storage/xml/marshalling/CaptionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/CaptionMarshaller.php @@ -39,7 +39,7 @@ class CaptionMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); $component = new $fqClass(); @@ -59,7 +59,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -73,7 +73,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\xhtml\\tables"]; } diff --git a/src/qtism/data/storage/xml/marshalling/ChoiceInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/ChoiceInteractionMarshaller.php index 12cb02538..4181bde55 100644 --- a/src/qtism/data/storage/xml/marshalling/ChoiceInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ChoiceInteractionMarshaller.php @@ -44,7 +44,7 @@ class ChoiceInteractionMarshaller extends ContentMarshaller * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $version = $this->getVersion(); $expectedOrderInteractionClassName = ($this->isWebComponentFriendly() === true) ? 'qti-order-interaction' : 'orderInteraction'; @@ -133,7 +133,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $version = $this->getVersion(); $isOrderInteraction = $component instanceof OrderInteraction; @@ -188,7 +188,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/ColMarshaller.php b/src/qtism/data/storage/xml/marshalling/ColMarshaller.php index 4f44bc79c..d454261c3 100644 --- a/src/qtism/data/storage/xml/marshalling/ColMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ColMarshaller.php @@ -38,7 +38,7 @@ class ColMarshaller extends Marshaller * @param QtiComponent $component A Col object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -55,10 +55,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an XHTML col element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Col object. + * @return Col A Col object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Col { $component = new Col(); @@ -74,7 +74,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'col'; } diff --git a/src/qtism/data/storage/xml/marshalling/ColgroupMarshaller.php b/src/qtism/data/storage/xml/marshalling/ColgroupMarshaller.php index 6fb5cd460..cf24e1665 100644 --- a/src/qtism/data/storage/xml/marshalling/ColgroupMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ColgroupMarshaller.php @@ -41,7 +41,7 @@ class ColgroupMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'span', $component->getSpan()); @@ -60,11 +60,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an XHTML colgroup table element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Colgroup object. + * @return Colgroup A Colgroup object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Colgroup { $component = new Colgroup(); @@ -87,7 +87,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'colgroup'; } diff --git a/src/qtism/data/storage/xml/marshalling/ContentMarshaller.php b/src/qtism/data/storage/xml/marshalling/ContentMarshaller.php index ddf0e757e..0a7b1ed5f 100644 --- a/src/qtism/data/storage/xml/marshalling/ContentMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ContentMarshaller.php @@ -196,7 +196,7 @@ public function __construct($version) * @param DOMNode $element * @return bool */ - protected function isElementFinal(DOMNode $element) + protected function isElementFinal(DOMNode $element): bool { return $element instanceof DOMText || ($element instanceof DOMElement && in_array($element->localName, self::$finals)); } @@ -205,7 +205,7 @@ protected function isElementFinal(DOMNode $element) * @param QtiComponent $component * @return bool */ - protected function isComponentFinal(QtiComponent $component) + protected function isComponentFinal(QtiComponent $component): bool { return in_array($component->getQtiClassName(), self::$finals) || $component instanceof ExternalQtiComponent; } @@ -214,7 +214,7 @@ protected function isComponentFinal(QtiComponent $component) * @param DOMElement $currentNode * @return QtiComponentCollection */ - protected function createCollection(DOMElement $currentNode) + protected function createCollection(DOMElement $currentNode): QtiComponentCollection { return new QtiComponentCollection(); } @@ -223,7 +223,7 @@ protected function createCollection(DOMElement $currentNode) * @param QtiComponent $component * @return array */ - protected function getChildrenComponents(QtiComponent $component) + protected function getChildrenComponents(QtiComponent $component): array { if ($component instanceof SimpleInline) { return $component->getContent()->getArrayCopy(); @@ -320,7 +320,7 @@ protected function getChildrenComponents(QtiComponent $component) * @param DOMElement $element * @return array */ - protected function getChildrenElements(DOMElement $element) + protected function getChildrenElements(DOMElement $element): array { $simpleComposites = self::$simpleComposites; $localName = $element->localName; @@ -380,7 +380,7 @@ protected function getChildrenElements(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return ''; } @@ -395,7 +395,7 @@ abstract protected function setLookupClasses(); * * @return array */ - protected function getLookupClasses() + protected function getLookupClasses(): array { return $this->lookupClasses; } @@ -407,7 +407,7 @@ protected function getLookupClasses() * @return string A fully qualified class name. * @throws UnmarshallingException If no class can be found for $element. */ - protected function lookupClass(DOMElement $element) + protected function lookupClass(DOMElement $element): string { $localName = $element->localName; if ($this->isWebComponentFriendly() === true && preg_match('/^qti-/', $localName) === 1) { diff --git a/src/qtism/data/storage/xml/marshalling/ContextMarshaller.php b/src/qtism/data/storage/xml/marshalling/ContextMarshaller.php index 09d53f93c..982fb205f 100644 --- a/src/qtism/data/storage/xml/marshalling/ContextMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ContextMarshaller.php @@ -44,12 +44,12 @@ class ContextMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException If an error occurs during the marshalling process. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); if ($component->hasSourcedId()) { - $element->setAttribute('sourcedId', $component->getSourcedId()); + $element->setAttribute('sourcedId', (string)$component->getSourcedId()); } if ($component->hasSessionIdentifiers()) { @@ -71,7 +71,7 @@ protected function marshall(QtiComponent $component) * @return Context A QtiComponent object. * @throws MarshallerNotFoundException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Context { $sourcedId = $element->hasAttribute('sourcedId') ? new QtiIdentifier($element->getAttribute('sourcedId')) @@ -102,7 +102,7 @@ protected function unmarshall(DOMElement $element) * * @return string A QTI class name or an empty string. */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'context'; } diff --git a/src/qtism/data/storage/xml/marshalling/CorrectMarshaller.php b/src/qtism/data/storage/xml/marshalling/CorrectMarshaller.php index c6f1c8361..d2160e54d 100644 --- a/src/qtism/data/storage/xml/marshalling/CorrectMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/CorrectMarshaller.php @@ -38,7 +38,7 @@ class CorrectMarshaller extends Marshaller * @param QtiComponent $component A Correct object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -51,10 +51,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI correct element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Correct object. + * @return Correct A Correct object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Correct { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier', 'string')) !== null) { return new Correct($identifier); @@ -67,7 +67,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'correct'; } diff --git a/src/qtism/data/storage/xml/marshalling/CorrectResponseMarshaller.php b/src/qtism/data/storage/xml/marshalling/CorrectResponseMarshaller.php index 5135fc9d8..05b964432 100644 --- a/src/qtism/data/storage/xml/marshalling/CorrectResponseMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/CorrectResponseMarshaller.php @@ -45,7 +45,7 @@ class CorrectResponseMarshaller extends Marshaller /** * @param int $baseType */ - public function setBaseType($baseType = -1) + public function setBaseType($baseType = -1): void { if (in_array($baseType, BaseType::asArray()) || $baseType == -1) { $this->baseType = $baseType; @@ -60,7 +60,7 @@ public function setBaseType($baseType = -1) * * @return int */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -85,7 +85,7 @@ public function __construct($version, $baseType = -1) * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -108,11 +108,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI correctResponse element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A CorrectResponse object. + * @return CorrectResponse A CorrectResponse object. * @throws MarshallerNotFoundException * @throws UnmarshallingException If the DOMElement object cannot be unmarshalled in a valid CorrectResponse object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): CorrectResponse { $interpretation = $this->getDOMElementAttributeAs($element, 'interpretation', 'string'); $interpretation = (empty($interpretation)) ? '' : $interpretation; @@ -137,7 +137,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'correctResponse'; } diff --git a/src/qtism/data/storage/xml/marshalling/CustomInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/CustomInteractionMarshaller.php index 90fe42bdd..ee08ef68f 100644 --- a/src/qtism/data/storage/xml/marshalling/CustomInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/CustomInteractionMarshaller.php @@ -39,7 +39,7 @@ class CustomInteractionMarshaller extends Marshaller * @param QtiComponent $component A CustomInteraction object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->fillElement($element, $component); @@ -60,10 +60,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI customInteraction element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A CustomInteraction object. + * @return CustomInteraction A CustomInteraction object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): CustomInteraction { if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { $frag = $element->ownerDocument->createDocumentFragment(); @@ -81,7 +81,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'customInteraction'; } diff --git a/src/qtism/data/storage/xml/marshalling/DefaultValMarshaller.php b/src/qtism/data/storage/xml/marshalling/DefaultValMarshaller.php index c0c9fcedf..c15aa73e0 100644 --- a/src/qtism/data/storage/xml/marshalling/DefaultValMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/DefaultValMarshaller.php @@ -38,7 +38,7 @@ class DefaultValMarshaller extends Marshaller * @param QtiComponent $component A DefaultVal object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -51,10 +51,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI default element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A DefaultVal object. + * @return DefaultVal A DefaultVal object. * @throws UnmarshallingException If the mandatory attributes 'identifier' is missing. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): DefaultVal { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier', 'string')) !== null) { return new DefaultVal($identifier); @@ -67,7 +67,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'default'; } diff --git a/src/qtism/data/storage/xml/marshalling/DefaultValueMarshaller.php b/src/qtism/data/storage/xml/marshalling/DefaultValueMarshaller.php index be3581524..52fe04456 100644 --- a/src/qtism/data/storage/xml/marshalling/DefaultValueMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/DefaultValueMarshaller.php @@ -40,7 +40,7 @@ class DefaultValueMarshaller extends Marshaller /** * @param int $baseType */ - public function setBaseType($baseType = -1) + public function setBaseType($baseType = -1): void { if (in_array($baseType, BaseType::asArray()) || $baseType == -1) { $this->baseType = $baseType; @@ -53,7 +53,7 @@ public function setBaseType($baseType = -1) /** * @return int */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -78,7 +78,7 @@ public function __construct($version, $baseType = -1) * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -101,11 +101,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI defaultValue element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A DefaultValue object. + * @return DefaultValue A DefaultValue object. * @throws MarshallerNotFoundException * @throws UnmarshallingException If the DOMElement object cannot be unmarshalled in a valid DefaultValue object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): DefaultValue { $interpretation = $this->getDOMElementAttributeAs($element, 'interpretation', 'string'); $interpretation = (empty($interpretation)) ? '' : $interpretation; @@ -130,7 +130,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'defaultValue'; } diff --git a/src/qtism/data/storage/xml/marshalling/DivMarshaller.php b/src/qtism/data/storage/xml/marshalling/DivMarshaller.php index 6bc55bfcb..6e4426d8a 100644 --- a/src/qtism/data/storage/xml/marshalling/DivMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/DivMarshaller.php @@ -39,7 +39,7 @@ class DivMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); $component = new $fqClass(); @@ -59,7 +59,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -76,7 +76,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\xhtml\\text"]; } diff --git a/src/qtism/data/storage/xml/marshalling/DlElementMarshaller.php b/src/qtism/data/storage/xml/marshalling/DlElementMarshaller.php index b2dcd4c47..3277977d2 100644 --- a/src/qtism/data/storage/xml/marshalling/DlElementMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/DlElementMarshaller.php @@ -41,7 +41,7 @@ class DlElementMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); $component = new $fqClass(); @@ -58,7 +58,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -71,7 +71,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\xhtml\\lists"]; } diff --git a/src/qtism/data/storage/xml/marshalling/DlMarshaller.php b/src/qtism/data/storage/xml/marshalling/DlMarshaller.php index ec848ff3e..c6f633bcc 100644 --- a/src/qtism/data/storage/xml/marshalling/DlMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/DlMarshaller.php @@ -39,7 +39,7 @@ class DlMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); $component = new $fqClass(); @@ -59,7 +59,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -76,7 +76,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\xhtml\\lists"]; } diff --git a/src/qtism/data/storage/xml/marshalling/DrawingInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/DrawingInteractionMarshaller.php index b309dbf78..aab22d623 100644 --- a/src/qtism/data/storage/xml/marshalling/DrawingInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/DrawingInteractionMarshaller.php @@ -40,7 +40,7 @@ class DrawingInteractionMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->fillElement($element, $component); @@ -63,11 +63,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a DrawingInteraction element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A DrawingInteraction object. + * @return DrawingInteraction A DrawingInteraction object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): DrawingInteraction { if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { $objectElts = $this->getChildElementsByTagName($element, 'object'); @@ -104,7 +104,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'drawingInteraction'; } diff --git a/src/qtism/data/storage/xml/marshalling/EndAttemptInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/EndAttemptInteractionMarshaller.php index dbfb31f56..0f9b0187f 100644 --- a/src/qtism/data/storage/xml/marshalling/EndAttemptInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/EndAttemptInteractionMarshaller.php @@ -38,7 +38,7 @@ class EndAttemptInteractionMarshaller extends Marshaller * @param QtiComponent $component An EndAttemptInteraction object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->fillElement($element, $component); @@ -56,10 +56,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an endAttemptInteraction element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An EndAttemptInteraction object. + * @return EndAttemptInteraction An EndAttemptInteraction object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): EndAttemptInteraction { if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { if (($title = $this->getDOMElementAttributeAs($element, 'title')) === null) { @@ -86,7 +86,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'endAttemptInteraction'; } diff --git a/src/qtism/data/storage/xml/marshalling/EqualMarshaller.php b/src/qtism/data/storage/xml/marshalling/EqualMarshaller.php index bf8546185..39a449848 100644 --- a/src/qtism/data/storage/xml/marshalling/EqualMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/EqualMarshaller.php @@ -43,7 +43,7 @@ class EqualMarshaller extends OperatorMarshaller * @param array An array of child DOMEelement objects. * @return DOMElement The marshalled QTI equal element. */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'toleranceMode', ToleranceMode::getNameByConstant($component->getToleranceMode())); @@ -76,7 +76,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @return QtiComponent An Equal object. * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $object = new Equal($children); diff --git a/src/qtism/data/storage/xml/marshalling/EqualRoundedMarshaller.php b/src/qtism/data/storage/xml/marshalling/EqualRoundedMarshaller.php index 9c705ac5c..7bb24e75f 100644 --- a/src/qtism/data/storage/xml/marshalling/EqualRoundedMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/EqualRoundedMarshaller.php @@ -43,7 +43,7 @@ class EqualRoundedMarshaller extends OperatorMarshaller * @param array An array of child DOMEelement objects. * @return DOMElement The marshalled QTI equalRounded element. */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'roundingMode', RoundingMode::getNameByConstant($component->getRoundingMode())); @@ -64,7 +64,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @return QtiComponent An EqualRounded object. * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($figures = $this->getDOMElementAttributeAs($element, 'figures')) !== null) { if (Format::isInteger($figures)) { diff --git a/src/qtism/data/storage/xml/marshalling/ExitResponseMarshaller.php b/src/qtism/data/storage/xml/marshalling/ExitResponseMarshaller.php index 836c1ffae..1eb1ecc9b 100644 --- a/src/qtism/data/storage/xml/marshalling/ExitResponseMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ExitResponseMarshaller.php @@ -38,7 +38,7 @@ class ExitResponseMarshaller extends Marshaller * @param QtiComponent $component An ExitResponse object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { return $this->createElement($component); } @@ -47,9 +47,9 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI exitResponse element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An ExitResponse object. + * @return ExitResponse An ExitResponse object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): ExitResponse { return new ExitResponse(); } @@ -57,7 +57,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'exitResponse'; } diff --git a/src/qtism/data/storage/xml/marshalling/ExitTemplateMarshaller.php b/src/qtism/data/storage/xml/marshalling/ExitTemplateMarshaller.php index ef15b808c..05aa6c4ab 100644 --- a/src/qtism/data/storage/xml/marshalling/ExitTemplateMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ExitTemplateMarshaller.php @@ -38,7 +38,7 @@ class ExitTemplateMarshaller extends Marshaller * @param QtiComponent $component An ExitTemplate object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { return $this->createElement($component); } @@ -47,9 +47,9 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI exitTemplate element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An ExitTemplate object. + * @return ExitTemplate An ExitTemplate object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): ExitTemplate { return new ExitTemplate(); } @@ -57,7 +57,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'exitTemplate'; } diff --git a/src/qtism/data/storage/xml/marshalling/ExitTestMarshaller.php b/src/qtism/data/storage/xml/marshalling/ExitTestMarshaller.php index 2b473eab6..2fb61ecf2 100644 --- a/src/qtism/data/storage/xml/marshalling/ExitTestMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ExitTestMarshaller.php @@ -38,7 +38,7 @@ class ExitTestMarshaller extends Marshaller * @param QtiComponent $component An ExitTest object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { return $this->createElement($component); } @@ -47,9 +47,9 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI exitTest element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An ExitTest object. + * @return ExitTest An ExitTest object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): ExitTest { return new ExitTest(); } @@ -57,7 +57,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'exitTest'; } diff --git a/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentItemRefMarshaller.php b/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentItemRefMarshaller.php index 5e6f10986..e2314712d 100644 --- a/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentItemRefMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentItemRefMarshaller.php @@ -47,7 +47,7 @@ class ExtendedAssessmentItemRefMarshaller extends AssessmentItemRefMarshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = parent::marshall($component); @@ -121,7 +121,7 @@ protected function marshall(QtiComponent $component) * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): ExtendedAssessmentItemRef { $baseComponent = parent::unmarshall($element); $identifier = $baseComponent->getIdentifier(); diff --git a/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentSectionMarshaller.php b/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentSectionMarshaller.php index 937d25a0a..9341b989a 100644 --- a/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentSectionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentSectionMarshaller.php @@ -44,7 +44,7 @@ class ExtendedAssessmentSectionMarshaller extends AssessmentSectionMarshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = parent::marshallChildrenKnown($component, $elements); @@ -66,8 +66,11 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children, AssessmentSection $assessmentSection = null) - { + protected function unmarshallChildrenKnown( + DOMElement $element, + QtiComponentCollection $children, + AssessmentSection $assessmentSection = null + ): QtiComponent { $baseComponent = parent::unmarshallChildrenKnown($element, $children); $component = ExtendedAssessmentSection::createFromAssessmentSection($baseComponent); diff --git a/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentTestMarshaller.php b/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentTestMarshaller.php index 4467d29fd..20a17aa5f 100644 --- a/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentTestMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ExtendedAssessmentTestMarshaller.php @@ -40,7 +40,7 @@ class ExtendedAssessmentTestMarshaller extends AssessmentTestMarshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = parent::marshall($component); @@ -56,11 +56,11 @@ protected function marshall(QtiComponent $component) /** * @param DOMElement $element * @param AssessmentTest|null $assessmentTest - * @return ExtendedAssessmentTest|QtiComponent + * @return ExtendedAssessmentTest * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element, AssessmentTest $assessmentTest = null) + protected function unmarshall(DOMElement $element, AssessmentTest $assessmentTest = null): ExtendedAssessmentTest { $baseComponent = parent::unmarshall($element); $component = ExtendedAssessmentTest::createFromAssessmentTest($baseComponent); diff --git a/src/qtism/data/storage/xml/marshalling/ExtendedTestPartMarshaller.php b/src/qtism/data/storage/xml/marshalling/ExtendedTestPartMarshaller.php index 6ee6f495a..de7c328c0 100644 --- a/src/qtism/data/storage/xml/marshalling/ExtendedTestPartMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ExtendedTestPartMarshaller.php @@ -27,7 +27,6 @@ use qtism\data\ExtendedTestPart; use qtism\data\QtiComponent; use qtism\data\TestFeedbackRefCollection; -use qtism\data\TestPart; /** * Marshalling/Unmarshalling implementation for ExtendedTestPart. @@ -40,7 +39,7 @@ class ExtendedTestPartMarshaller extends TestPartMarshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = parent::marshall($component); @@ -55,11 +54,11 @@ protected function marshall(QtiComponent $component) /** * @param DOMElement $element - * @return ExtendedTestPart|TestPart + * @return ExtendedTestPart * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): ExtendedTestPart { $baseComponent = parent::unmarshall($element); $component = ExtendedTestPart::createFromTestPart($baseComponent); diff --git a/src/qtism/data/storage/xml/marshalling/FeedbackElementMarshaller.php b/src/qtism/data/storage/xml/marshalling/FeedbackElementMarshaller.php index a54a19de3..6bb13d435 100644 --- a/src/qtism/data/storage/xml/marshalling/FeedbackElementMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/FeedbackElementMarshaller.php @@ -43,7 +43,7 @@ class FeedbackElementMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); @@ -101,7 +101,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->fillElement($element, $component); @@ -120,7 +120,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content"]; } diff --git a/src/qtism/data/storage/xml/marshalling/FieldValueMarshaller.php b/src/qtism/data/storage/xml/marshalling/FieldValueMarshaller.php index 83ccfae2f..8af56daa2 100644 --- a/src/qtism/data/storage/xml/marshalling/FieldValueMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/FieldValueMarshaller.php @@ -41,7 +41,7 @@ class FieldValueMarshaller extends OperatorMarshaller * @param array An array of child DOMEelement objects. * @return DOMElement The marshalled QTI fieldValue element. */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'fieldIdentifier', $component->getFieldIdentifier()); @@ -61,7 +61,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @return QtiComponent An FieldValue object. * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($fieldIdentifier = $this->getDOMElementAttributeAs($element, 'fieldIdentifier')) !== null) { return new FieldValue($children, $fieldIdentifier); diff --git a/src/qtism/data/storage/xml/marshalling/GapChoiceMarshaller.php b/src/qtism/data/storage/xml/marshalling/GapChoiceMarshaller.php index 5761e46f9..6a26f0119 100644 --- a/src/qtism/data/storage/xml/marshalling/GapChoiceMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/GapChoiceMarshaller.php @@ -79,7 +79,7 @@ class GapChoiceMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $version = $this->getVersion(); $expectedGapImgName = ($this->isWebComponentFriendly()) ? 'qti-gap-img' : 'gapImg'; @@ -171,7 +171,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -219,7 +219,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/GapMarshaller.php b/src/qtism/data/storage/xml/marshalling/GapMarshaller.php index 123b5034d..77d5e71d7 100644 --- a/src/qtism/data/storage/xml/marshalling/GapMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/GapMarshaller.php @@ -41,7 +41,7 @@ class GapMarshaller extends Marshaller * @param QtiComponent $component A Gap object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -79,10 +79,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an XHTML gap element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Gap object. + * @return Gap A Gap object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Gap { $version = $this->getVersion(); if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { @@ -120,7 +120,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'gap'; } diff --git a/src/qtism/data/storage/xml/marshalling/GapMatchInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/GapMatchInteractionMarshaller.php index 72904f50e..25df95558 100644 --- a/src/qtism/data/storage/xml/marshalling/GapMatchInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/GapMatchInteractionMarshaller.php @@ -42,7 +42,7 @@ class GapMatchInteractionMarshaller extends ContentMarshaller * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { $gapChoiceElts = $this->getChildElementsByTagName($element, ['gapText', 'gapImg']); @@ -88,7 +88,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -118,7 +118,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/GraphicAssociateInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/GraphicAssociateInteractionMarshaller.php index ea0cd6e1c..d3ca81215 100644 --- a/src/qtism/data/storage/xml/marshalling/GraphicAssociateInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/GraphicAssociateInteractionMarshaller.php @@ -41,7 +41,7 @@ class GraphicAssociateInteractionMarshaller extends ContentMarshaller * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $version = $this->getVersion(); if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { @@ -100,7 +100,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -132,7 +132,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/GraphicGapMatchInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/GraphicGapMatchInteractionMarshaller.php index 0384b488e..03ffef61d 100644 --- a/src/qtism/data/storage/xml/marshalling/GraphicGapMatchInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/GraphicGapMatchInteractionMarshaller.php @@ -38,11 +38,11 @@ class GraphicGapMatchInteractionMarshaller extends Marshaller * Unmarshall a DOMElement object corresponding to a graphicGapMatchInteraction element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A GraphicGapMatchInteraction object. + * @return GraphicGapMatchInteraction A GraphicGapMatchInteraction object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): GraphicGapMatchInteraction { if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { $objectElts = $this->getChildElementsByTagName($element, 'object'); @@ -109,7 +109,7 @@ protected function unmarshall(DOMElement $element) * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->fillElement($element, $component); @@ -139,7 +139,7 @@ protected function marshall(QtiComponent $component) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'graphicGapMatchInteraction'; } diff --git a/src/qtism/data/storage/xml/marshalling/GraphicOrderInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/GraphicOrderInteractionMarshaller.php index ac641c84a..1592438f2 100644 --- a/src/qtism/data/storage/xml/marshalling/GraphicOrderInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/GraphicOrderInteractionMarshaller.php @@ -41,7 +41,7 @@ class GraphicOrderInteractionMarshaller extends ContentMarshaller * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $version = $this->getVersion(); if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { @@ -105,7 +105,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -139,7 +139,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/HotspotInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/HotspotInteractionMarshaller.php index f7b50cde4..4322a7af1 100644 --- a/src/qtism/data/storage/xml/marshalling/HotspotInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/HotspotInteractionMarshaller.php @@ -41,7 +41,7 @@ class HotspotInteractionMarshaller extends ContentMarshaller * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $version = $this->getVersion(); if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) === null) { @@ -106,7 +106,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -137,7 +137,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/HotspotMarshaller.php b/src/qtism/data/storage/xml/marshalling/HotspotMarshaller.php index cf3f621a0..ab382c564 100644 --- a/src/qtism/data/storage/xml/marshalling/HotspotMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/HotspotMarshaller.php @@ -46,7 +46,7 @@ class HotspotMarshaller extends Marshaller * @param QtiComponent $component A HotspotChoice/AssociableHotspot object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -96,10 +96,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a hotspotChoice/associableHotspot element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A HotspotChoice/AssociableHotspot object. + * @return HotspotChoice|AssociableHotspot A HotspotChoice/AssociableHotspot object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): QtiComponent { $version = $this->getVersion(); if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { @@ -181,7 +181,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return ''; } diff --git a/src/qtism/data/storage/xml/marshalling/HottextInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/HottextInteractionMarshaller.php index 2614e7955..fa82313c2 100644 --- a/src/qtism/data/storage/xml/marshalling/HottextInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/HottextInteractionMarshaller.php @@ -42,7 +42,7 @@ class HottextInteractionMarshaller extends ContentMarshaller * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $version = $this->getVersion(); @@ -97,7 +97,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -127,7 +127,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/HottextMarshaller.php b/src/qtism/data/storage/xml/marshalling/HottextMarshaller.php index bf13be83c..0ea8d9c21 100644 --- a/src/qtism/data/storage/xml/marshalling/HottextMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/HottextMarshaller.php @@ -40,7 +40,7 @@ class HottextMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { $fqClass = $this->lookupClass($element); @@ -77,7 +77,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->fillElement($element, $component); @@ -107,7 +107,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/HrMarshaller.php b/src/qtism/data/storage/xml/marshalling/HrMarshaller.php index 343043031..261ba0ab4 100644 --- a/src/qtism/data/storage/xml/marshalling/HrMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/HrMarshaller.php @@ -38,7 +38,7 @@ class HrMarshaller extends Marshaller * @param QtiComponent $component A Hr object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -55,10 +55,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an XHTML hr element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Hr object. + * @return Hr A Hr object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Hr { $component = new Hr(); @@ -74,7 +74,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'hr'; } diff --git a/src/qtism/data/storage/xml/marshalling/Html5ContentMarshaller.php b/src/qtism/data/storage/xml/marshalling/Html5ContentMarshaller.php index 1fd89a933..8c1c6085a 100644 --- a/src/qtism/data/storage/xml/marshalling/Html5ContentMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/Html5ContentMarshaller.php @@ -38,7 +38,7 @@ abstract class Html5ContentMarshaller extends ContentMarshaller use QtiNamespacePrefixTrait; use QtiHtml5AttributeTrait; - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return Version::compare($this->getVersion(), '2.2', '>=') ? static::getExpectedQtiClassName() : 'not_existing'; } @@ -51,7 +51,7 @@ abstract protected static function getContentCollectionClassName(); * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); $component = new $fqClass(); @@ -75,7 +75,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { /** @var Html5Element $component */ $element = $this->getNamespacedElement($component); @@ -93,7 +93,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = [ "qtism\\data\\content\\xhtml", diff --git a/src/qtism/data/storage/xml/marshalling/Html5ElementMarshaller.php b/src/qtism/data/storage/xml/marshalling/Html5ElementMarshaller.php index e8d59b10f..11e5b111b 100644 --- a/src/qtism/data/storage/xml/marshalling/Html5ElementMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/Html5ElementMarshaller.php @@ -63,7 +63,7 @@ protected function marshall(QtiComponent $component): DOMElement * @param DOMElement $element The DOMElement object from where the attribute values must be retrieved. * @throws UnmarshallingException If one of the attributes of $element is not valid. */ - protected function fillBodyElement(BodyElement $bodyElement, DOMElement $element) + protected function fillBodyElement(BodyElement $bodyElement, DOMElement $element): void { $this->fillBodyElementAttributes($bodyElement, $element); diff --git a/src/qtism/data/storage/xml/marshalling/Html5FigcaptionMarshaller.php b/src/qtism/data/storage/xml/marshalling/Html5FigcaptionMarshaller.php index 107f8b72e..b915674cb 100644 --- a/src/qtism/data/storage/xml/marshalling/Html5FigcaptionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/Html5FigcaptionMarshaller.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\storage\xml\marshalling; use DOMElement; @@ -31,7 +29,7 @@ class Html5FigcaptionMarshaller extends Html5ContentMarshaller { - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return Figcaption::QTI_CLASS_NAME_FIGCAPTION; } @@ -42,7 +40,7 @@ public function getExpectedQtiClassName() * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $component = parent::unmarshallChildrenKnown($element, $children); @@ -62,7 +60,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = parent::marshallChildrenKnown($component, $elements); diff --git a/src/qtism/data/storage/xml/marshalling/Html5FigureMarshaller.php b/src/qtism/data/storage/xml/marshalling/Html5FigureMarshaller.php index d4c9c87fd..8d2f890ea 100644 --- a/src/qtism/data/storage/xml/marshalling/Html5FigureMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/Html5FigureMarshaller.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\storage\xml\marshalling; use DOMElement; @@ -31,7 +29,7 @@ class Html5FigureMarshaller extends Html5ContentMarshaller { - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return Figure::QTI_CLASS_NAME_FIGURE; } @@ -43,7 +41,7 @@ public function getExpectedQtiClassName() * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $component = parent::unmarshallChildrenKnown($element, $children); @@ -63,7 +61,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = parent::marshallChildrenKnown($component, $elements); diff --git a/src/qtism/data/storage/xml/marshalling/Html5RbMarshaller.php b/src/qtism/data/storage/xml/marshalling/Html5RbMarshaller.php index c1e10b300..5d058a973 100644 --- a/src/qtism/data/storage/xml/marshalling/Html5RbMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/Html5RbMarshaller.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\storage\xml\marshalling; use DOMElement; @@ -30,7 +28,7 @@ class Html5RbMarshaller extends Html5ContentMarshaller { - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return Rb::QTI_CLASS_NAME; } @@ -41,7 +39,7 @@ public function getExpectedQtiClassName() * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $component = parent::unmarshallChildrenKnown($element, $children); @@ -61,7 +59,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = parent::marshallChildrenKnown($component, $elements); diff --git a/src/qtism/data/storage/xml/marshalling/Html5RpMarshaller.php b/src/qtism/data/storage/xml/marshalling/Html5RpMarshaller.php index 9bb6e80ec..ea04f70a0 100644 --- a/src/qtism/data/storage/xml/marshalling/Html5RpMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/Html5RpMarshaller.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\storage\xml\marshalling; use DOMElement; @@ -30,7 +28,7 @@ class Html5RpMarshaller extends Html5ContentMarshaller { - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return Rp::QTI_CLASS_NAME; } @@ -41,7 +39,7 @@ public function getExpectedQtiClassName() * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $component = parent::unmarshallChildrenKnown($element, $children); @@ -61,7 +59,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = parent::marshallChildrenKnown($component, $elements); diff --git a/src/qtism/data/storage/xml/marshalling/Html5RtMarshaller.php b/src/qtism/data/storage/xml/marshalling/Html5RtMarshaller.php index 19b124724..5726d645a 100644 --- a/src/qtism/data/storage/xml/marshalling/Html5RtMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/Html5RtMarshaller.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\storage\xml\marshalling; use DOMElement; @@ -30,7 +28,7 @@ class Html5RtMarshaller extends Html5ContentMarshaller { - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return Rt::QTI_CLASS_NAME; } @@ -41,7 +39,7 @@ public function getExpectedQtiClassName() * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $component = parent::unmarshallChildrenKnown($element, $children); @@ -61,7 +59,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = parent::marshallChildrenKnown($component, $elements); diff --git a/src/qtism/data/storage/xml/marshalling/Html5RubyMarshaller.php b/src/qtism/data/storage/xml/marshalling/Html5RubyMarshaller.php index 657aaa6f7..a5fb040ed 100644 --- a/src/qtism/data/storage/xml/marshalling/Html5RubyMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/Html5RubyMarshaller.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\storage\xml\marshalling; use DOMElement; @@ -30,7 +28,7 @@ class Html5RubyMarshaller extends Html5ContentMarshaller { - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return Ruby::QTI_CLASS_NAME; } @@ -42,7 +40,7 @@ public function getExpectedQtiClassName() * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $component = parent::unmarshallChildrenKnown($element, $children); @@ -62,7 +60,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = parent::marshallChildrenKnown($component, $elements); diff --git a/src/qtism/data/storage/xml/marshalling/ImgMarshaller.php b/src/qtism/data/storage/xml/marshalling/ImgMarshaller.php index c6b6c70ac..ffedf3a87 100644 --- a/src/qtism/data/storage/xml/marshalling/ImgMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ImgMarshaller.php @@ -38,7 +38,7 @@ class ImgMarshaller extends Marshaller * @param QtiComponent $component An Img object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { /** @var Img $component */ $element = $this->createElement($component); @@ -71,10 +71,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an XHTML img element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent n Img object. + * @return Img n Img object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Img { $src = $this->getDOMElementAttributeAs($element, 'src'); if ($src === null) { @@ -109,7 +109,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'img'; } diff --git a/src/qtism/data/storage/xml/marshalling/IndexMarshaller.php b/src/qtism/data/storage/xml/marshalling/IndexMarshaller.php index d67257794..544059146 100644 --- a/src/qtism/data/storage/xml/marshalling/IndexMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/IndexMarshaller.php @@ -42,7 +42,7 @@ class IndexMarshaller extends OperatorMarshaller * @param array An array of child DOMEelement objects. * @return DOMElement The marshalled QTI index element. */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'n', $component->getN()); @@ -62,7 +62,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @return QtiComponent An Index object. * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($n = $this->getDOMElementAttributeAs($element, 'n')) !== null) { if (Format::isInteger($n)) { diff --git a/src/qtism/data/storage/xml/marshalling/InfoControlMarshaller.php b/src/qtism/data/storage/xml/marshalling/InfoControlMarshaller.php index 56c6c0bcd..3aa3477e9 100644 --- a/src/qtism/data/storage/xml/marshalling/InfoControlMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/InfoControlMarshaller.php @@ -39,7 +39,7 @@ class InfoControlMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); $component = new $fqClass(); @@ -63,7 +63,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -81,7 +81,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content"]; } diff --git a/src/qtism/data/storage/xml/marshalling/InlineChoiceInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/InlineChoiceInteractionMarshaller.php index d7e0f05f6..28c0c9fc9 100644 --- a/src/qtism/data/storage/xml/marshalling/InlineChoiceInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/InlineChoiceInteractionMarshaller.php @@ -41,7 +41,7 @@ class InlineChoiceInteractionMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { $version = $this->getVersion(); @@ -89,7 +89,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -115,7 +115,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/InlineChoiceMarshaller.php b/src/qtism/data/storage/xml/marshalling/InlineChoiceMarshaller.php index 843f0258d..4d6c17f01 100644 --- a/src/qtism/data/storage/xml/marshalling/InlineChoiceMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/InlineChoiceMarshaller.php @@ -43,7 +43,7 @@ class InlineChoiceMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { $version = $this->getVersion(); @@ -94,7 +94,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -122,7 +122,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/InsideMarshaller.php b/src/qtism/data/storage/xml/marshalling/InsideMarshaller.php index 698debc88..323b4eb5d 100644 --- a/src/qtism/data/storage/xml/marshalling/InsideMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/InsideMarshaller.php @@ -43,7 +43,7 @@ class InsideMarshaller extends OperatorMarshaller * @param array An array of child DOMEelement objects. * @return DOMElement The marshalled QTI inside element. */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'shape', QtiShape::getNameByConstant($component->getShape())); @@ -64,7 +64,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @return QtiComponent An Inside object. * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($shape = $this->getDOMElementAttributeAs($element, 'shape')) !== null) { if (($coords = $this->getDOMElementAttributeAs($element, 'coords')) !== null) { diff --git a/src/qtism/data/storage/xml/marshalling/InterpolationTableEntryMarshaller.php b/src/qtism/data/storage/xml/marshalling/InterpolationTableEntryMarshaller.php index b0656d0d4..d2cfca354 100644 --- a/src/qtism/data/storage/xml/marshalling/InterpolationTableEntryMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/InterpolationTableEntryMarshaller.php @@ -43,7 +43,7 @@ class InterpolationTableEntryMarshaller extends Marshaller * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -55,7 +55,7 @@ public function getBaseType() * @param int $baseType A value from the BaseType enumeration. * @throws InvalidArgumentException If $baseType is not a value from the BaseType enumeration nor -1. */ - public function setBaseType($baseType = -1) + public function setBaseType($baseType = -1): void { if (in_array($baseType, BaseType::asArray()) || $baseType == -1) { $this->baseType = $baseType; @@ -83,7 +83,7 @@ public function __construct($version, $baseType = -1) * @param QtiComponent $component An InterpolationTableEntry object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -98,10 +98,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI InterpolationEntry element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An InterpolationTableEntry object. + * @return InterpolationTableEntry An InterpolationTableEntry object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): InterpolationTableEntry { if (($sourceValue = $this->getDOMElementAttributeAs($element, 'sourceValue', 'float')) !== null) { if (($targetValue = $this->getDOMElementAttributeAs($element, 'targetValue', 'string')) !== null) { @@ -122,7 +122,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'interpolationTableEntry'; } diff --git a/src/qtism/data/storage/xml/marshalling/InterpolationTableMarshaller.php b/src/qtism/data/storage/xml/marshalling/InterpolationTableMarshaller.php index 4f06ceeb3..f0b7ad091 100644 --- a/src/qtism/data/storage/xml/marshalling/InterpolationTableMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/InterpolationTableMarshaller.php @@ -66,7 +66,7 @@ public function __construct($version, $baseType = -1) * @param int $baseType A value from the BaseType enumeration. * @throws InvalidArgumentException If $baseType is not a value from the BaseType enumeration nor -1. */ - public function setBaseType($baseType) + public function setBaseType($baseType): void { if (in_array($baseType, BaseType::asArray(), true) || $baseType === -1) { $this->baseType = $baseType; @@ -83,7 +83,7 @@ public function setBaseType($baseType) * * @return int A value from the BaseType enumeration or -1 if no baseType found for the related variableDeclaration. */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -96,7 +96,7 @@ public function getBaseType() * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); foreach ($component->getInterpolationTableEntries() as $interpolationTableEntry) { @@ -115,11 +115,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI InterpolationTable element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An InterpolationTable object. + * @return InterpolationTable An InterpolationTable object. * @throws MarshallerNotFoundException * @throws UnmarshallingException If $element does not contain any interpolationTableEntry QTI elements. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): InterpolationTable { $interpolationTableEntryElements = $element->getElementsByTagName('interpolationTableEntry'); @@ -151,7 +151,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'interpolationTable'; } diff --git a/src/qtism/data/storage/xml/marshalling/ItemBodyMarshaller.php b/src/qtism/data/storage/xml/marshalling/ItemBodyMarshaller.php index ad9943bb1..38d807a6b 100644 --- a/src/qtism/data/storage/xml/marshalling/ItemBodyMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ItemBodyMarshaller.php @@ -39,7 +39,7 @@ class ItemBodyMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); $component = new $fqClass(); @@ -55,7 +55,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -68,7 +68,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content"]; } diff --git a/src/qtism/data/storage/xml/marshalling/ItemResultMarshaller.php b/src/qtism/data/storage/xml/marshalling/ItemResultMarshaller.php index 0ec6733c4..94c7ef6b3 100644 --- a/src/qtism/data/storage/xml/marshalling/ItemResultMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ItemResultMarshaller.php @@ -49,20 +49,20 @@ class ItemResultMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); - $element->setAttribute('identifier', $component->getIdentifier()); + $element->setAttribute('identifier', (string)$component->getIdentifier()); $element->setAttribute('datestamp', $component->getDatestamp()->format('c')); // ISO 8601 $element->setAttribute('sessionStatus', SessionStatus::getNameByConstant($component->getSessionStatus())); if ($component->hasSequenceIndex()) { - $element->setAttribute('sequenceIndex', $component->getSequenceIndex()); + $element->setAttribute('sequenceIndex', (string)$component->getSequenceIndex()); } if ($component->hasCandidateComment()) { $candidateCommentElement = self::getDOMCradle()->createElement('candidateComment'); - $candidateCommentElement->textContent = $component->getCandidateComment(); + $candidateCommentElement->textContent = (string)$component->getCandidateComment(); $element->appendChild($candidateCommentElement); } @@ -79,11 +79,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI sessionIdentifier element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A QtiComponent object. + * @return ItemResult A QtiComponent object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): ItemResult { if (!$element->hasAttribute('identifier')) { throw new UnmarshallingException('ItemResult element must have identifier attribute', $element); @@ -143,7 +143,7 @@ protected function unmarshall(DOMElement $element) * * @return string A QTI class name or an empty string. */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'itemResult'; } diff --git a/src/qtism/data/storage/xml/marshalling/ItemSessionControlMarshaller.php b/src/qtism/data/storage/xml/marshalling/ItemSessionControlMarshaller.php index bc065aa84..ce9ebb5ed 100644 --- a/src/qtism/data/storage/xml/marshalling/ItemSessionControlMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ItemSessionControlMarshaller.php @@ -36,7 +36,7 @@ class ItemSessionControlMarshaller extends Marshaller * @param QtiComponent $component * @return DOMElement */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -55,7 +55,7 @@ protected function marshall(QtiComponent $component) * @param DOMElement $element * @return ItemSessionControl */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): ItemSessionControl { $object = new ItemSessionControl(); @@ -93,7 +93,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'itemSessionControl'; } diff --git a/src/qtism/data/storage/xml/marshalling/ItemSubsetMarshaller.php b/src/qtism/data/storage/xml/marshalling/ItemSubsetMarshaller.php index e999865cd..7691ccbb6 100644 --- a/src/qtism/data/storage/xml/marshalling/ItemSubsetMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ItemSubsetMarshaller.php @@ -38,7 +38,7 @@ class ItemSubsetMarshaller extends Marshaller * @param QtiComponent $component * @return DOMElement */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -64,7 +64,7 @@ protected function marshall(QtiComponent $component) * @param DOMElement $element * @return ItemSubset */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): ItemSubset { $object = new ItemSubset(); @@ -88,7 +88,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'itemSubset'; } diff --git a/src/qtism/data/storage/xml/marshalling/LiMarshaller.php b/src/qtism/data/storage/xml/marshalling/LiMarshaller.php index 772e98295..ac8ee0f12 100644 --- a/src/qtism/data/storage/xml/marshalling/LiMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/LiMarshaller.php @@ -39,7 +39,7 @@ class LiMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); $component = new $fqClass(); @@ -55,7 +55,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -68,7 +68,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\xhtml\\lists"]; } diff --git a/src/qtism/data/storage/xml/marshalling/ListMarshaller.php b/src/qtism/data/storage/xml/marshalling/ListMarshaller.php index 8ad7ef9e5..ecb75660d 100644 --- a/src/qtism/data/storage/xml/marshalling/ListMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ListMarshaller.php @@ -39,7 +39,7 @@ class ListMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); $component = new $fqClass(); @@ -59,7 +59,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -76,7 +76,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\xhtml\\lists"]; } diff --git a/src/qtism/data/storage/xml/marshalling/LookupOutcomeValueMarshaller.php b/src/qtism/data/storage/xml/marshalling/LookupOutcomeValueMarshaller.php index 0e840b76e..0fab88cf3 100644 --- a/src/qtism/data/storage/xml/marshalling/LookupOutcomeValueMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/LookupOutcomeValueMarshaller.php @@ -40,7 +40,7 @@ class LookupOutcomeValueMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -56,11 +56,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI lookupOutcomeValue element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A LookupOutcomeValue object. + * @return LookupOutcomeValue A LookupOutcomeValue object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): LookupOutcomeValue { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { $expressionElt = self::getFirstChildElement($element); @@ -82,7 +82,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'lookupOutcomeValue'; } diff --git a/src/qtism/data/storage/xml/marshalling/MapEntryMarshaller.php b/src/qtism/data/storage/xml/marshalling/MapEntryMarshaller.php index b7c5de308..fcfa3761f 100644 --- a/src/qtism/data/storage/xml/marshalling/MapEntryMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/MapEntryMarshaller.php @@ -52,7 +52,7 @@ class MapEntryMarshaller extends Marshaller * @param int $baseType A baseType from the BaseType enumeration. * @throws InvalidArgumentException If $baseType is not a value from the BaseType enumeration. */ - protected function setBaseType($baseType) + protected function setBaseType($baseType): void { if (in_array($baseType, BaseType::asArray())) { $this->baseType = $baseType; @@ -68,7 +68,7 @@ protected function setBaseType($baseType) * * @return int A baseType from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -92,7 +92,7 @@ public function __construct($version, $baseType) * @param QtiComponent $component A MapEntry object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -110,10 +110,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI mapEntry element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A MapEntry object. + * @return MapEntry A MapEntry object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): MapEntry { try { $mapKey = $this->getDOMElementAttributeAs($element, 'mapKey'); @@ -140,7 +140,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'mapEntry'; } diff --git a/src/qtism/data/storage/xml/marshalling/MapResponseMarshaller.php b/src/qtism/data/storage/xml/marshalling/MapResponseMarshaller.php index 1e6703c2f..5f16d84c5 100644 --- a/src/qtism/data/storage/xml/marshalling/MapResponseMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/MapResponseMarshaller.php @@ -38,7 +38,7 @@ class MapResponseMarshaller extends Marshaller * @param QtiComponent $component A MapResponse object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -51,10 +51,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI mapResponse element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A MapResponse object. + * @return MapResponse A MapResponse object. * @throws UnmarshallingException If the mandatory attributes 'identifier' is missing. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): MapResponse { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier', 'string')) !== null) { return new MapResponse($identifier); @@ -67,7 +67,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'mapResponse'; } diff --git a/src/qtism/data/storage/xml/marshalling/MapResponsePointMarshaller.php b/src/qtism/data/storage/xml/marshalling/MapResponsePointMarshaller.php index 159d4f315..5d5eba838 100644 --- a/src/qtism/data/storage/xml/marshalling/MapResponsePointMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/MapResponsePointMarshaller.php @@ -38,7 +38,7 @@ class MapResponsePointMarshaller extends Marshaller * @param QtiComponent $component A MapResponsePoint object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -51,10 +51,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI mapResponsePoint element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A MapResponsePoint object. + * @return MapResponsePoint A MapResponsePoint object. * @throws UnmarshallingException If the mandatory attributes 'identifier' is missing. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): MapResponsePoint { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier', 'string')) !== null) { return new MapResponsePoint($identifier); @@ -67,7 +67,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'mapResponsePoint'; } diff --git a/src/qtism/data/storage/xml/marshalling/MappingMarshaller.php b/src/qtism/data/storage/xml/marshalling/MappingMarshaller.php index ce77925d9..8b158cc54 100644 --- a/src/qtism/data/storage/xml/marshalling/MappingMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/MappingMarshaller.php @@ -50,7 +50,7 @@ class MappingMarshaller extends Marshaller * @param int $baseType A baseType from the BaseType enumeration. * @throws InvalidArgumentException If $baseType is not a value from the BaseType enumeration. */ - protected function setBaseType($baseType) + protected function setBaseType($baseType): void { if (in_array($baseType, BaseType::asArray())) { $this->baseType = $baseType; @@ -66,7 +66,7 @@ protected function setBaseType($baseType) * * @return int A baseType from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -92,7 +92,7 @@ public function __construct($version, $baseType) * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -118,11 +118,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI mapping element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Mapping object. + * @return Mapping A Mapping object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Mapping { $mapEntriesElts = $this->getChildElementsByTagName($element, 'mapEntry'); $mapEntries = new MapEntryCollection(); @@ -157,7 +157,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'mapping'; } diff --git a/src/qtism/data/storage/xml/marshalling/Marshaller.php b/src/qtism/data/storage/xml/marshalling/Marshaller.php index d13469644..f30cf0a0b 100644 --- a/src/qtism/data/storage/xml/marshalling/Marshaller.php +++ b/src/qtism/data/storage/xml/marshalling/Marshaller.php @@ -25,6 +25,7 @@ use DOMDocument; use DOMElement; +use DOMNode; use InvalidArgumentException; use qtism\common\utils\Version; use qtism\data\content\BodyElement; @@ -255,7 +256,7 @@ public function __construct($version) * * @return DOMDocument A unique DOMDocument object. */ - protected static function getDOMCradle() + protected static function getDOMCradle(): DOMDocument { if (empty(self::$DOMCradle)) { self::$DOMCradle = new DOMDocument('1.0', 'UTF-8'); @@ -296,7 +297,7 @@ public function getMarshallerFactory(): MarshallerFactory * * @param string $version A QTI version number e.g. '2.1'. */ - protected function setVersion($version) + protected function setVersion($version): void { $this->version = $version; } @@ -306,7 +307,7 @@ protected function setVersion($version) * * @return string A QTI version number e.g. '2.1'. */ - public function getVersion() + public function getVersion(): string { return $this->version; } @@ -338,7 +339,7 @@ public function __call($method, $args) } } - protected function checkMarshallerImplementation($component) + protected function checkMarshallerImplementation($component): void { if (!$component instanceof QtiComponent || ($this->getExpectedQtiClassName() !== '' && $component->getQtiClassName() !== $this->getExpectedQtiClassName())) { $componentName = $this->getComponentName($component); @@ -346,7 +347,7 @@ protected function checkMarshallerImplementation($component) } } - protected function checkUnmarshallerImplementation($element) + protected function checkUnmarshallerImplementation($element): void { if (!$element instanceof DOMElement || ($this->getExpectedQtiClassName() !== '' && $element->localName !== $this->getExpectedQtiClassName())) { $nodeName = $this->getElementName($element); @@ -375,7 +376,7 @@ protected function checkUnmarshallerImplementation($element) * @param $attribute * @return string */ - protected function getAttributeName(DOMElement $element, $attribute) + protected function getAttributeName(DOMElement $element, $attribute): string { if ($this->isWebComponentFriendly() === true && strpos($element->localName, "qti-") === 0) { $qtiFriendlyClassName = XmlUtils::qtiFriendlyName($element->localName); @@ -397,6 +398,7 @@ protected function getAttributeName(DOMElement $element, $attribute) * @return mixed The attribute value with the provided $datatype, or null if the attribute does not exist in $element. * @throws InvalidArgumentException If $datatype is not in the range of possible values. */ + #[\ReturnTypeWillChange] public function getDOMElementAttributeAs(DOMElement $element, $attribute, $datatype = 'string') { return XmlUtils::getDOMElementAttributeAs($element, $this->getAttributeName($element, $attribute), $datatype); @@ -409,7 +411,7 @@ public function getDOMElementAttributeAs(DOMElement $element, $attribute, $datat * @param string $attribute An XML attribute name. * @param mixed $value A given value. */ - public function setDOMElementAttribute(DOMElement $element, $attribute, $value) + public function setDOMElementAttribute(DOMElement $element, $attribute, $value): void { XmlUtils::setDOMElementAttribute($element, $this->getAttributeName($element, $attribute), $value); } @@ -420,7 +422,7 @@ public function setDOMElementAttribute(DOMElement $element, $attribute, $value) * @param DOMElement $element A DOMElement object. * @param mixed $value A given value. */ - public static function setDOMElementValue(DOMElement $element, $value) + public static function setDOMElementValue(DOMElement $element, $value): void { XmlUtils::setDOMElementValue($element, $value); } @@ -453,7 +455,7 @@ public static function getFirstChildElement($element) * @param bool $withText Whether text nodes must be returned or not. * @return array An array of DOMNode objects. */ - public static function getChildElements($element, $withText = false) + public static function getChildElements($element, $withText = false): array { return XmlUtils::getChildElements($element, $withText); } @@ -469,7 +471,7 @@ public static function getChildElements($element, $withText = false) * @param bool $withText (optional) Whether text nodes must be returned or not. * @return array An array of DOMElement objects. */ - public function getChildElementsByTagName($element, $tagName, $exclude = false, $withText = false) + public function getChildElementsByTagName($element, $tagName, $exclude = false, $withText = false): array { if (!is_array($tagName)) { $tagName = [$tagName]; @@ -512,7 +514,7 @@ public static function getXmlBase(DOMElement $element) * @param DOMElement $element The $element you want to set a value for xml:base. * @param string $xmlBase The value to be set to the xml:base attribute of $element. */ - public static function setXmlBase(DOMElement $element, $xmlBase) + public static function setXmlBase(DOMElement $element, $xmlBase): void { $element->setAttributeNS('http://www.w3.org/XML/1998/namespace', 'base', $xmlBase); } @@ -521,7 +523,7 @@ public static function setXmlBase(DOMElement $element, $xmlBase) * @param BodyElement $bodyElement * @param DOMElement $element */ - protected function fillBodyElementFlowTo(BodyElement $bodyElement, DOMElement $element) + protected function fillBodyElementFlowTo(BodyElement $bodyElement, DOMElement $element): void { $scan = ['aria-flowto']; @@ -563,7 +565,7 @@ private function needsFlowsToFix(string $className): bool * @param DOMElement $element The DOMElement object from where the attribute values must be retrieved. * @throws UnmarshallingException If one of the attributes of $element is not valid. */ - protected function fillBodyElement(BodyElement $bodyElement, DOMElement $element) + protected function fillBodyElement(BodyElement $bodyElement, DOMElement $element): void { try { $bodyElement->setId($element->getAttribute('id')); @@ -641,7 +643,7 @@ protected function fillBodyElement(BodyElement $bodyElement, DOMElement $element * @param DOMElement $element * @param BodyElement $bodyElement */ - protected function fillElementFlowto(DOMElement $element, BodyElement $bodyElement) + protected function fillElementFlowto(DOMElement $element, BodyElement $bodyElement): void { if (($ariaFlowTo = $bodyElement->getAriaFlowTo()) !== '') { if ($this->needsFlowsToFix($element->localName)) { @@ -658,7 +660,7 @@ protected function fillElementFlowto(DOMElement $element, BodyElement $bodyEleme * @param DOMElement $element The element from where the attribute values will be * @param BodyElement $bodyElement The bodyElement to be fill. */ - protected function fillElement(DOMElement $element, BodyElement $bodyElement) + protected function fillElement(DOMElement $element, BodyElement $bodyElement): void { if (($id = $bodyElement->getId()) !== '') { $element->setAttribute('id', $id); @@ -744,7 +746,7 @@ protected function fillElement(DOMElement $element, BodyElement $bodyElement) * @param QtiComponent $component * @return DOMElement */ - protected function createElement(QtiComponent $component) + protected function createElement(QtiComponent $component): DOMElement { $localName = $component->getQtiClassName(); @@ -762,7 +764,7 @@ protected function createElement(QtiComponent $component) * * @return bool */ - protected function isWebComponentFriendly() + protected function isWebComponentFriendly(): bool { return $this->getMarshallerFactory()->isWebComponentFriendly(); } @@ -771,10 +773,10 @@ protected function isWebComponentFriendly() * Marshall a QtiComponent object into its QTI-XML equivalent. * * @param QtiComponent $component A QtiComponent object to marshall. - * @return DOMElement A DOMElement object. + * @return DOMNode A DOMElement object. * @throws MarshallingException|MarshallerNotFoundException If an error occurs during the marshalling process. */ - abstract protected function marshall(QtiComponent $component); + abstract protected function marshall(QtiComponent $component): DOMNode; /** * Unmarshall a DOMElement object into its QTI Data Model equivalent. @@ -783,7 +785,7 @@ abstract protected function marshall(QtiComponent $component); * @return QtiComponent A QtiComponent object. * @throws UnmarshallingException|MarshallerNotFoundException If an error occurs during the unmarshalling process. */ - abstract protected function unmarshall(DOMElement $element); + abstract protected function unmarshall(DOMElement $element): QtiComponent; /** * Get the class name/tag name of the QtiComponent/DOMElement which can be handled @@ -794,13 +796,13 @@ abstract protected function unmarshall(DOMElement $element); * * @return string A QTI class name or an empty string. */ - abstract public function getExpectedQtiClassName(); + abstract public function getExpectedQtiClassName(): string; /** * @param QtiComponent|string $component * @return string */ - private function getComponentName($component) + private function getComponentName($component): string { if ($component instanceof QtiComponent) { return $component->getQtiClassName(); @@ -812,7 +814,7 @@ private function getComponentName($component) * @param DOMElement|string $element * @return string */ - private function getElementName($element) + private function getElementName($element): string { if ($element instanceof DOMElement) { return $element->localName; diff --git a/src/qtism/data/storage/xml/marshalling/MarshallerFactory.php b/src/qtism/data/storage/xml/marshalling/MarshallerFactory.php index 81da816b8..72acbf9c3 100644 --- a/src/qtism/data/storage/xml/marshalling/MarshallerFactory.php +++ b/src/qtism/data/storage/xml/marshalling/MarshallerFactory.php @@ -301,7 +301,7 @@ public function __construct() * @param string $marshallerClassName A PHP marshaller class name (fully qualified). * @param string $ns */ - public function addMappingEntry($qtiClassName, $marshallerClassName, $ns = 'qtism') + public function addMappingEntry($qtiClassName, $marshallerClassName, $ns = 'qtism'): void { $this->mapping[$ns][$qtiClassName] = $marshallerClassName; } @@ -313,7 +313,7 @@ public function addMappingEntry($qtiClassName, $marshallerClassName, $ns = 'qtis * @param string $ns * @return bool Whether a mapping entry is defined. */ - public function hasMappingEntry($qtiClassName, $ns = 'qtism') + public function hasMappingEntry($qtiClassName, $ns = 'qtism'): bool { return isset($this->mapping[$ns][$qtiClassName]); } @@ -336,7 +336,7 @@ public function getMappingEntry($qtiClassName, $ns = 'qtism') * @param string $qtiClassName A QTI class name. * @param string $ns */ - public function removeMappingEntry($qtiClassName, $ns = 'qtism') + public function removeMappingEntry($qtiClassName, $ns = 'qtism'): void { unset($this->mapping[$ns][$qtiClassName]); } @@ -348,7 +348,7 @@ public function removeMappingEntry($qtiClassName, $ns = 'qtism') * * @param bool $webComponentFriendly */ - protected function setWebComponentFriendly($webComponentFriendly) + protected function setWebComponentFriendly($webComponentFriendly): void { $this->webComponentFriendly = $webComponentFriendly; } @@ -360,7 +360,7 @@ protected function setWebComponentFriendly($webComponentFriendly) * * @return bool */ - public function isWebComponentFriendly() + public function isWebComponentFriendly(): bool { return $this->webComponentFriendly; } @@ -380,7 +380,7 @@ public function isWebComponentFriendly() * @throws MarshallerNotFoundException If no Marshaller mapping is set for a given $object. * @throws InvalidArgumentException If $object is not a QtiComponent nor a DOMElement object. */ - public function createMarshaller($object, array $args = []) + public function createMarshaller($object, array $args = []): Marshaller { if ($object instanceof QtiComponent) { // Asking for a Marshaller... @@ -428,5 +428,6 @@ public function createMarshaller($object, array $args = []) * @param array $args * @return mixed */ + #[\ReturnTypeWillChange] abstract protected function instantiateMarshaller(ReflectionClass $class, array $args); } diff --git a/src/qtism/data/storage/xml/marshalling/MarshallerNotFoundException.php b/src/qtism/data/storage/xml/marshalling/MarshallerNotFoundException.php index 097625794..407663da7 100644 --- a/src/qtism/data/storage/xml/marshalling/MarshallerNotFoundException.php +++ b/src/qtism/data/storage/xml/marshalling/MarshallerNotFoundException.php @@ -55,7 +55,7 @@ public function __construct($message, $qtiClassName, Exception $previous = null) * * @return string */ - public function getQtiClassName() + public function getQtiClassName(): string { return $this->qtiClassName; } @@ -65,7 +65,7 @@ public function getQtiClassName() * * @param string $qtiClassName */ - protected function setQtiClassName($qtiClassName) + protected function setQtiClassName($qtiClassName): void { $this->qtiClassName = $qtiClassName; } diff --git a/src/qtism/data/storage/xml/marshalling/MarshallingException.php b/src/qtism/data/storage/xml/marshalling/MarshallingException.php index 3448b8cdc..5e8603e00 100644 --- a/src/qtism/data/storage/xml/marshalling/MarshallingException.php +++ b/src/qtism/data/storage/xml/marshalling/MarshallingException.php @@ -58,7 +58,7 @@ public function __construct($message, QtiComponent $component, $previous = null) * * @return QtiComponent A QtiComponent object. */ - public function getComponent() + public function getComponent(): QtiComponent { return $this->component; } @@ -68,7 +68,7 @@ public function getComponent() * * @param QtiComponent $component A QTI Component object. */ - protected function setComponent(QtiComponent $component) + protected function setComponent(QtiComponent $component): void { $this->component = $component; } diff --git a/src/qtism/data/storage/xml/marshalling/MatchInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/MatchInteractionMarshaller.php index 347dc47be..f80b58cf3 100644 --- a/src/qtism/data/storage/xml/marshalling/MatchInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/MatchInteractionMarshaller.php @@ -42,7 +42,7 @@ class MatchInteractionMarshaller extends ContentMarshaller * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $version = $this->getVersion(); @@ -107,7 +107,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -148,7 +148,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/MatchTableEntryMarshaller.php b/src/qtism/data/storage/xml/marshalling/MatchTableEntryMarshaller.php index b6b14cdce..750bbbcf9 100644 --- a/src/qtism/data/storage/xml/marshalling/MatchTableEntryMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/MatchTableEntryMarshaller.php @@ -51,7 +51,7 @@ class MatchTableEntryMarshaller extends Marshaller * * @return int A value from the BaseType enumeration. */ - protected function getBaseType() + protected function getBaseType(): int { return $this->baseType; } @@ -62,7 +62,7 @@ protected function getBaseType() * @param int $baseType A value from the BaseType enumeration. * @throws InvalidArgumentException If $baseType is not a value from the BaseType enumeration. */ - protected function setBaseType($baseType) + protected function setBaseType($baseType): void { if (in_array($baseType, BaseType::asArray())) { $this->baseType = $baseType; @@ -93,7 +93,7 @@ public function __construct($version, $baseType) * @param QtiComponent $component A MatchTableEntry object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -107,10 +107,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI MatchTableEntry element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A MatchTableEntry object. + * @return MatchTableEntry A MatchTableEntry object. * @throws UnmarshallingException If the mandatory attributes 'sourceValue' or 'targetValue' are missing from $element. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): MatchTableEntry { if (($sourceValue = $this->getDOMElementAttributeAs($element, 'sourceValue', 'integer')) !== null) { if (($targetValue = $this->getDOMElementAttributeAs($element, 'targetValue', 'string')) !== null) { @@ -128,7 +128,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'matchTableEntry'; } diff --git a/src/qtism/data/storage/xml/marshalling/MatchTableMarshaller.php b/src/qtism/data/storage/xml/marshalling/MatchTableMarshaller.php index 1df2ad5e4..3e589146b 100644 --- a/src/qtism/data/storage/xml/marshalling/MatchTableMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/MatchTableMarshaller.php @@ -50,7 +50,7 @@ class MatchTableMarshaller extends Marshaller * * @return int */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -62,7 +62,7 @@ public function getBaseType() * @param int $baseType A value from the BaseType enumeration or -1 to state there is no particular baseType. * @throws InvalidArgumentException If $baseType is not a value from the BaseType enumeration nor -1. */ - public function setBaseType($baseType) + public function setBaseType($baseType): void { if (in_array($baseType, BaseType::asArray()) || $baseType == -1) { $this->baseType = $baseType; @@ -93,7 +93,7 @@ public function __construct($version, $baseType = -1) * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -113,11 +113,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI MatchTable element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A MatchTable object. + * @return MatchTable A MatchTable object. * @throws MarshallerNotFoundException * @throws UnmarshallingException If the $element to unmarshall has no matchTableEntry children. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): MatchTable { $matchTableEntryElements = $element->getElementsByTagName('matchTableEntry'); if ($matchTableEntryElements->length > 0) { @@ -151,7 +151,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'matchTable'; } diff --git a/src/qtism/data/storage/xml/marshalling/MathConstantMarshaller.php b/src/qtism/data/storage/xml/marshalling/MathConstantMarshaller.php index ffee9d4eb..bf12a13a7 100644 --- a/src/qtism/data/storage/xml/marshalling/MathConstantMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/MathConstantMarshaller.php @@ -39,7 +39,7 @@ class MathConstantMarshaller extends Marshaller * @param QtiComponent $component A MathConstant object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -52,10 +52,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI mathConstant element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A MathConstant object. + * @return MathConstant A MathConstant object. * @throws UnmarshallingException If the mandatory attribute 'name' is missing. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): MathConstant { if (($name = $this->getDOMElementAttributeAs($element, 'name')) !== null) { if (($cst = MathEnumeration::getConstantByName($name)) !== false) { @@ -73,7 +73,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'mathConstant'; } diff --git a/src/qtism/data/storage/xml/marshalling/MathMarshaller.php b/src/qtism/data/storage/xml/marshalling/MathMarshaller.php index 38dc232b5..048fd5064 100644 --- a/src/qtism/data/storage/xml/marshalling/MathMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/MathMarshaller.php @@ -38,7 +38,7 @@ class MathMarshaller extends Marshaller * @param QtiComponent $component A Math object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { return self::getDOMCradle()->importNode($component->getXml()->documentElement, true); } @@ -47,9 +47,9 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a math element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Math object. + * @return Math A Math object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Math { $node = $element->cloneNode(true); @@ -59,7 +59,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'math'; } diff --git a/src/qtism/data/storage/xml/marshalling/MathOperatorMarshaller.php b/src/qtism/data/storage/xml/marshalling/MathOperatorMarshaller.php index 6770c7d0b..497a152de 100644 --- a/src/qtism/data/storage/xml/marshalling/MathOperatorMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/MathOperatorMarshaller.php @@ -42,7 +42,7 @@ class MathOperatorMarshaller extends OperatorMarshaller * @param array An array of child DOMEelement objects. * @return DOMElement The marshalled QTI mathOperator element. */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -63,7 +63,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @return QtiComponent A MathOperator object. * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($name = $this->getDOMElementAttributeAs($element, 'name')) !== null) { return new MathOperator($children, MathFunctions::getConstantByName($name)); diff --git a/src/qtism/data/storage/xml/marshalling/MediaInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/MediaInteractionMarshaller.php index 57f0f5286..e806d5f4b 100644 --- a/src/qtism/data/storage/xml/marshalling/MediaInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/MediaInteractionMarshaller.php @@ -40,7 +40,7 @@ class MediaInteractionMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->fillElement($element, $component); @@ -76,11 +76,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a MediaInteraction element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A MediaInteraction object. + * @return MediaInteraction A MediaInteraction object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): MediaInteraction { if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { if (($autostart = $this->getDOMElementAttributeAs($element, 'autostart', 'boolean')) !== null) { @@ -134,7 +134,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'mediaInteraction'; } diff --git a/src/qtism/data/storage/xml/marshalling/ModalFeedbackMarshaller.php b/src/qtism/data/storage/xml/marshalling/ModalFeedbackMarshaller.php index d9bd7038b..5ced8db3e 100644 --- a/src/qtism/data/storage/xml/marshalling/ModalFeedbackMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ModalFeedbackMarshaller.php @@ -41,7 +41,7 @@ class ModalFeedbackMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); @@ -89,7 +89,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'outcomeIdentifier', $component->getOutcomeIdentifier()); @@ -107,7 +107,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content"]; } diff --git a/src/qtism/data/storage/xml/marshalling/ModalFeedbackRuleMarshaller.php b/src/qtism/data/storage/xml/marshalling/ModalFeedbackRuleMarshaller.php index c30709b70..513208878 100644 --- a/src/qtism/data/storage/xml/marshalling/ModalFeedbackRuleMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ModalFeedbackRuleMarshaller.php @@ -39,7 +39,7 @@ class ModalFeedbackRuleMarshaller extends Marshaller * @param QtiComponent $component * @return DOMElement */ - public function marshall(QtiComponent $component) + public function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'outcomeIdentifier', $component->getOutcomeIdentifier()); @@ -57,10 +57,10 @@ public function marshall(QtiComponent $component) * Unmarshall a DOMElement to its ModalFeedbackRule data model representation. * * @param DOMElement $element - * @return QtiComponent A ModalFeedbackRule object. + * @return ModalFeedbackRule A ModalFeedbackRule object. * @throws UnmarshallingException If the 'identifier', 'outcomeIdentifier', 'showHide', or attribute is missing from the XML definition. */ - public function unmarshall(DOMElement $element) + public function unmarshall(DOMElement $element): ModalFeedbackRule { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { if (($outcomeIdentifier = $this->getDOMElementAttributeAs($element, 'outcomeIdentifier')) !== null) { @@ -90,7 +90,7 @@ public function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'modalFeedbackRule'; } diff --git a/src/qtism/data/storage/xml/marshalling/NullValueMarshaller.php b/src/qtism/data/storage/xml/marshalling/NullValueMarshaller.php index 27939f56d..bb3351159 100644 --- a/src/qtism/data/storage/xml/marshalling/NullValueMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/NullValueMarshaller.php @@ -38,7 +38,7 @@ class NullValueMarshaller extends Marshaller * @param QtiComponent $component A NullValue object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { return $this->createElement($component); } @@ -47,9 +47,9 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI null element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A NullValue object. + * @return NullValue A NullValue object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): NullValue { return new NullValue(); } @@ -57,7 +57,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'null'; } diff --git a/src/qtism/data/storage/xml/marshalling/NumberCorrectMarshaller.php b/src/qtism/data/storage/xml/marshalling/NumberCorrectMarshaller.php index ef906b6c6..5a5736d66 100644 --- a/src/qtism/data/storage/xml/marshalling/NumberCorrectMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/NumberCorrectMarshaller.php @@ -38,7 +38,7 @@ class NumberCorrectMarshaller extends ItemSubsetMarshaller * @param QtiComponent $component A NumberCorrect object. * @return DOMElement The corresponding numberCorrect QTI element. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { return parent::marshall($component); } @@ -47,9 +47,9 @@ protected function marshall(QtiComponent $component) * Marshall an numberCorrect QTI element in its NumberCorrect object equivalent. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent The corresponding NumberCorrect object. + * @return NumberCorrect The corresponding NumberCorrect object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): NumberCorrect { $baseComponent = parent::unmarshall($element); @@ -65,7 +65,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'numberCorrect'; } diff --git a/src/qtism/data/storage/xml/marshalling/NumberIncorrectMarshaller.php b/src/qtism/data/storage/xml/marshalling/NumberIncorrectMarshaller.php index 160e5a6c2..e8e3c7615 100644 --- a/src/qtism/data/storage/xml/marshalling/NumberIncorrectMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/NumberIncorrectMarshaller.php @@ -38,7 +38,7 @@ class NumberIncorrectMarshaller extends ItemSubsetMarshaller * @param QtiComponent $component A NumberIncorrect object. * @return DOMElement The corresponding numberIncorrect QTI element. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { return parent::marshall($component); } @@ -47,9 +47,9 @@ protected function marshall(QtiComponent $component) * Marshall an numberIncorrect QTI element in its NumberIncorrect object equivalent. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent The corresponding NumberIncorrect object. + * @return NumberIncorrect The corresponding NumberIncorrect object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): NumberIncorrect { $baseComponent = parent::unmarshall($element); $object = new NumberIncorrect(); @@ -63,7 +63,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'numberIncorrect'; } diff --git a/src/qtism/data/storage/xml/marshalling/NumberPresentedMarshaller.php b/src/qtism/data/storage/xml/marshalling/NumberPresentedMarshaller.php index b561789d7..78eaed7d3 100644 --- a/src/qtism/data/storage/xml/marshalling/NumberPresentedMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/NumberPresentedMarshaller.php @@ -38,7 +38,7 @@ class NumberPresentedMarshaller extends ItemSubsetMarshaller * @param QtiComponent $component A NumberPresented object. * @return DOMElement The corresponding numberPresented QTI element. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { return parent::marshall($component); } @@ -47,9 +47,9 @@ protected function marshall(QtiComponent $component) * Marshall an numberPresented QTI element in its NumberPresented object equivalent. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent The corresponding NumberPresented object. + * @return NumberPresented The corresponding NumberPresented object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): NumberPresented { $baseComponent = parent::unmarshall($element); $object = new NumberPresented(); @@ -63,7 +63,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'numberPresented'; } diff --git a/src/qtism/data/storage/xml/marshalling/NumberRespondedMarshaller.php b/src/qtism/data/storage/xml/marshalling/NumberRespondedMarshaller.php index eb937dfbf..45771343b 100644 --- a/src/qtism/data/storage/xml/marshalling/NumberRespondedMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/NumberRespondedMarshaller.php @@ -38,7 +38,7 @@ class NumberRespondedMarshaller extends ItemSubsetMarshaller * @param QtiComponent $component A NumberResponded object. * @return DOMElement The corresponding numberResponded QTI element. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { return parent::marshall($component); } @@ -47,9 +47,9 @@ protected function marshall(QtiComponent $component) * Marshall an numberResponded QTI element in its NumberResponded object equivalent. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent The corresponding NumberResponded object. + * @return NumberResponded The corresponding NumberResponded object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): NumberResponded { $baseComponent = parent::unmarshall($element); $object = new NumberResponded(); @@ -63,7 +63,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'numberResponded'; } diff --git a/src/qtism/data/storage/xml/marshalling/NumberSelectedMarshaller.php b/src/qtism/data/storage/xml/marshalling/NumberSelectedMarshaller.php index 40b56c397..d2ba4ec70 100644 --- a/src/qtism/data/storage/xml/marshalling/NumberSelectedMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/NumberSelectedMarshaller.php @@ -38,7 +38,7 @@ class NumberSelectedMarshaller extends ItemSubsetMarshaller * @param QtiComponent $component A NumberSelected object. * @return DOMElement The corresponding numberSelected QTI element. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { return parent::marshall($component); } @@ -47,9 +47,9 @@ protected function marshall(QtiComponent $component) * Marshall an numberSelected QTI element in its NumberSelected object equivalent. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent The corresponding NumberSelected object. + * @return NumberSelected The corresponding NumberSelected object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): NumberSelected { $baseComponent = parent::unmarshall($element); $object = new NumberSelected(); @@ -63,7 +63,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'numberSelected'; } diff --git a/src/qtism/data/storage/xml/marshalling/ObjectMarshaller.php b/src/qtism/data/storage/xml/marshalling/ObjectMarshaller.php index dfa06635a..7bc763960 100644 --- a/src/qtism/data/storage/xml/marshalling/ObjectMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ObjectMarshaller.php @@ -40,7 +40,7 @@ class ObjectMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { // At item authoring time, we could admit that an empty data attribute // may occur. @@ -73,7 +73,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { /** @var ObjectElement $component */ $element = $this->createElement($component); @@ -101,7 +101,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\xhtml"]; } diff --git a/src/qtism/data/storage/xml/marshalling/OperatorMarshaller.php b/src/qtism/data/storage/xml/marshalling/OperatorMarshaller.php index c988908e6..d5ba8c4bc 100644 --- a/src/qtism/data/storage/xml/marshalling/OperatorMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/OperatorMarshaller.php @@ -120,7 +120,7 @@ class OperatorMarshaller extends RecursiveMarshaller * * @return array An array of string. */ - public static function getOperators() + public static function getOperators(): array { return self::$operators; } @@ -130,7 +130,7 @@ public static function getOperators() * * @return array An array of string. */ - public static function getExpressions() + public static function getExpressions(): array { return self::$expressions; } @@ -141,7 +141,7 @@ public static function getExpressions() * @return mixed * @throws ReflectionException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { // Some exceptions applies on instanciation e.g. the And operator is named // AndOperator because of PHP reserved words restriction. @@ -188,7 +188,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); foreach ($elements as $elt) { @@ -225,7 +225,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @param DOMNode $element * @return bool */ - protected function isElementFinal(DOMNode $element) + protected function isElementFinal(DOMNode $element): bool { return !in_array($element->localName, static::getOperators()); } @@ -234,7 +234,7 @@ protected function isElementFinal(DOMNode $element) * @param QtiComponent $component * @return bool */ - protected function isComponentFinal(QtiComponent $component) + protected function isComponentFinal(QtiComponent $component): bool { return !$component instanceof Operator; } @@ -243,7 +243,7 @@ protected function isComponentFinal(QtiComponent $component) * @param DOMElement $element * @return array */ - protected function getChildrenElements(DOMElement $element) + protected function getChildrenElements(DOMElement $element): array { return $this->getChildElementsByTagName($element, array_merge(self::getOperators(), self::getExpressions())); } @@ -252,7 +252,7 @@ protected function getChildrenElements(DOMElement $element) * @param QtiComponent $component * @return array */ - protected function getChildrenComponents(QtiComponent $component) + protected function getChildrenComponents(QtiComponent $component): array { if ($component instanceof Operator) { return $component->getExpressions()->getArrayCopy(); @@ -265,7 +265,7 @@ protected function getChildrenComponents(QtiComponent $component) * @param DOMElement $currentNode * @return ExpressionCollection */ - protected function createCollection(DOMElement $currentNode) + protected function createCollection(DOMElement $currentNode): ExpressionCollection { return new ExpressionCollection(); } @@ -273,7 +273,7 @@ protected function createCollection(DOMElement $currentNode) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return ''; } diff --git a/src/qtism/data/storage/xml/marshalling/OrderingMarshaller.php b/src/qtism/data/storage/xml/marshalling/OrderingMarshaller.php index 1a131de49..bfc701b20 100644 --- a/src/qtism/data/storage/xml/marshalling/OrderingMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/OrderingMarshaller.php @@ -38,7 +38,7 @@ class OrderingMarshaller extends Marshaller * @param QtiComponent $component An Ordering object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -51,9 +51,9 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI Ordering element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An Ordering object. + * @return Ordering An Ordering object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Ordering { $object = new Ordering(); @@ -67,7 +67,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'ordering'; } diff --git a/src/qtism/data/storage/xml/marshalling/OutcomeConditionMarshaller.php b/src/qtism/data/storage/xml/marshalling/OutcomeConditionMarshaller.php index b2412c9e3..534a47a2b 100644 --- a/src/qtism/data/storage/xml/marshalling/OutcomeConditionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/OutcomeConditionMarshaller.php @@ -45,7 +45,7 @@ class OutcomeConditionMarshaller extends RecursiveMarshaller * @return OutcomeCondition * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): OutcomeCondition { if (count($children) > 0) { // The first element of $children must be an outcomeIf. @@ -83,7 +83,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -98,7 +98,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @param DOMNode $element * @return bool */ - protected function isElementFinal(DOMNode $element) + protected function isElementFinal(DOMNode $element): bool { $exclusion = ['outcomeIf', 'outcomeElseIf', 'outcomeElse', 'outcomeCondition']; @@ -109,7 +109,7 @@ protected function isElementFinal(DOMNode $element) * @param QtiComponent $component * @return bool */ - protected function isComponentFinal(QtiComponent $component) + protected function isComponentFinal(QtiComponent $component): bool { return (!$component instanceof OutcomeIf && !$component instanceof OutcomeElseIf && @@ -121,7 +121,7 @@ protected function isComponentFinal(QtiComponent $component) * @param DOMElement $element * @return array */ - protected function getChildrenElements(DOMElement $element) + protected function getChildrenElements(DOMElement $element): array { return $this->getChildElementsByTagName($element, [ 'outcomeIf', @@ -138,7 +138,7 @@ protected function getChildrenElements(DOMElement $element) * @param QtiComponent $component * @return array */ - protected function getChildrenComponents(QtiComponent $component) + protected function getChildrenComponents(QtiComponent $component): array { if ($component instanceof OutcomeIf || $component instanceof OutcomeElseIf || $component instanceof OutcomeElse) { // OutcomeControl @@ -163,7 +163,7 @@ protected function getChildrenComponents(QtiComponent $component) * @param DOMElement $currentNode * @return QtiComponentCollection|OutcomeRuleCollection */ - protected function createCollection(DOMElement $currentNode) + protected function createCollection(DOMElement $currentNode): QtiComponentCollection { if ($currentNode->localName != 'outcomeCondition') { return new OutcomeRuleCollection(); @@ -175,7 +175,7 @@ protected function createCollection(DOMElement $currentNode) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return ''; } diff --git a/src/qtism/data/storage/xml/marshalling/OutcomeControlMarshaller.php b/src/qtism/data/storage/xml/marshalling/OutcomeControlMarshaller.php index e057e4bef..c91eaf3a3 100644 --- a/src/qtism/data/storage/xml/marshalling/OutcomeControlMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/OutcomeControlMarshaller.php @@ -52,7 +52,7 @@ class OutcomeControlMarshaller extends RecursiveMarshaller * @throws UnmarshallingException * @throws ReflectionException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $expressionElts = $this->getChildElementsByTagName($element, Expression::getExpressionClassNames()); @@ -84,7 +84,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -104,7 +104,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @param DOMNode $element * @return bool */ - protected function isElementFinal(DOMNode $element) + protected function isElementFinal(DOMNode $element): bool { return in_array($element->localName, array_merge([ 'exitTest', @@ -117,7 +117,7 @@ protected function isElementFinal(DOMNode $element) * @param QtiComponent $component * @return bool */ - protected function isComponentFinal(QtiComponent $component) + protected function isComponentFinal(QtiComponent $component): bool { return ($component instanceof ExitTest || $component instanceof LookupOutcomeValue || @@ -128,7 +128,7 @@ protected function isComponentFinal(QtiComponent $component) * @param DOMElement $element * @return array */ - protected function getChildrenElements(DOMElement $element) + protected function getChildrenElements(DOMElement $element): array { return $this->getChildElementsByTagName($element, [ 'exitTest', @@ -142,7 +142,7 @@ protected function getChildrenElements(DOMElement $element) * @param QtiComponent $component * @return array */ - protected function getChildrenComponents(QtiComponent $component) + protected function getChildrenComponents(QtiComponent $component): array { return $component->getOutcomeRules()->getArrayCopy(); } @@ -151,7 +151,7 @@ protected function getChildrenComponents(QtiComponent $component) * @param DOMElement $currentNode * @return OutcomeRuleCollection */ - protected function createCollection(DOMElement $currentNode) + protected function createCollection(DOMElement $currentNode): OutcomeRuleCollection { return new OutcomeRuleCollection(); } @@ -159,7 +159,7 @@ protected function createCollection(DOMElement $currentNode) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return ''; } diff --git a/src/qtism/data/storage/xml/marshalling/OutcomeDeclarationMarshaller.php b/src/qtism/data/storage/xml/marshalling/OutcomeDeclarationMarshaller.php index e9e9b1a35..380a3cb52 100644 --- a/src/qtism/data/storage/xml/marshalling/OutcomeDeclarationMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/OutcomeDeclarationMarshaller.php @@ -45,7 +45,7 @@ class OutcomeDeclarationMarshaller extends VariableDeclarationMarshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = parent::marshall($component); $version = $this->getVersion(); @@ -106,11 +106,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI outcomeDeclaration element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An OutcomeDeclaration object. + * @return OutcomeDeclaration An OutcomeDeclaration object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): OutcomeDeclaration { try { $version = $this->getVersion(); @@ -192,7 +192,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'outcomeDeclaration'; } diff --git a/src/qtism/data/storage/xml/marshalling/OutcomeMaximumMarshaller.php b/src/qtism/data/storage/xml/marshalling/OutcomeMaximumMarshaller.php index 502893641..8399f6149 100644 --- a/src/qtism/data/storage/xml/marshalling/OutcomeMaximumMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/OutcomeMaximumMarshaller.php @@ -38,7 +38,7 @@ class OutcomeMaximumMarshaller extends ItemSubsetMarshaller * @param QtiComponent $component A OutcomeMaximum object. * @return DOMElement The corresponding outcomeMaximum QTI element. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = parent::marshall($component); $this->setDOMElementAttribute($element, 'outcomeIdentifier', $component->getOutcomeIdentifier()); @@ -55,10 +55,10 @@ protected function marshall(QtiComponent $component) * Marshall an outcomeMaximum QTI element in its OutcomeMaximum object equivalent. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent The corresponding OutcomeMaximum object. + * @return OutcomeMaximum The corresponding OutcomeMaximum object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): OutcomeMaximum { $baseComponent = parent::unmarshall($element); @@ -82,7 +82,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'outcomeMaximum'; } diff --git a/src/qtism/data/storage/xml/marshalling/OutcomeMinimumMarshaller.php b/src/qtism/data/storage/xml/marshalling/OutcomeMinimumMarshaller.php index 2f85c8f57..bee000f12 100644 --- a/src/qtism/data/storage/xml/marshalling/OutcomeMinimumMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/OutcomeMinimumMarshaller.php @@ -38,7 +38,7 @@ class OutcomeMinimumMarshaller extends ItemSubsetMarshaller * @param QtiComponent $component A OutcomeMinimum object. * @return DOMElement The corresponding outcomeMinimum QTI element. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = parent::marshall($component); $this->setDOMElementAttribute($element, 'outcomeIdentifier', $component->getOutcomeIdentifier()); @@ -55,10 +55,10 @@ protected function marshall(QtiComponent $component) * Marshall a outcomeMinimum QTI element in its OutcomeMinimum object equivalent. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent The corresponding OutcomeMinimum object. + * @return OutcomeMinimum The corresponding OutcomeMinimum object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): OutcomeMinimum { $baseComponent = parent::unmarshall($element); @@ -82,7 +82,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'outcomeMinimum'; } diff --git a/src/qtism/data/storage/xml/marshalling/OutcomeProcessingMarshaller.php b/src/qtism/data/storage/xml/marshalling/OutcomeProcessingMarshaller.php index 0ebc116db..74b1aac0a 100644 --- a/src/qtism/data/storage/xml/marshalling/OutcomeProcessingMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/OutcomeProcessingMarshaller.php @@ -41,7 +41,7 @@ class OutcomeProcessingMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -57,17 +57,16 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI outcomeProcessing element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An OutcomeProcessing object. + * @return OutcomeProcessing An OutcomeProcessing object. * @throws MarshallerNotFoundException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): OutcomeProcessing { - $outcomeRuleElts = self::getChildElements($element); - $outcomeRules = new OutcomeRuleCollection(); - for ($i = 0; $i < count($outcomeRuleElts); $i++) { - $marshaller = $this->getMarshallerFactory()->createMarshaller($outcomeRuleElts[$i]); - $outcomeRules[] = $marshaller->unmarshall($outcomeRuleElts[$i]); + + foreach (self::getChildElements($element) as $outcomeRule) { + $marshaller = $this->getMarshallerFactory()->createMarshaller($outcomeRule); + $outcomeRules[] = $marshaller->unmarshall($outcomeRule); } return new OutcomeProcessing($outcomeRules); @@ -76,7 +75,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'outcomeProcessing'; } diff --git a/src/qtism/data/storage/xml/marshalling/OutcomeVariableMarshaller.php b/src/qtism/data/storage/xml/marshalling/OutcomeVariableMarshaller.php index 3881cca45..3d8cf4fcc 100644 --- a/src/qtism/data/storage/xml/marshalling/OutcomeVariableMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/OutcomeVariableMarshaller.php @@ -50,10 +50,10 @@ class OutcomeVariableMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); - $element->setAttribute('identifier', $component->getIdentifier()); + $element->setAttribute('identifier', (string)$component->getIdentifier()); $element->setAttribute('cardinality', Cardinality::getNameByConstant($component->getCardinality())); $element->setAttribute('baseType', BaseType::getNameByConstant($component->getBaseType())); @@ -62,23 +62,23 @@ protected function marshall(QtiComponent $component) } if ($component->hasInterpretation()) { - $element->setAttribute('interpretation', $component->getInterpretation()); + $element->setAttribute('interpretation', (string)$component->getInterpretation()); } if ($component->hasLongInterpretation()) { - $element->setAttribute('longInterpretation', $component->getLongInterpretation()); + $element->setAttribute('longInterpretation', (string)$component->getLongInterpretation()); } if ($component->hasNormalMinimum()) { - $element->setAttribute('normalMinimum', $component->getNormalMinimum()); + $element->setAttribute('normalMinimum', (string)$component->getNormalMinimum()); } if ($component->hasNormalMaximum()) { - $element->setAttribute('normalMaximum', $component->getNormalMaximum()); + $element->setAttribute('normalMaximum', (string)$component->getNormalMaximum()); } if ($component->hasMasteryValue()) { - $element->setAttribute('masteryValue', $component->getMasteryValue()); + $element->setAttribute('masteryValue', (string)$component->getMasteryValue()); } if ($component->hasValues()) { @@ -95,11 +95,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI sessionIdentifier element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A QtiComponent object. + * @return ResultOutcomeVariable A QtiComponent object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): ResultOutcomeVariable { if (!$element->hasAttribute('identifier')) { throw new UnmarshallingException('OutcomeVariable element must have identifier attribute', $element); @@ -164,7 +164,7 @@ protected function unmarshall(DOMElement $element) * * @return string A QTI class name or an empty string. */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'outcomeVariable'; } diff --git a/src/qtism/data/storage/xml/marshalling/ParamMarshaller.php b/src/qtism/data/storage/xml/marshalling/ParamMarshaller.php index 43d4081f2..b21a0fd2d 100644 --- a/src/qtism/data/storage/xml/marshalling/ParamMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ParamMarshaller.php @@ -39,7 +39,7 @@ class ParamMarshaller extends Marshaller * @param QtiComponent $component A Param object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'name', $component->getName()); @@ -57,10 +57,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an XHTML param element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Param object. + * @return Param A Param object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Param { if (($name = $this->getDOMElementAttributeAs($element, 'name')) === null) { // XSD use="required" but can be empty. @@ -89,7 +89,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'param'; } diff --git a/src/qtism/data/storage/xml/marshalling/PatternMatchMarshaller.php b/src/qtism/data/storage/xml/marshalling/PatternMatchMarshaller.php index 21b83cfbc..57bff3b8e 100644 --- a/src/qtism/data/storage/xml/marshalling/PatternMatchMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/PatternMatchMarshaller.php @@ -41,7 +41,7 @@ class PatternMatchMarshaller extends OperatorMarshaller * @param array $elements An array of child DOMEelement objects. * @return DOMElement The marshalled QTI patternMatch element. */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'pattern', $component->getPattern()); @@ -61,7 +61,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @return QtiComponent A PatternMatch object. * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($pattern = $this->getDOMElementAttributeAs($element, 'pattern')) !== null) { return new PatternMatch($children, $pattern); diff --git a/src/qtism/data/storage/xml/marshalling/PositionObjectInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/PositionObjectInteractionMarshaller.php index 27877522e..073d864c5 100644 --- a/src/qtism/data/storage/xml/marshalling/PositionObjectInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/PositionObjectInteractionMarshaller.php @@ -43,7 +43,7 @@ class PositionObjectInteractionMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -72,11 +72,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an positionObjectInteraction element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A PositionObjectInteraction object. + * @return PositionObjectInteraction A PositionObjectInteraction object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): PositionObjectInteraction { $version = $this->getVersion(); if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { @@ -131,7 +131,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'positionObjectInteraction'; } diff --git a/src/qtism/data/storage/xml/marshalling/PositionObjectStageMarshaller.php b/src/qtism/data/storage/xml/marshalling/PositionObjectStageMarshaller.php index 7eee39d06..e0b4ba342 100644 --- a/src/qtism/data/storage/xml/marshalling/PositionObjectStageMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/PositionObjectStageMarshaller.php @@ -41,7 +41,7 @@ class PositionObjectStageMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $object = $component->getObject(); @@ -58,11 +58,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an positionObjectStage element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A PositionObjectStage object. + * @return PositionObjectStage A PositionObjectStage object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): PositionObjectStage { $objectElts = $this->getChildElementsByTagName($element, 'object'); if (count($objectElts) > 0) { @@ -90,7 +90,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'positionObjectStage'; } diff --git a/src/qtism/data/storage/xml/marshalling/PreConditionMarshaller.php b/src/qtism/data/storage/xml/marshalling/PreConditionMarshaller.php index d392b94f3..fafdc0551 100644 --- a/src/qtism/data/storage/xml/marshalling/PreConditionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/PreConditionMarshaller.php @@ -40,7 +40,7 @@ class PreConditionMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -54,11 +54,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI preCondition element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Precondition object. + * @return Precondition A Precondition object. * @throws MarshallerNotFoundException * @throws UnmarshallingException If $element does not contain any QTI expression element. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Precondition { $expressionElt = self::getFirstChildElement($element); @@ -74,7 +74,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'preCondition'; } diff --git a/src/qtism/data/storage/xml/marshalling/PrintedVariableMarshaller.php b/src/qtism/data/storage/xml/marshalling/PrintedVariableMarshaller.php index 52988111a..7b469380e 100644 --- a/src/qtism/data/storage/xml/marshalling/PrintedVariableMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/PrintedVariableMarshaller.php @@ -40,7 +40,7 @@ class PrintedVariableMarshaller extends Marshaller * @param QtiComponent $component A PrintedVariable object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $version = $this->getVersion(); @@ -79,10 +79,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a printedVariable element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A PrintedVariable object. + * @return PrintedVariable A PrintedVariable object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): PrintedVariable { $version = $this->getVersion(); @@ -133,7 +133,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'printedVariable'; } diff --git a/src/qtism/data/storage/xml/marshalling/PromptMarshaller.php b/src/qtism/data/storage/xml/marshalling/PromptMarshaller.php index 345497520..865435d21 100644 --- a/src/qtism/data/storage/xml/marshalling/PromptMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/PromptMarshaller.php @@ -38,10 +38,10 @@ class PromptMarshaller extends ContentMarshaller /** * @param DOMElement $element * @param QtiComponentCollection $children - * @return mixed + * @return QtiComponent * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); $component = new $fqClass(); @@ -86,7 +86,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->fillElement($element, $component); @@ -98,7 +98,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/Qti20MarshallerFactory.php b/src/qtism/data/storage/xml/marshalling/Qti20MarshallerFactory.php index 89d4a181f..2f110d2ad 100644 --- a/src/qtism/data/storage/xml/marshalling/Qti20MarshallerFactory.php +++ b/src/qtism/data/storage/xml/marshalling/Qti20MarshallerFactory.php @@ -91,6 +91,7 @@ public function __construct() * @param array $args * @return mixed */ + #[\ReturnTypeWillChange] protected function instantiateMarshaller(ReflectionClass $class, array $args) { array_unshift($args, '2.0.0'); diff --git a/src/qtism/data/storage/xml/marshalling/Qti211MarshallerFactory.php b/src/qtism/data/storage/xml/marshalling/Qti211MarshallerFactory.php index 4533872b9..c1e259c48 100644 --- a/src/qtism/data/storage/xml/marshalling/Qti211MarshallerFactory.php +++ b/src/qtism/data/storage/xml/marshalling/Qti211MarshallerFactory.php @@ -37,6 +37,7 @@ class Qti211MarshallerFactory extends Qti21MarshallerFactory * @param array $args * @return mixed */ + #[\ReturnTypeWillChange] protected function instantiateMarshaller(ReflectionClass $class, array $args) { array_unshift($args, '2.1.1'); diff --git a/src/qtism/data/storage/xml/marshalling/Qti21MarshallerFactory.php b/src/qtism/data/storage/xml/marshalling/Qti21MarshallerFactory.php index 99349e9ff..c735dde8c 100644 --- a/src/qtism/data/storage/xml/marshalling/Qti21MarshallerFactory.php +++ b/src/qtism/data/storage/xml/marshalling/Qti21MarshallerFactory.php @@ -37,6 +37,7 @@ class Qti21MarshallerFactory extends MarshallerFactory * @param array $args * @return mixed */ + #[\ReturnTypeWillChange] protected function instantiateMarshaller(ReflectionClass $class, array $args) { array_unshift($args, '2.1.0'); diff --git a/src/qtism/data/storage/xml/marshalling/Qti221MarshallerFactory.php b/src/qtism/data/storage/xml/marshalling/Qti221MarshallerFactory.php index 95d895ef5..96f932263 100644 --- a/src/qtism/data/storage/xml/marshalling/Qti221MarshallerFactory.php +++ b/src/qtism/data/storage/xml/marshalling/Qti221MarshallerFactory.php @@ -37,6 +37,7 @@ class Qti221MarshallerFactory extends Qti22MarshallerFactory * @param array $args * @return mixed */ + #[\ReturnTypeWillChange] protected function instantiateMarshaller(ReflectionClass $class, array $args) { array_unshift($args, '2.2.1'); diff --git a/src/qtism/data/storage/xml/marshalling/Qti222MarshallerFactory.php b/src/qtism/data/storage/xml/marshalling/Qti222MarshallerFactory.php index 45c57c56c..60d29acd0 100644 --- a/src/qtism/data/storage/xml/marshalling/Qti222MarshallerFactory.php +++ b/src/qtism/data/storage/xml/marshalling/Qti222MarshallerFactory.php @@ -37,6 +37,7 @@ class Qti222MarshallerFactory extends Qti22MarshallerFactory * @param array $args * @return mixed */ + #[\ReturnTypeWillChange] protected function instantiateMarshaller(ReflectionClass $class, array $args) { array_unshift($args, '2.2.2'); diff --git a/src/qtism/data/storage/xml/marshalling/Qti223MarshallerFactory.php b/src/qtism/data/storage/xml/marshalling/Qti223MarshallerFactory.php index 4c173d903..a715edf34 100644 --- a/src/qtism/data/storage/xml/marshalling/Qti223MarshallerFactory.php +++ b/src/qtism/data/storage/xml/marshalling/Qti223MarshallerFactory.php @@ -37,6 +37,7 @@ class Qti223MarshallerFactory extends Qti22MarshallerFactory * @param array $args * @return mixed */ + #[\ReturnTypeWillChange] protected function instantiateMarshaller(ReflectionClass $class, array $args) { array_unshift($args, '2.2.3'); diff --git a/src/qtism/data/storage/xml/marshalling/Qti224MarshallerFactory.php b/src/qtism/data/storage/xml/marshalling/Qti224MarshallerFactory.php index 31c91a278..c47b3618b 100644 --- a/src/qtism/data/storage/xml/marshalling/Qti224MarshallerFactory.php +++ b/src/qtism/data/storage/xml/marshalling/Qti224MarshallerFactory.php @@ -37,6 +37,7 @@ class Qti224MarshallerFactory extends Qti22MarshallerFactory * @param array $args * @return mixed */ + #[\ReturnTypeWillChange] protected function instantiateMarshaller(ReflectionClass $class, array $args) { array_unshift($args, '2.2.4'); diff --git a/src/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php b/src/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php index 19d5729f9..3ee919f50 100644 --- a/src/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php +++ b/src/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php @@ -60,6 +60,7 @@ public function __construct() * @param array $args * @return mixed */ + #[\ReturnTypeWillChange] protected function instantiateMarshaller(ReflectionClass $class, array $args) { array_unshift($args, '2.2.0'); diff --git a/src/qtism/data/storage/xml/marshalling/Qti30MarshallerFactory.php b/src/qtism/data/storage/xml/marshalling/Qti30MarshallerFactory.php index 3de5b3d55..de96c8f97 100644 --- a/src/qtism/data/storage/xml/marshalling/Qti30MarshallerFactory.php +++ b/src/qtism/data/storage/xml/marshalling/Qti30MarshallerFactory.php @@ -128,7 +128,7 @@ public function __construct() * @param array $args * @return Marshaller */ - protected function instantiateMarshaller(ReflectionClass $class, array $args) + protected function instantiateMarshaller(ReflectionClass $class, array $args): Marshaller { array_unshift($args, '3.0.0'); return Reflection::newInstance($class, $args); diff --git a/src/qtism/data/storage/xml/marshalling/QtiHtml5AttributeTrait.php b/src/qtism/data/storage/xml/marshalling/QtiHtml5AttributeTrait.php index c541ad82b..f04b7ec7a 100644 --- a/src/qtism/data/storage/xml/marshalling/QtiHtml5AttributeTrait.php +++ b/src/qtism/data/storage/xml/marshalling/QtiHtml5AttributeTrait.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\storage\xml\marshalling; use qtism\common\utils\Version; @@ -36,7 +34,7 @@ abstract function getDOMElementAttributeAs(DOMElement $element, $attribute, $dat /** * @return DOMElement */ - public function marshallHtml5Attributes(QtiComponent $component, DOMElement $element) + public function marshallHtml5Attributes(QtiComponent $component, DOMElement $element): DOMElement { if ($component->hasTitle()) { $this->setDOMElementAttribute($element, 'title', $component->getTitle()); @@ -49,7 +47,7 @@ public function marshallHtml5Attributes(QtiComponent $component, DOMElement $ele return $element; } - protected function fillBodyElementAttributes(BodyElement &$bodyElement, DOMElement $element) + protected function fillBodyElementAttributes(BodyElement &$bodyElement, DOMElement $element): void { if (Version::compare($this->getVersion(), '2.2.0', '>=') === true) { $title = $this->getDOMElementAttributeAs($element, 'title'); diff --git a/src/qtism/data/storage/xml/marshalling/QtiNamespacePrefixTrait.php b/src/qtism/data/storage/xml/marshalling/QtiNamespacePrefixTrait.php index 7e6f4f381..fe8a9660b 100644 --- a/src/qtism/data/storage/xml/marshalling/QtiNamespacePrefixTrait.php +++ b/src/qtism/data/storage/xml/marshalling/QtiNamespacePrefixTrait.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\data\storage\xml\marshalling; use qtism\data\QtiComponent; @@ -33,7 +31,7 @@ trait QtiNamespacePrefixTrait /** * @return string */ - abstract public function getVersion(); + abstract public function getVersion(): string; /** * @return DOMElement|false diff --git a/src/qtism/data/storage/xml/marshalling/RandomFloatMarshaller.php b/src/qtism/data/storage/xml/marshalling/RandomFloatMarshaller.php index 3350e1ead..56e698147 100644 --- a/src/qtism/data/storage/xml/marshalling/RandomFloatMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/RandomFloatMarshaller.php @@ -39,7 +39,7 @@ class RandomFloatMarshaller extends Marshaller * @param QtiComponent $component A RandomFloat object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -53,10 +53,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI randomFloat element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A RandomFloat object. + * @return RandomFloat A RandomFloat object. * @throws UnmarshallingException If the mandatory attributes min or max ar missing. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): RandomFloat { // max attribute is mandatory. if (($max = $this->getDOMElementAttributeAs($element, 'max')) !== null) { @@ -79,7 +79,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'randomFloat'; } diff --git a/src/qtism/data/storage/xml/marshalling/RandomIntegerMarshaller.php b/src/qtism/data/storage/xml/marshalling/RandomIntegerMarshaller.php index 31bb42ffb..fda81b4b8 100644 --- a/src/qtism/data/storage/xml/marshalling/RandomIntegerMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/RandomIntegerMarshaller.php @@ -39,7 +39,7 @@ class RandomIntegerMarshaller extends Marshaller * @param QtiComponent $component A RandomInteger object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -57,10 +57,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI randomInteger element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A RandomInteger object. + * @return RandomInteger A RandomInteger object. * @throws UnmarshallingException If the mandatory attributes 'min' or 'max' are missing from $element. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): RandomInteger { if (($max = $this->getDOMElementAttributeAs($element, 'max', 'string')) !== null) { $max = (Format::isVariableRef($max)) ? $max : (int)$max; @@ -85,7 +85,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'randomInteger'; } diff --git a/src/qtism/data/storage/xml/marshalling/RecursiveMarshaller.php b/src/qtism/data/storage/xml/marshalling/RecursiveMarshaller.php index 9c339aea1..312a2f77d 100644 --- a/src/qtism/data/storage/xml/marshalling/RecursiveMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/RecursiveMarshaller.php @@ -70,7 +70,7 @@ abstract class RecursiveMarshaller extends Marshaller * * @param mixed $object An object value. */ - protected function pushProcessed($object) + protected function pushProcessed($object): void { array_push($this->processed, $object); } @@ -80,7 +80,7 @@ protected function pushProcessed($object) * * @return array An array of object values. */ - protected function getProcessed() + protected function getProcessed(): array { return $this->processed; } @@ -88,7 +88,7 @@ protected function getProcessed() /** * Reset the list of objects processed so far. */ - protected function resetProcessed() + protected function resetProcessed(): void { $this->processed = []; } @@ -98,7 +98,7 @@ protected function resetProcessed() * * @param mixed $object An object to push on the trail stack. */ - protected function pushTrail($object) + protected function pushTrail($object): void { array_push($this->trail, $object); } @@ -108,6 +108,7 @@ protected function pushTrail($object) * * @return mixed An object popped from the trail stack. */ + #[\ReturnTypeWillChange] protected function popTrail() { return array_pop($this->trail); @@ -116,7 +117,7 @@ protected function popTrail() /** * Reset the trail stack. */ - protected function resetTrail() + protected function resetTrail(): void { $this->trail = []; } @@ -126,7 +127,7 @@ protected function resetTrail() * * @return int The amount of objects in the trail stack. */ - protected function countTrail() + protected function countTrail(): int { return count($this->trail); } @@ -136,7 +137,7 @@ protected function countTrail() * * @param mixed $object */ - protected function pushFinal($object) + protected function pushFinal($object): void { array_push($this->final, $object); } @@ -147,7 +148,7 @@ protected function pushFinal($object) * @param int $count * @return array The content of the final stack. */ - protected function emptyFinal(int $count) + protected function emptyFinal(int $count): array { $returnValue = []; @@ -162,7 +163,7 @@ protected function emptyFinal(int $count) /** * Reset the final stack. */ - protected function resetFinal() + protected function resetFinal(): void { $this->final = []; } @@ -172,7 +173,7 @@ protected function resetFinal() * * @param mixed $object A php object. */ - protected function mark($object) + protected function mark($object): void { array_push($this->mark, $object); } @@ -180,7 +181,7 @@ protected function mark($object) /** * Reset the marking of objects. */ - protected function resetMark() + protected function resetMark(): void { $this->mark = []; } @@ -191,7 +192,7 @@ protected function resetMark() * @param mixed $object The object to check; * @return bool Whether $object is marked. */ - protected function isMarked($object) + protected function isMarked($object): bool { return in_array($object, $this->mark, true); } @@ -204,7 +205,7 @@ protected function isMarked($object) * @throws MarshallerNotFoundException * @throws MarshallingException If an error occurs during the marshalling process. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { // Reset. $this->resetTrail(); @@ -258,7 +259,7 @@ protected function marshall(QtiComponent $component) * @return QtiComponent A QtiComponent object corresponding to the DOMElement to unmarshall. * @throws MarshallerNotFoundException */ - protected function unmarshall(DOMElement $element, QtiComponent $rootComponent = null) + protected function unmarshall(DOMElement $element, QtiComponent $rootComponent = null): QtiComponent { // Reset. $this->resetTrail(); @@ -335,7 +336,7 @@ protected function unmarshall(DOMElement $element, QtiComponent $rootComponent = * @param QtiComponentCollection $children The already unmarshalled children QTI components. * @return QtiComponent $element as a QtiComponent object. */ - abstract protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children); + abstract protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent; /** * Whether a given $element is final. In other words, whether the $element @@ -351,7 +352,7 @@ abstract protected function isElementFinal(DOMNode $element); * @param DOMElement $element * @return array An array of DOMNode objects. */ - abstract protected function getChildrenElements(DOMElement $element); + abstract protected function getChildrenElements(DOMElement $element): array; /** * Create a collection from DOMElement objects. @@ -359,7 +360,7 @@ abstract protected function getChildrenElements(DOMElement $element); * @param DOMElement $currentNode * @return AbstractCollection */ - abstract protected function createCollection(DOMElement $currentNode); + abstract protected function createCollection(DOMElement $currentNode): AbstractCollection; /** * Marshall a given QTI $component while receiving the already marshalled @@ -369,7 +370,7 @@ abstract protected function createCollection(DOMElement $currentNode); * @param array $elements An array of DOMElement objectss. * @return DOMElement The marshalled $component. */ - abstract protected function marshallChildrenKnown(QtiComponent $component, array $elements); + abstract protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement; /** * Whether or not a QtiComponent object is final. In other words, whether $component @@ -385,5 +386,5 @@ abstract protected function isComponentFinal(QtiComponent $component); * @param QtiComponent $component * @return array An array of QtiComponent objects. */ - abstract protected function getChildrenComponents(QtiComponent $component); + abstract protected function getChildrenComponents(QtiComponent $component): array; } diff --git a/src/qtism/data/storage/xml/marshalling/RepeatMarshaller.php b/src/qtism/data/storage/xml/marshalling/RepeatMarshaller.php index 111dd685f..a4e0cc576 100644 --- a/src/qtism/data/storage/xml/marshalling/RepeatMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/RepeatMarshaller.php @@ -42,7 +42,7 @@ class RepeatMarshaller extends OperatorMarshaller * @param array $elements An array of child DOMElement objects. * @return DOMElement The marshalled QTI repeat element. */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'numberRepeats', $component->getNumberRepeats()); @@ -62,7 +62,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @return QtiComponent A Repeat object. * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($numberRepeats = $this->getDOMElementAttributeAs($element, 'numberRepeats')) !== null) { if (Format::isInteger($numberRepeats)) { diff --git a/src/qtism/data/storage/xml/marshalling/ResponseConditionMarshaller.php b/src/qtism/data/storage/xml/marshalling/ResponseConditionMarshaller.php index 20e00e32a..c72636cf1 100644 --- a/src/qtism/data/storage/xml/marshalling/ResponseConditionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ResponseConditionMarshaller.php @@ -46,7 +46,7 @@ class ResponseConditionMarshaller extends RecursiveMarshaller * @return ResponseCondition * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): ResponseCondition { if (count($children) > 0) { // The first element of $children must be a responseIf. @@ -84,7 +84,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -99,7 +99,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @param DOMNode $element * @return bool */ - protected function isElementFinal(DOMNode $element) + protected function isElementFinal(DOMNode $element): bool { $exclusion = ['responseIf', 'responseElseIf', 'responseElse', 'responseCondition']; @@ -110,7 +110,7 @@ protected function isElementFinal(DOMNode $element) * @param QtiComponent $component * @return bool */ - protected function isComponentFinal(QtiComponent $component) + protected function isComponentFinal(QtiComponent $component): bool { return (!$component instanceof ResponseIf && !$component instanceof ResponseElseIf && @@ -122,7 +122,7 @@ protected function isComponentFinal(QtiComponent $component) * @param DOMElement $element * @return array */ - protected function getChildrenElements(DOMElement $element) + protected function getChildrenElements(DOMElement $element): array { return $this->getChildElementsByTagName($element, [ 'responseIf', @@ -139,7 +139,7 @@ protected function getChildrenElements(DOMElement $element) * @param QtiComponent $component * @return array */ - protected function getChildrenComponents(QtiComponent $component) + protected function getChildrenComponents(QtiComponent $component): array { if ($component instanceof ResponseIf || $component instanceof ResponseElseIf || $component instanceof ResponseElse) { // ResponseControl @@ -164,7 +164,7 @@ protected function getChildrenComponents(QtiComponent $component) * @param DOMElement $currentNode * @return QtiComponentCollection|ResponseRuleCollection */ - protected function createCollection(DOMElement $currentNode) + protected function createCollection(DOMElement $currentNode): QtiComponentCollection { if ($currentNode->localName != 'responseCondition') { return new ResponseRuleCollection(); @@ -176,7 +176,7 @@ protected function createCollection(DOMElement $currentNode) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return ''; } diff --git a/src/qtism/data/storage/xml/marshalling/ResponseControlMarshaller.php b/src/qtism/data/storage/xml/marshalling/ResponseControlMarshaller.php index 846126a3d..cab80da68 100644 --- a/src/qtism/data/storage/xml/marshalling/ResponseControlMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ResponseControlMarshaller.php @@ -51,7 +51,7 @@ class ResponseControlMarshaller extends RecursiveMarshaller * @throws UnmarshallingException * @throws ReflectionException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $expressionElts = $this->getChildElementsByTagName($element, Expression::getExpressionClassNames()); @@ -83,7 +83,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -103,7 +103,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @param DOMNode $element * @return bool */ - protected function isElementFinal(DOMNode $element) + protected function isElementFinal(DOMNode $element): bool { return in_array($element->localName, array_merge([ 'exitResponse', @@ -116,7 +116,7 @@ protected function isElementFinal(DOMNode $element) * @param QtiComponent $component * @return bool */ - protected function isComponentFinal(QtiComponent $component) + protected function isComponentFinal(QtiComponent $component): bool { return ($component instanceof ExitTest || $component instanceof LookupOutcomeValue || @@ -127,7 +127,7 @@ protected function isComponentFinal(QtiComponent $component) * @param DOMElement $element * @return array */ - protected function getChildrenElements(DOMElement $element) + protected function getChildrenElements(DOMElement $element): array { return $this->getChildElementsByTagName($element, [ 'exitResponse', @@ -141,7 +141,7 @@ protected function getChildrenElements(DOMElement $element) * @param QtiComponent $component * @return array */ - protected function getChildrenComponents(QtiComponent $component) + protected function getChildrenComponents(QtiComponent $component): array { return $component->getResponseRules()->getArrayCopy(); } @@ -150,7 +150,7 @@ protected function getChildrenComponents(QtiComponent $component) * @param DOMElement $currentNode * @return ResponseRuleCollection */ - protected function createCollection(DOMElement $currentNode) + protected function createCollection(DOMElement $currentNode): ResponseRuleCollection { return new ResponseRuleCollection(); } @@ -158,7 +158,7 @@ protected function createCollection(DOMElement $currentNode) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return ''; } diff --git a/src/qtism/data/storage/xml/marshalling/ResponseDeclarationMarshaller.php b/src/qtism/data/storage/xml/marshalling/ResponseDeclarationMarshaller.php index 21af63016..e8a51c8f7 100644 --- a/src/qtism/data/storage/xml/marshalling/ResponseDeclarationMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ResponseDeclarationMarshaller.php @@ -41,7 +41,7 @@ class ResponseDeclarationMarshaller extends VariableDeclarationMarshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = parent::marshall($component); $baseType = $component->getBaseType(); @@ -68,11 +68,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI responseDeclaration element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A ResponseDeclaration object. + * @return ResponseDeclaration A ResponseDeclaration object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): ResponseDeclaration { try { $baseComponent = parent::unmarshall($element); @@ -112,7 +112,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'responseDeclaration'; } diff --git a/src/qtism/data/storage/xml/marshalling/ResponseProcessingMarshaller.php b/src/qtism/data/storage/xml/marshalling/ResponseProcessingMarshaller.php index 2f42769c6..88378236e 100644 --- a/src/qtism/data/storage/xml/marshalling/ResponseProcessingMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ResponseProcessingMarshaller.php @@ -41,7 +41,7 @@ class ResponseProcessingMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -66,11 +66,13 @@ protected function marshall(QtiComponent $component) * * @param DOMElement $element A DOMElement object. * @param ResponseProcessing|null $responseProcessing - * @return QtiComponent A ResponseProcessing object. + * @return ResponseProcessing A ResponseProcessing object. * @throws MarshallerNotFoundException */ - protected function unmarshall(DOMElement $element, ResponseProcessing $responseProcessing = null) - { + protected function unmarshall( + DOMElement $element, + ResponseProcessing $responseProcessing = null + ): ResponseProcessing { $responseRuleElts = self::getChildElements($element); $responseRules = new ResponseRuleCollection(); @@ -100,7 +102,7 @@ protected function unmarshall(DOMElement $element, ResponseProcessing $responseP /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'responseProcessing'; } diff --git a/src/qtism/data/storage/xml/marshalling/ResponseValidityConstraintMarshaller.php b/src/qtism/data/storage/xml/marshalling/ResponseValidityConstraintMarshaller.php index 5b7e1b105..1a9d4a850 100644 --- a/src/qtism/data/storage/xml/marshalling/ResponseValidityConstraintMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ResponseValidityConstraintMarshaller.php @@ -41,7 +41,7 @@ class ResponseValidityConstraintMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - public function marshall(QtiComponent $component) + public function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier()); @@ -64,11 +64,11 @@ public function marshall(QtiComponent $component) * Unmarshall a DOMElement to its ResponseValidityConstraint data model representation. * * @param DOMElement $element - * @return QtiComponent A ResponseValidityConstraint object. + * @return ResponseValidityConstraint A ResponseValidityConstraint object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - public function unmarshall(DOMElement $element) + public function unmarshall(DOMElement $element): ResponseValidityConstraint { if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { if (($minConstraint = $this->getDOMElementAttributeAs($element, 'minConstraint', 'integer')) !== null) { @@ -118,7 +118,7 @@ public function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'responseValidityConstraint'; } diff --git a/src/qtism/data/storage/xml/marshalling/ResponseVariableMarshaller.php b/src/qtism/data/storage/xml/marshalling/ResponseVariableMarshaller.php index 7d8df287b..9db607f23 100644 --- a/src/qtism/data/storage/xml/marshalling/ResponseVariableMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ResponseVariableMarshaller.php @@ -45,10 +45,10 @@ class ResponseVariableMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); - $element->setAttribute('identifier', $component->getIdentifier()); + $element->setAttribute('identifier', (string)$component->getIdentifier()); $element->setAttribute('cardinality', Cardinality::getNameByConstant($component->getCardinality())); if ($component->hasBaseType()) { @@ -56,7 +56,7 @@ protected function marshall(QtiComponent $component) } if ($component->hasChoiceSequence()) { - $element->setAttribute('choiceSequence', $component->getChoiceSequence()); + $element->setAttribute('choiceSequence', (string)$component->getChoiceSequence()); } if ($component->hasCorrectResponse()) { @@ -76,11 +76,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI sessionIdentifier element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A QtiComponent object. + * @return ResultResponseVariable A QtiComponent object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): ResultResponseVariable { if (!$element->hasAttribute('identifier')) { throw new UnmarshallingException('ResponseVariable element must have identifier attribute', $element); @@ -133,7 +133,7 @@ protected function unmarshall(DOMElement $element) * * @return string A QTI class name or an empty string. */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'responseVariable'; } diff --git a/src/qtism/data/storage/xml/marshalling/RoundToMarshaller.php b/src/qtism/data/storage/xml/marshalling/RoundToMarshaller.php index 296f9ce1b..34dd38ff0 100644 --- a/src/qtism/data/storage/xml/marshalling/RoundToMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/RoundToMarshaller.php @@ -43,7 +43,7 @@ class RoundToMarshaller extends OperatorMarshaller * @param array $elements An array of child DOMEelement objects. * @return DOMElement The marshalled QTI roundTo element. */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -65,7 +65,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @return QtiComponent A RoundTo object. * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($figures = $this->getDOMElementAttributeAs($element, 'figures', 'string')) !== null) { if (!Format::isVariableRef($figures)) { diff --git a/src/qtism/data/storage/xml/marshalling/RubricBlockMarshaller.php b/src/qtism/data/storage/xml/marshalling/RubricBlockMarshaller.php index 23ebeacb0..da88a5e4d 100644 --- a/src/qtism/data/storage/xml/marshalling/RubricBlockMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/RubricBlockMarshaller.php @@ -47,7 +47,7 @@ class RubricBlockMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -93,7 +93,7 @@ protected function marshall(QtiComponent $component) * @throws MarshallerNotFoundException * @throws UnmarshallingException If the mandatory attribute 'href' is missing from $element. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): RubricBlock { // First we retrieve the mandatory views. if (($value = $this->getDOMElementAttributeAs($element, 'view', 'string')) !== null) { @@ -154,7 +154,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'rubricBlock'; } diff --git a/src/qtism/data/storage/xml/marshalling/RubricBlockRefMarshaller.php b/src/qtism/data/storage/xml/marshalling/RubricBlockRefMarshaller.php index ffa0ccdbf..b9606e4f7 100644 --- a/src/qtism/data/storage/xml/marshalling/RubricBlockRefMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/RubricBlockRefMarshaller.php @@ -38,7 +38,7 @@ class RubricBlockRefMarshaller extends Marshaller * @param QtiComponent $component * @return DOMElement */ - public function marshall(QtiComponent $component) + public function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'identifier', $component->getIdentifier()); @@ -51,10 +51,10 @@ public function marshall(QtiComponent $component) * Unmarshall a DOMElement to its RubricBlockRef data model representation. * * @param DOMElement $element - * @return QtiComponent A RubricBlockRef object. + * @return RubricBlockRef A RubricBlockRef object. * @throws UnmarshallingException If the 'identifier' or 'href' attribute is missing from the XML definition. */ - public function unmarshall(DOMElement $element) + public function unmarshall(DOMElement $element): RubricBlockRef { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { if (($href = $this->getDOMElementAttributeAs($element, 'href')) !== null) { @@ -72,7 +72,7 @@ public function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'rubricBlockRef'; } diff --git a/src/qtism/data/storage/xml/marshalling/SectionPartMarshaller.php b/src/qtism/data/storage/xml/marshalling/SectionPartMarshaller.php index 542fbc215..fc7ad509e 100644 --- a/src/qtism/data/storage/xml/marshalling/SectionPartMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SectionPartMarshaller.php @@ -42,7 +42,7 @@ class SectionPartMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -81,7 +81,7 @@ protected function marshall(QtiComponent $component) * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): QtiComponent { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { $object = new SectionPart($identifier); @@ -95,9 +95,10 @@ protected function unmarshall(DOMElement $element) } $preConditionElts = $this->getChildElementsByTagName($element, 'preCondition'); - if (count($preConditionElts) > 0) { + $preConditionElementCount = count($preConditionElts); + if ($preConditionElementCount > 0) { $preConditions = new PreConditionCollection(); - for ($i = 0; $i < count($preConditionElts); $i++) { + for ($i = 0; $i < $preConditionElementCount; $i++) { $marshaller = $this->getMarshallerFactory()->createMarshaller($preConditionElts[$i]); $preConditions[] = $marshaller->unmarshall($preConditionElts[$i]); } @@ -105,9 +106,10 @@ protected function unmarshall(DOMElement $element) } $branchRuleElts = $this->getChildElementsByTagName($element, 'branchRule'); - if (count($branchRuleElts) > 0) { + $branchRuleElementCount = count($branchRuleElts); + if ($branchRuleElementCount > 0) { $branchRules = new BranchRuleCollection(); - for ($i = 0; $i < count($branchRuleElts); $i++) { + for ($i = 0; $i < $branchRuleElementCount; $i++) { $marshaller = $this->getMarshallerFactory()->createMarshaller($branchRuleElts[$i]); $branchRules[] = $marshaller->unmarshall($branchRuleElts[$i]); } @@ -136,7 +138,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'sectionPart'; } diff --git a/src/qtism/data/storage/xml/marshalling/SelectPointInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/SelectPointInteractionMarshaller.php index 50e442c49..bc60f2d74 100644 --- a/src/qtism/data/storage/xml/marshalling/SelectPointInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SelectPointInteractionMarshaller.php @@ -41,7 +41,7 @@ class SelectPointInteractionMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -73,11 +73,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a selectPointInteraction element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A SelectPointInteraction object. + * @return SelectPointInteraction A SelectPointInteraction object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): SelectPointInteraction { $version = $this->getVersion(); if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) === null) { @@ -132,7 +132,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'selectPointInteraction'; } diff --git a/src/qtism/data/storage/xml/marshalling/SelectionMarshaller.php b/src/qtism/data/storage/xml/marshalling/SelectionMarshaller.php index b9cdb1879..8cdfc096b 100644 --- a/src/qtism/data/storage/xml/marshalling/SelectionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SelectionMarshaller.php @@ -39,7 +39,7 @@ class SelectionMarshaller extends Marshaller * @param QtiComponent $component A Selection object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -60,10 +60,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI Selection object. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Selection object. + * @return Selection A Selection object. * @throws UnmarshallingException If the mandatory 'select' attribute is missing from $element. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Selection { // Retrieve XML content as a string. $frag = $element->ownerDocument->createDocumentFragment(); @@ -91,7 +91,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'selection'; } diff --git a/src/qtism/data/storage/xml/marshalling/SessionIdentifierMarshaller.php b/src/qtism/data/storage/xml/marshalling/SessionIdentifierMarshaller.php index 3c026e33f..886cd4b3a 100644 --- a/src/qtism/data/storage/xml/marshalling/SessionIdentifierMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SessionIdentifierMarshaller.php @@ -42,11 +42,11 @@ class SessionIdentifierMarshaller extends Marshaller * @param QtiComponent|SessionIdentifier $component A QtiComponent object to marshall. * @return DOMElement A DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); - $element->setAttribute('sourceID', $component->getSourceID()); - $element->setAttribute('identifier', $component->getIdentifier()); + $element->setAttribute('sourceID', (string)$component->getSourceID()); + $element->setAttribute('identifier', (string)$component->getIdentifier()); return $element; } @@ -55,10 +55,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI sessionIdentifier element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A QtiComponent object. + * @return SessionIdentifier A QtiComponent object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): SessionIdentifier { if (!$element->hasAttribute('sourceID')) { throw new UnmarshallingException('SessionIdentifier element must have sourceID attribute', $element); @@ -81,7 +81,7 @@ protected function unmarshall(DOMElement $element) * * @return string A QTI class name or an empty string. */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'sessionIdentifier'; } diff --git a/src/qtism/data/storage/xml/marshalling/SetCorrectResponseMarshaller.php b/src/qtism/data/storage/xml/marshalling/SetCorrectResponseMarshaller.php index 6d5ea7978..9561934c0 100644 --- a/src/qtism/data/storage/xml/marshalling/SetCorrectResponseMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SetCorrectResponseMarshaller.php @@ -40,7 +40,7 @@ class SetCorrectResponseMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getExpression()); @@ -55,11 +55,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI setCorrectResponse element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A SetCorrectResponse object. + * @return SetCorrectResponse A SetCorrectResponse object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): SetCorrectResponse { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { $expressionElt = self::getFirstChildElement($element); @@ -80,7 +80,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'setCorrectResponse'; } diff --git a/src/qtism/data/storage/xml/marshalling/SetDefaultValueMarshaller.php b/src/qtism/data/storage/xml/marshalling/SetDefaultValueMarshaller.php index 7435d7f1d..72ffa6625 100644 --- a/src/qtism/data/storage/xml/marshalling/SetDefaultValueMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SetDefaultValueMarshaller.php @@ -40,7 +40,7 @@ class SetDefaultValueMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getExpression()); @@ -55,11 +55,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI setDefaultValue element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A SetDefaultValue object. + * @return SetDefaultValue A SetDefaultValue object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): SetDefaultValue { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { $expressionElt = self::getFirstChildElement($element); @@ -80,7 +80,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'setDefaultValue'; } diff --git a/src/qtism/data/storage/xml/marshalling/SetOutcomeValueMarshaller.php b/src/qtism/data/storage/xml/marshalling/SetOutcomeValueMarshaller.php index 025b37885..00505bb9b 100644 --- a/src/qtism/data/storage/xml/marshalling/SetOutcomeValueMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SetOutcomeValueMarshaller.php @@ -40,7 +40,7 @@ class SetOutcomeValueMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getExpression()); @@ -55,11 +55,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI SetOutcomeValue element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A SetOutcomeValue object. + * @return SetOutcomeValue A SetOutcomeValue object. * @throws MarshallerNotFoundException * @throws UnmarshallingException If the mandatory expression child element is missing from $element or if the 'target' element is missing. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): SetOutcomeValue { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { $expressionElt = self::getFirstChildElement($element); @@ -80,7 +80,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'setOutcomeValue'; } diff --git a/src/qtism/data/storage/xml/marshalling/SetTemplateValueMarshaller.php b/src/qtism/data/storage/xml/marshalling/SetTemplateValueMarshaller.php index 3566f6653..9602881bf 100644 --- a/src/qtism/data/storage/xml/marshalling/SetTemplateValueMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SetTemplateValueMarshaller.php @@ -40,7 +40,7 @@ class SetTemplateValueMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getExpression()); @@ -55,11 +55,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI setTemplateValue element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A SetTemplateValue object. + * @return SetTemplateValue A SetTemplateValue object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): SetTemplateValue { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { $expressionElt = self::getFirstChildElement($element); @@ -80,7 +80,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'setTemplateValue'; } diff --git a/src/qtism/data/storage/xml/marshalling/ShufflingGroupMarshaller.php b/src/qtism/data/storage/xml/marshalling/ShufflingGroupMarshaller.php index 7598ab3bf..2ec0680d3 100644 --- a/src/qtism/data/storage/xml/marshalling/ShufflingGroupMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ShufflingGroupMarshaller.php @@ -39,7 +39,7 @@ class ShufflingGroupMarshaller extends Marshaller * @param QtiComponent $component A ShufflingGroup object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'identifiers', implode("\x20", $component->getIdentifiers()->getArrayCopy())); @@ -56,10 +56,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI ShufflingGroup element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A ShufflingGroup object. + * @return ShufflingGroup A ShufflingGroup object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): ShufflingGroup { if (($identifiers = $this->getDOMElementAttributeAs($element, 'identifiers')) !== null) { $identifiers = explode("\x20", $identifiers); @@ -80,7 +80,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'shufflingGroup'; } diff --git a/src/qtism/data/storage/xml/marshalling/ShufflingMarshaller.php b/src/qtism/data/storage/xml/marshalling/ShufflingMarshaller.php index c88e08a17..efceb5ef6 100644 --- a/src/qtism/data/storage/xml/marshalling/ShufflingMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ShufflingMarshaller.php @@ -41,7 +41,7 @@ class ShufflingMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier()); @@ -58,11 +58,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI ShufflingGroup element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A ShufflingGroup object. + * @return Shuffling A ShufflingGroup object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Shuffling { if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { $shufflingGroupElts = self::getChildElements($element, 'shufflingGroup'); @@ -91,7 +91,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'shuffling'; } diff --git a/src/qtism/data/storage/xml/marshalling/SimpleAssociableChoiceMarshaller.php b/src/qtism/data/storage/xml/marshalling/SimpleAssociableChoiceMarshaller.php index 0d17640b7..126e82162 100644 --- a/src/qtism/data/storage/xml/marshalling/SimpleAssociableChoiceMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SimpleAssociableChoiceMarshaller.php @@ -42,7 +42,7 @@ class SimpleAssociableChoiceMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $version = $this->getVersion(); @@ -90,7 +90,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -129,7 +129,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/SimpleChoiceMarshaller.php b/src/qtism/data/storage/xml/marshalling/SimpleChoiceMarshaller.php index f6202f6e8..2f1275eb7 100644 --- a/src/qtism/data/storage/xml/marshalling/SimpleChoiceMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SimpleChoiceMarshaller.php @@ -41,7 +41,7 @@ class SimpleChoiceMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $version = $this->getVersion(); @@ -76,7 +76,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $version = $this->getVersion(); $element = $this->createElement($component); @@ -103,7 +103,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/SimpleInlineMarshaller.php b/src/qtism/data/storage/xml/marshalling/SimpleInlineMarshaller.php index 373a04918..9699a5f84 100644 --- a/src/qtism/data/storage/xml/marshalling/SimpleInlineMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SimpleInlineMarshaller.php @@ -40,7 +40,7 @@ class SimpleInlineMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); @@ -79,7 +79,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->fillElement($element, $component); @@ -105,7 +105,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = [ "qtism\\data\\content\\xhtml", diff --git a/src/qtism/data/storage/xml/marshalling/SimpleMatchSetMarshaller.php b/src/qtism/data/storage/xml/marshalling/SimpleMatchSetMarshaller.php index 4dea3669b..fbd938c22 100644 --- a/src/qtism/data/storage/xml/marshalling/SimpleMatchSetMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SimpleMatchSetMarshaller.php @@ -39,7 +39,7 @@ class SimpleMatchSetMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); return new $fqClass(new SimpleAssociableChoiceCollection($children->getArrayCopy())); @@ -50,7 +50,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -61,7 +61,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\interactions"]; } diff --git a/src/qtism/data/storage/xml/marshalling/SliderInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/SliderInteractionMarshaller.php index 22d166848..48015d7e2 100644 --- a/src/qtism/data/storage/xml/marshalling/SliderInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SliderInteractionMarshaller.php @@ -42,7 +42,7 @@ class SliderInteractionMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->fillElement($element, $component); @@ -81,11 +81,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a SliderInteraction element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A SliderInteraction object. + * @return SliderInteraction A SliderInteraction object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): SliderInteraction { if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { if (($lowerBound = $this->getDOMElementAttributeAs($element, 'lowerBound', 'float')) !== null) { @@ -144,7 +144,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'sliderInteraction'; } diff --git a/src/qtism/data/storage/xml/marshalling/SsmlSubMarshaller.php b/src/qtism/data/storage/xml/marshalling/SsmlSubMarshaller.php index 14a0021af..e2b50e305 100644 --- a/src/qtism/data/storage/xml/marshalling/SsmlSubMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SsmlSubMarshaller.php @@ -38,7 +38,7 @@ class SsmlSubMarshaller extends Marshaller * @param QtiComponent $component An SSML sub object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { return self::getDOMCradle()->importNode($component->getXml()->documentElement, true); } @@ -47,9 +47,9 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an SSML sub element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An SSML sub object. + * @return Sub An SSML sub object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Sub { $node = $element->cloneNode(true); @@ -59,7 +59,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'sub'; } diff --git a/src/qtism/data/storage/xml/marshalling/StatsOperatorMarshaller.php b/src/qtism/data/storage/xml/marshalling/StatsOperatorMarshaller.php index 3f40b9769..b3002f5eb 100644 --- a/src/qtism/data/storage/xml/marshalling/StatsOperatorMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/StatsOperatorMarshaller.php @@ -42,7 +42,7 @@ class StatsOperatorMarshaller extends OperatorMarshaller * @param array $elements An array of child DOMEelement objects. * @return DOMElement The marshalled QTI statsOperator element. */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -63,7 +63,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @return QtiComponent A StatsOperator object. * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($name = $this->getDOMElementAttributeAs($element, 'name')) !== null) { return new StatsOperator($children, Statistics::getConstantByName($name)); diff --git a/src/qtism/data/storage/xml/marshalling/StringMatchMarshaller.php b/src/qtism/data/storage/xml/marshalling/StringMatchMarshaller.php index 9725ac63b..7affbca0c 100644 --- a/src/qtism/data/storage/xml/marshalling/StringMatchMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/StringMatchMarshaller.php @@ -41,7 +41,7 @@ class StringMatchMarshaller extends OperatorMarshaller * @param array $elements An array of child DOMEelement objects. * @return DOMElement The marshalled QTI stringMatch element. */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'caseSensitive', $component->isCaseSensitive()); @@ -62,7 +62,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @return QtiComponent An StringMatch object. * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { if (($caseSensitive = $this->getDOMElementAttributeAs($element, 'caseSensitive', 'boolean')) !== null) { $object = new StringMatch($children, $caseSensitive); diff --git a/src/qtism/data/storage/xml/marshalling/StylesheetMarshaller.php b/src/qtism/data/storage/xml/marshalling/StylesheetMarshaller.php index a2e7136dd..7cd8cb04c 100644 --- a/src/qtism/data/storage/xml/marshalling/StylesheetMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/StylesheetMarshaller.php @@ -38,7 +38,7 @@ class StylesheetMarshaller extends Marshaller * @param QtiComponent $component A Stylesheet object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -56,11 +56,11 @@ protected function marshall(QtiComponent $component) /** * Unmarshall a DOMElement object corresponding to a QTI stylesheet element. * - * @param DOMElement $element A DOMElement object. + * @param Stylesheet $element A DOMElement object. * @return QtiComponent A Stylesheet object. * @throws UnmarshallingException If the mandatory attribute 'href' is missing from $element. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Stylesheet { // href is a mandatory value, retrieve it first. if (($value = $this->getDOMElementAttributeAs($element, 'href', 'string')) !== null) { @@ -88,7 +88,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'stylesheet'; } diff --git a/src/qtism/data/storage/xml/marshalling/SubstringMarshaller.php b/src/qtism/data/storage/xml/marshalling/SubstringMarshaller.php index 73f267eb6..5e34b4b8a 100644 --- a/src/qtism/data/storage/xml/marshalling/SubstringMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/SubstringMarshaller.php @@ -41,7 +41,7 @@ class SubstringMarshaller extends OperatorMarshaller * @param array $elements An array of child DOMEelement objects. * @return DOMElement The marshalled QTI substring element. */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->setDOMElementAttribute($element, 'caseSensitive', $component->isCaseSensitive()); @@ -60,7 +60,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @param QtiComponentCollection $children A collection containing the child Expression objects composing the Operator. * @return QtiComponent A Substring object. */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $object = new Substring($children); diff --git a/src/qtism/data/storage/xml/marshalling/TableCellMarshaller.php b/src/qtism/data/storage/xml/marshalling/TableCellMarshaller.php index 83a19bf57..366288f76 100644 --- a/src/qtism/data/storage/xml/marshalling/TableCellMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TableCellMarshaller.php @@ -42,7 +42,7 @@ class TableCellMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); $component = new $fqClass(); @@ -100,7 +100,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -139,7 +139,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\xhtml\\tables"]; } diff --git a/src/qtism/data/storage/xml/marshalling/TableMarshaller.php b/src/qtism/data/storage/xml/marshalling/TableMarshaller.php index 5681876a9..c8b570e5b 100644 --- a/src/qtism/data/storage/xml/marshalling/TableMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TableMarshaller.php @@ -43,7 +43,7 @@ class TableMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -103,11 +103,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an XHTML table element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Table object. + * @return Table A Table object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Table { $tbodyElts = $this->getChildElementsByTagName($element, 'tbody'); @@ -179,7 +179,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'table'; } diff --git a/src/qtism/data/storage/xml/marshalling/TablePartMarshaller.php b/src/qtism/data/storage/xml/marshalling/TablePartMarshaller.php index 940be5454..3d4856c64 100644 --- a/src/qtism/data/storage/xml/marshalling/TablePartMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TablePartMarshaller.php @@ -24,6 +24,7 @@ namespace qtism\data\storage\xml\marshalling; use DOMElement; +use qtism\data\content\BodyElement; use qtism\data\content\xhtml\tables\TrCollection; use qtism\data\QtiComponent; @@ -40,7 +41,7 @@ class TablePartMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -58,11 +59,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an XHTML tbody/thead/tfoot element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Tbody/Thead/Tfoot object. + * @return BodyElement A Tbody/Thead/Tfoot object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): BodyElement { $trs = new TrCollection(); foreach ($this->getChildElementsByTagName($element, 'tr') as $trElt) { @@ -86,7 +87,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return ''; } diff --git a/src/qtism/data/storage/xml/marshalling/TemplateConditionMarshaller.php b/src/qtism/data/storage/xml/marshalling/TemplateConditionMarshaller.php index 78a8c3996..29281cd7a 100644 --- a/src/qtism/data/storage/xml/marshalling/TemplateConditionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TemplateConditionMarshaller.php @@ -46,7 +46,7 @@ class TemplateConditionMarshaller extends RecursiveMarshaller * @return TemplateCondition * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): TemplateCondition { if (count($children) > 0) { // The first element of $children must be a templateIf. @@ -84,7 +84,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -99,7 +99,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @param DOMNode $element * @return bool */ - protected function isElementFinal(DOMNode $element) + protected function isElementFinal(DOMNode $element): bool { return !in_array($element->localName, ['templateIf', 'templateElseIf', 'templateElse', 'templateCondition']); } @@ -108,7 +108,7 @@ protected function isElementFinal(DOMNode $element) * @param QtiComponent $component * @return bool */ - protected function isComponentFinal(QtiComponent $component) + protected function isComponentFinal(QtiComponent $component): bool { return (!$component instanceof TemplateIf && !$component instanceof TemplateElseIf && @@ -120,7 +120,7 @@ protected function isComponentFinal(QtiComponent $component) * @param DOMElement $element * @return array */ - protected function getChildrenElements(DOMElement $element) + protected function getChildrenElements(DOMElement $element): array { return $this->getChildElementsByTagName($element, [ 'templateIf', @@ -139,7 +139,7 @@ protected function getChildrenElements(DOMElement $element) * @param QtiComponent $component * @return array */ - protected function getChildrenComponents(QtiComponent $component) + protected function getChildrenComponents(QtiComponent $component): array { if ($component instanceof TemplateIf || $component instanceof TemplateElseIf || $component instanceof TemplateElse) { // TemplateControl @@ -164,7 +164,7 @@ protected function getChildrenComponents(QtiComponent $component) * @param DOMElement $currentNode * @return QtiComponentCollection|TemplateRuleCollection */ - protected function createCollection(DOMElement $currentNode) + protected function createCollection(DOMElement $currentNode): QtiComponentCollection { if ($currentNode->localName != 'templateCondition') { return new TemplateRuleCollection(); @@ -176,7 +176,7 @@ protected function createCollection(DOMElement $currentNode) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return ''; } diff --git a/src/qtism/data/storage/xml/marshalling/TemplateConstraintMarshaller.php b/src/qtism/data/storage/xml/marshalling/TemplateConstraintMarshaller.php index deab39292..7c0b03f5e 100644 --- a/src/qtism/data/storage/xml/marshalling/TemplateConstraintMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TemplateConstraintMarshaller.php @@ -41,7 +41,7 @@ class TemplateConstraintMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -55,11 +55,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI templateConstraint element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A TemplateConstraint object. + * @return TemplateConstraint A TemplateConstraint object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): TemplateConstraint { $expressionElt = self::getFirstChildElement($element); @@ -76,7 +76,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'templateConstraint'; } diff --git a/src/qtism/data/storage/xml/marshalling/TemplateControlMarshaller.php b/src/qtism/data/storage/xml/marshalling/TemplateControlMarshaller.php index 72b07bde1..d2fa8f896 100644 --- a/src/qtism/data/storage/xml/marshalling/TemplateControlMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TemplateControlMarshaller.php @@ -54,7 +54,7 @@ class TemplateControlMarshaller extends RecursiveMarshaller * @throws UnmarshallingException * @throws ReflectionException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $expressionElts = $this->getChildElementsByTagName($element, Expression::getExpressionClassNames()); @@ -86,7 +86,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -106,7 +106,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element * @param DOMNode $element * @return bool */ - protected function isElementFinal(DOMNode $element) + protected function isElementFinal(DOMNode $element): bool { return in_array($element->localName, array_merge([ 'setDefaultValue', @@ -121,7 +121,7 @@ protected function isElementFinal(DOMNode $element) * @param QtiComponent $component * @return bool */ - protected function isComponentFinal(QtiComponent $component) + protected function isComponentFinal(QtiComponent $component): bool { return ($component instanceof ExitTemplate || $component instanceof SetDefaultValue || @@ -134,7 +134,7 @@ protected function isComponentFinal(QtiComponent $component) * @param DOMElement $element * @return array */ - protected function getChildrenElements(DOMElement $element) + protected function getChildrenElements(DOMElement $element): array { return $this->getChildElementsByTagName($element, [ 'exitTemplate', @@ -150,7 +150,7 @@ protected function getChildrenElements(DOMElement $element) * @param QtiComponent $component * @return array */ - protected function getChildrenComponents(QtiComponent $component) + protected function getChildrenComponents(QtiComponent $component): array { return $component->getTemplateRules()->getArrayCopy(); } @@ -159,7 +159,7 @@ protected function getChildrenComponents(QtiComponent $component) * @param DOMElement $currentNode * @return TemplateRuleCollection */ - protected function createCollection(DOMElement $currentNode) + protected function createCollection(DOMElement $currentNode): TemplateRuleCollection { return new TemplateRuleCollection(); } @@ -167,7 +167,7 @@ protected function createCollection(DOMElement $currentNode) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return ''; } diff --git a/src/qtism/data/storage/xml/marshalling/TemplateDeclarationMarshaller.php b/src/qtism/data/storage/xml/marshalling/TemplateDeclarationMarshaller.php index 4d61a320e..9013a47e0 100644 --- a/src/qtism/data/storage/xml/marshalling/TemplateDeclarationMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TemplateDeclarationMarshaller.php @@ -42,7 +42,7 @@ class TemplateDeclarationMarshaller extends VariableDeclarationMarshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = parent::marshall($component); $version = $this->getVersion(); @@ -66,11 +66,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI templateDeclaration element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A TemplateDeclaration object. + * @return TemplateDeclaration A TemplateDeclaration object. * @throws UnmarshallingException * @throws MarshallerNotFoundException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): TemplateDeclaration { try { $baseComponent = parent::unmarshall($element); @@ -105,7 +105,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'templateDeclaration'; } diff --git a/src/qtism/data/storage/xml/marshalling/TemplateDefaultMarshaller.php b/src/qtism/data/storage/xml/marshalling/TemplateDefaultMarshaller.php index 50c7a29db..19d67bd41 100644 --- a/src/qtism/data/storage/xml/marshalling/TemplateDefaultMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TemplateDefaultMarshaller.php @@ -40,7 +40,7 @@ class TemplateDefaultMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -59,11 +59,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI templateDefault element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A templateDefault object. + * @return TemplateDefault A templateDefault object. * @throws MarshallerNotFoundException * @throws UnmarshallingException If the mandatory attribute 'templateIdentifier' is missing or has an unexpected number of expressions. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): TemplateDefault { if (($tplIdentifier = $this->getDOMElementAttributeAs($element, 'templateIdentifier')) !== null) { $expressionElt = self::getFirstChildElement($element); @@ -86,7 +86,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'templateDefault'; } diff --git a/src/qtism/data/storage/xml/marshalling/TemplateElementMarshaller.php b/src/qtism/data/storage/xml/marshalling/TemplateElementMarshaller.php index 054128f56..8de1a3a15 100644 --- a/src/qtism/data/storage/xml/marshalling/TemplateElementMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TemplateElementMarshaller.php @@ -43,7 +43,7 @@ class TemplateElementMarshaller extends ContentMarshaller * @return mixed * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): QtiComponent { $fqClass = $this->lookupClass($element); @@ -100,7 +100,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); $this->fillElement($element, $component); @@ -119,7 +119,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content"]; } diff --git a/src/qtism/data/storage/xml/marshalling/TemplateProcessingMarshaller.php b/src/qtism/data/storage/xml/marshalling/TemplateProcessingMarshaller.php index 365e924d9..4f5167f73 100644 --- a/src/qtism/data/storage/xml/marshalling/TemplateProcessingMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TemplateProcessingMarshaller.php @@ -42,7 +42,7 @@ class TemplateProcessingMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -57,11 +57,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI templateProcessing element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A TemplateProcessing object. + * @return TemplateProcessing A TemplateProcessing object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): TemplateProcessing { $childrenTagNames = ['exitTemplate', 'setCorrectResponse', 'setDefaultValue', 'setTemplateValue', 'templateCondition', 'templateConstraint']; $templateRuleElts = $this->getChildElementsByTagName($element, $childrenTagNames); @@ -82,7 +82,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'templateProcessing'; } diff --git a/src/qtism/data/storage/xml/marshalling/TemplateVariableMarshaller.php b/src/qtism/data/storage/xml/marshalling/TemplateVariableMarshaller.php index da66d3d28..540ee3340 100644 --- a/src/qtism/data/storage/xml/marshalling/TemplateVariableMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TemplateVariableMarshaller.php @@ -47,10 +47,10 @@ class TemplateVariableMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); - $element->setAttribute('identifier', $component->getIdentifier()); + $element->setAttribute('identifier', (string)$component->getIdentifier()); $element->setAttribute('cardinality', Cardinality::getNameByConstant($component->getCardinality())); if ($component->hasBaseType()) { @@ -74,11 +74,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI sessionIdentifier element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A QtiComponent object. + * @return ResultTemplateVariable A QtiComponent object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): ResultTemplateVariable { if (!$element->hasAttribute('identifier')) { throw new UnmarshallingException('TemplateVariable element must have identifier attribute', $element); @@ -120,7 +120,7 @@ protected function unmarshall(DOMElement $element) * * @return string A QTI class name or an empty string. */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'templateVariable'; } diff --git a/src/qtism/data/storage/xml/marshalling/TestFeedbackMarshaller.php b/src/qtism/data/storage/xml/marshalling/TestFeedbackMarshaller.php index d8e1f8aaa..2ccbcae9c 100644 --- a/src/qtism/data/storage/xml/marshalling/TestFeedbackMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TestFeedbackMarshaller.php @@ -46,7 +46,7 @@ class TestFeedbackMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $access = ($component->getAccess() == TestFeedbackAccess::AT_END) ? 'atEnd' : 'during'; @@ -74,11 +74,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI testFeedback element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A TestFeedback object. + * @return TestFeedback A TestFeedback object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): TestFeedback { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier', 'string')) !== null) { if (($outcomeIdentifier = $this->getDOMElementAttributeAs($element, 'outcomeIdentifier', 'string')) !== null) { @@ -132,7 +132,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'testFeedback'; } @@ -144,7 +144,7 @@ public function getExpectedQtiClassName() * @return string The content of the feedback element as a string. If there is no extractable content, an empty string is returned. * @throws InvalidArgumentException If $element is not a testFeedback element. */ - protected static function extractContent(DOMElement $element) + protected static function extractContent(DOMElement $element): string { if ($element->localName == 'testFeedback') { return preg_replace('##iu', '', $element->ownerDocument->saveXML($element)); diff --git a/src/qtism/data/storage/xml/marshalling/TestFeedbackRefMarshaller.php b/src/qtism/data/storage/xml/marshalling/TestFeedbackRefMarshaller.php index 8b48175b0..80b9a070b 100644 --- a/src/qtism/data/storage/xml/marshalling/TestFeedbackRefMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TestFeedbackRefMarshaller.php @@ -40,7 +40,7 @@ class TestFeedbackRefMarshaller extends Marshaller * @param QtiComponent $component * @return DOMElement */ - public function marshall(QtiComponent $component) + public function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -57,10 +57,10 @@ public function marshall(QtiComponent $component) * Unmarshall a DOMElement to its TestFeedbackRef data model representation. * * @param DOMElement $element - * @return QtiComponent A TestFeedbackRef object. + * @return TestFeedbackRef A TestFeedbackRef object. * @throws UnmarshallingException If the element cannot be unmarshalled. */ - public function unmarshall(DOMElement $element) + public function unmarshall(DOMElement $element): TestFeedbackRef { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { if (($href = $this->getDOMElementAttributeAs($element, 'href')) !== null) { @@ -96,7 +96,7 @@ public function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'testFeedbackRef'; } diff --git a/src/qtism/data/storage/xml/marshalling/TestPartMarshaller.php b/src/qtism/data/storage/xml/marshalling/TestPartMarshaller.php index e095b1ea0..46da3d9f0 100644 --- a/src/qtism/data/storage/xml/marshalling/TestPartMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TestPartMarshaller.php @@ -44,7 +44,7 @@ class TestPartMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -93,7 +93,7 @@ protected function marshall(QtiComponent $component) * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): TestPart { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { if (($navigationMode = $this->getDOMElementAttributeAs($element, 'navigationMode')) !== null) { @@ -179,7 +179,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'testPart'; } diff --git a/src/qtism/data/storage/xml/marshalling/TestResultMarshaller.php b/src/qtism/data/storage/xml/marshalling/TestResultMarshaller.php index 280530710..d9e81cc09 100644 --- a/src/qtism/data/storage/xml/marshalling/TestResultMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TestResultMarshaller.php @@ -46,11 +46,11 @@ class TestResultMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); - $element->setAttribute('identifier', $component->getIdentifier()); + $element->setAttribute('identifier', (string)$component->getIdentifier()); $datestamp = $component->getDatestamp()->format('c'); // ISO 8601 $element->setAttribute('datestamp', $datestamp); @@ -70,11 +70,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI sessionIdentifier element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A QtiComponent object. + * @return TestResult A QtiComponent object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): TestResult { if (!$element->hasAttribute('identifier')) { throw new UnmarshallingException('TestResult element must have identifier attribute', $element); @@ -117,7 +117,7 @@ protected function unmarshall(DOMElement $element) * * @return string A QTI class name or an empty string. */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'testResult'; } diff --git a/src/qtism/data/storage/xml/marshalling/TestVariablesMarshaller.php b/src/qtism/data/storage/xml/marshalling/TestVariablesMarshaller.php index 2c770f6d3..8876d1396 100644 --- a/src/qtism/data/storage/xml/marshalling/TestVariablesMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TestVariablesMarshaller.php @@ -39,7 +39,7 @@ class TestVariablesMarshaller extends ItemSubsetMarshaller * @param QtiComponent $component A TestVariable object. * @return DOMElement The corresponding testVariable QTI element. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = parent::marshall($component); @@ -62,10 +62,10 @@ protected function marshall(QtiComponent $component) * Marshall a testVariable QTI element in its TestVariable object equivalent. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent The corresponding TestVariable object. + * @return TestVariables The corresponding TestVariable object. * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): TestVariables { $baseComponent = parent::unmarshall($element); @@ -93,7 +93,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'testVariables'; } diff --git a/src/qtism/data/storage/xml/marshalling/TextInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/TextInteractionMarshaller.php index 973848349..0c2280b84 100644 --- a/src/qtism/data/storage/xml/marshalling/TextInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TextInteractionMarshaller.php @@ -43,7 +43,7 @@ class TextInteractionMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $version = $this->getVersion(); @@ -71,7 +71,7 @@ protected function marshall(QtiComponent $component) } if ($component->hasXmlBase() === true) { - self::setXmlBase($element, $component->setXmlBase()); + self::setXmlBase($element, $component->getXmlBase()); } if ($element->localName === 'extendedTextInteraction') { @@ -109,7 +109,7 @@ protected function marshall(QtiComponent $component) * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): QtiComponent { $version = $this->getVersion(); @@ -183,7 +183,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return ''; } diff --git a/src/qtism/data/storage/xml/marshalling/TextRunMarshaller.php b/src/qtism/data/storage/xml/marshalling/TextRunMarshaller.php index a9dbfba8a..e8fc5eab6 100644 --- a/src/qtism/data/storage/xml/marshalling/TextRunMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TextRunMarshaller.php @@ -39,7 +39,7 @@ class TextRunMarshaller extends Marshaller * @param QtiComponent $component A TextRun object. * @return DOMText The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMText { return static::getDOMCradle()->createTextNode($component->getContent()); } @@ -48,9 +48,9 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI textRun element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A TextRun object. + * @return TextRun A TextRun object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): TextRun { return new TextRun($element->nodeValue); } @@ -58,7 +58,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'textRun'; } diff --git a/src/qtism/data/storage/xml/marshalling/TimeLimitsMarshaller.php b/src/qtism/data/storage/xml/marshalling/TimeLimitsMarshaller.php index 6bbb74ff4..0b1f41481 100644 --- a/src/qtism/data/storage/xml/marshalling/TimeLimitsMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TimeLimitsMarshaller.php @@ -40,7 +40,7 @@ class TimeLimitsMarshaller extends Marshaller * @param QtiComponent $component A TimeLimits object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -61,9 +61,9 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI timeLimits element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A TimeLimits object. + * @return TimeLimits A TimeLimits object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): TimeLimits { $object = new TimeLimits(); @@ -85,7 +85,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'timeLimits'; } diff --git a/src/qtism/data/storage/xml/marshalling/TrMarshaller.php b/src/qtism/data/storage/xml/marshalling/TrMarshaller.php index cdc8a3b06..a99159196 100644 --- a/src/qtism/data/storage/xml/marshalling/TrMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/TrMarshaller.php @@ -41,7 +41,7 @@ class TrMarshaller extends ContentMarshaller * @return Tr * @throws UnmarshallingException */ - protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) + protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children): Tr { try { $component = new Tr(new TableCellCollection($children->getArrayCopy())); @@ -59,7 +59,7 @@ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentColl * @param array $elements * @return DOMElement */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) + protected function marshallChildrenKnown(QtiComponent $component, array $elements): DOMElement { $element = $this->createElement($component); @@ -72,7 +72,7 @@ protected function marshallChildrenKnown(QtiComponent $component, array $element return $element; } - protected function setLookupClasses() + protected function setLookupClasses(): void { $this->lookupClasses = ["qtism\\data\\content\\xhtml\\tables"]; } diff --git a/src/qtism/data/storage/xml/marshalling/UnmarshallingException.php b/src/qtism/data/storage/xml/marshalling/UnmarshallingException.php index 6cda6e50b..21113e246 100644 --- a/src/qtism/data/storage/xml/marshalling/UnmarshallingException.php +++ b/src/qtism/data/storage/xml/marshalling/UnmarshallingException.php @@ -73,7 +73,7 @@ public static function createFromInvalidArgumentException( * * @return DOMElement A DOMElement object. */ - public function getDOMElement() + public function getDOMElement(): DOMElement { return $this->DOMElement; } @@ -83,7 +83,7 @@ public function getDOMElement() * * @param DOMElement $element A DOMElement object. */ - protected function setDOMElement(DOMElement $element) + protected function setDOMElement(DOMElement $element): void { $this->DOMElement = $element; } diff --git a/src/qtism/data/storage/xml/marshalling/UploadInteractionMarshaller.php b/src/qtism/data/storage/xml/marshalling/UploadInteractionMarshaller.php index 1b9847d9c..c87e03a83 100644 --- a/src/qtism/data/storage/xml/marshalling/UploadInteractionMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/UploadInteractionMarshaller.php @@ -40,7 +40,7 @@ class UploadInteractionMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); $this->fillElement($element, $component); @@ -65,11 +65,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to an uploadInteraction element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent An UploadInteraction object. + * @return UploadInteraction An UploadInteraction object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): UploadInteraction { if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) { $component = new UploadInteraction($responseIdentifier); @@ -101,7 +101,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'uploadInteraction'; } diff --git a/src/qtism/data/storage/xml/marshalling/ValueMarshaller.php b/src/qtism/data/storage/xml/marshalling/ValueMarshaller.php index 422cb4d09..a5e42d745 100644 --- a/src/qtism/data/storage/xml/marshalling/ValueMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/ValueMarshaller.php @@ -50,7 +50,7 @@ class ValueMarshaller extends Marshaller * @param int $baseType A baseType from the BaseType enumeration. * @throws InvalidArgumentException If $baseType is not a value from the BaseType enumeration. */ - protected function setBaseType($baseType) + protected function setBaseType($baseType): void { if (in_array($baseType, BaseType::asArray()) || $baseType == -1) { $this->baseType = $baseType; @@ -66,7 +66,7 @@ protected function setBaseType($baseType) * * @return int A baseType from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -90,7 +90,7 @@ public function __construct($version, $baseType = -1) * @param QtiComponent $component A Value object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -114,10 +114,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI Value element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Value object. + * @return Value A Value object. * @throws UnmarshallingException If the 'baseType' attribute is not a valid QTI baseType. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Value { $object = null; @@ -160,7 +160,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'value'; } diff --git a/src/qtism/data/storage/xml/marshalling/VariableDeclarationMarshaller.php b/src/qtism/data/storage/xml/marshalling/VariableDeclarationMarshaller.php index 6bb935d57..9fa04696d 100644 --- a/src/qtism/data/storage/xml/marshalling/VariableDeclarationMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/VariableDeclarationMarshaller.php @@ -43,7 +43,7 @@ class VariableDeclarationMarshaller extends Marshaller * @throws MarshallerNotFoundException * @throws MarshallingException */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -68,11 +68,11 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI variableDeclaration element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A VariableDeclaration object. + * @return VariableDeclaration A VariableDeclaration object. * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): VariableDeclaration { try { // identifier is a mandatory value for the variableDeclaration element. @@ -114,7 +114,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'variableDeclaration'; } diff --git a/src/qtism/data/storage/xml/marshalling/VariableMappingMarshaller.php b/src/qtism/data/storage/xml/marshalling/VariableMappingMarshaller.php index 0aac9d57a..46b086106 100644 --- a/src/qtism/data/storage/xml/marshalling/VariableMappingMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/VariableMappingMarshaller.php @@ -39,7 +39,7 @@ class VariableMappingMarshaller extends Marshaller * @param QtiComponent $component A VariableMapping object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -53,10 +53,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI variableMapping element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A VariableMapping object. + * @return VariableMapping A VariableMapping object. * @throws UnmarshallingException If the mandatory attributes 'sourceIdentifier' or 'targetIdentifier' are missing from $element or are invalid. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): VariableMapping { if (($source = $this->getDOMElementAttributeAs($element, 'sourceIdentifier', 'string')) !== null) { if (($target = $this->getDOMElementAttributeAs($element, 'targetIdentifier', 'string')) !== null) { @@ -79,7 +79,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'variableMapping'; } diff --git a/src/qtism/data/storage/xml/marshalling/VariableMarshaller.php b/src/qtism/data/storage/xml/marshalling/VariableMarshaller.php index 6563c1ee9..e83d0e0a5 100644 --- a/src/qtism/data/storage/xml/marshalling/VariableMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/VariableMarshaller.php @@ -38,7 +38,7 @@ class VariableMarshaller extends Marshaller * @param QtiComponent $component A Variable object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -56,10 +56,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI Variable element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Variable object. + * @return Variable A Variable object. * @throws UnmarshallingException If the mandatory attribute 'identifier' is not set in $element. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Variable { if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier')) !== null) { $object = new Variable($identifier); @@ -78,7 +78,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'variable'; } diff --git a/src/qtism/data/storage/xml/marshalling/WeightMarshaller.php b/src/qtism/data/storage/xml/marshalling/WeightMarshaller.php index 485d9efd1..722a5620a 100644 --- a/src/qtism/data/storage/xml/marshalling/WeightMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/WeightMarshaller.php @@ -40,7 +40,7 @@ class WeightMarshaller extends Marshaller * @param QtiComponent $component A Weight object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { $element = $this->createElement($component); @@ -54,10 +54,10 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a QTI weight element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Weight object. + * @return Weight A Weight object. * @throws UnmarshallingException If the mandatory attributes 'identifier' or 'value' are missing from $element but also if 'value' cannot be converted to a float value or 'identifier' is not a valid QTI Identifier. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): Weight { // identifier is a mandatory value. if (($identifier = $this->getDOMElementAttributeAs($element, 'identifier', 'string')) !== null) { @@ -86,7 +86,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'weight'; } diff --git a/src/qtism/data/storage/xml/marshalling/XIncludeMarshaller.php b/src/qtism/data/storage/xml/marshalling/XIncludeMarshaller.php index 7935468ce..594e02a76 100644 --- a/src/qtism/data/storage/xml/marshalling/XIncludeMarshaller.php +++ b/src/qtism/data/storage/xml/marshalling/XIncludeMarshaller.php @@ -38,7 +38,7 @@ class XIncludeMarshaller extends Marshaller * @param QtiComponent $component An XInclude object. * @return DOMElement The according DOMElement object. */ - protected function marshall(QtiComponent $component) + protected function marshall(QtiComponent $component): DOMElement { return self::getDOMCradle()->importNode($component->getXml()->documentElement, true); } @@ -47,9 +47,9 @@ protected function marshall(QtiComponent $component) * Unmarshall a DOMElement object corresponding to a math element. * * @param DOMElement $element A DOMElement object. - * @return QtiComponent A Math object. + * @return XInclude A Math object. */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): XInclude { $node = $element->cloneNode(true); @@ -59,7 +59,7 @@ protected function unmarshall(DOMElement $element) /** * @return string */ - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { return 'include'; } diff --git a/src/qtism/data/storage/xml/versions/CompactVersion.php b/src/qtism/data/storage/xml/versions/CompactVersion.php index 227016460..127b5b8ca 100644 --- a/src/qtism/data/storage/xml/versions/CompactVersion.php +++ b/src/qtism/data/storage/xml/versions/CompactVersion.php @@ -30,7 +30,7 @@ */ class CompactVersion extends QtiVersion { - const SUPPORTED_VERSIONS = [ + public const SUPPORTED_VERSIONS = [ '2.1.0' => CompactVersion21::class, '2.1.1' => CompactVersion21::class, '2.2.0' => CompactVersion22::class, @@ -40,9 +40,9 @@ class CompactVersion extends QtiVersion '2.2.4' => CompactVersion22::class, ]; - const UNSUPPORTED_VERSION_MESSAGE = 'QTI Compact is not supported for version "%s".'; + public const UNSUPPORTED_VERSION_MESSAGE = 'QTI Compact is not supported for version "%s".'; - const INFERRED_VERSIONS = [ + public const INFERRED_VERSIONS = [ CompactVersion21::XMLNS => '2.1.0', CompactVersion22::XMLNS => '2.2.0', ]; diff --git a/src/qtism/data/storage/xml/versions/CompactVersion21.php b/src/qtism/data/storage/xml/versions/CompactVersion21.php index b5eee05c1..289490aed 100644 --- a/src/qtism/data/storage/xml/versions/CompactVersion21.php +++ b/src/qtism/data/storage/xml/versions/CompactVersion21.php @@ -30,11 +30,11 @@ */ class CompactVersion21 extends CompactVersion { - const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_v2p1'; + public const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_v2p1'; - const XSD = 'http://www.taotesting.com/xsd/qticompact_v2p1.xsd'; + public const XSD = 'http://www.taotesting.com/xsd/qticompact_v2p1.xsd'; - const LOCAL_XSD = 'qticompact_v2p1.xsd'; + public const LOCAL_XSD = 'qticompact_v2p1.xsd'; - const MARSHALLER_FACTORY = Compact21MarshallerFactory::class; + public const MARSHALLER_FACTORY = Compact21MarshallerFactory::class; } diff --git a/src/qtism/data/storage/xml/versions/CompactVersion22.php b/src/qtism/data/storage/xml/versions/CompactVersion22.php index 9e13e3736..218f466e2 100644 --- a/src/qtism/data/storage/xml/versions/CompactVersion22.php +++ b/src/qtism/data/storage/xml/versions/CompactVersion22.php @@ -30,11 +30,11 @@ */ class CompactVersion22 extends CompactVersion { - const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_v2p2'; + public const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_v2p2'; - const XSD = 'http://www.taotesting.com/xsd/qticompact_v2p2.xsd'; + public const XSD = 'http://www.taotesting.com/xsd/qticompact_v2p2.xsd'; - const LOCAL_XSD = 'qticompact_v2p2.xsd'; + public const LOCAL_XSD = 'qticompact_v2p2.xsd'; - const MARSHALLER_FACTORY = Compact22MarshallerFactory::class; + public const MARSHALLER_FACTORY = Compact22MarshallerFactory::class; } diff --git a/src/qtism/data/storage/xml/versions/QtiVersion.php b/src/qtism/data/storage/xml/versions/QtiVersion.php index 6808dffa1..93aa07fdc 100644 --- a/src/qtism/data/storage/xml/versions/QtiVersion.php +++ b/src/qtism/data/storage/xml/versions/QtiVersion.php @@ -36,7 +36,7 @@ */ class QtiVersion extends Version { - const SUPPORTED_VERSIONS = [ + public const SUPPORTED_VERSIONS = [ '2.0.0' => QtiVersion200::class, '2.1.0' => QtiVersion210::class, '2.1.1' => QtiVersion211::class, @@ -48,7 +48,7 @@ class QtiVersion extends Version '3.0.0' => QtiVersion300::class, ]; - const UNSUPPORTED_VERSION_MESSAGE = 'QTI version "%s" is not supported.'; + public const UNSUPPORTED_VERSION_MESSAGE = 'QTI version "%s" is not supported.'; /** @var string */ private $versionNumber; @@ -90,7 +90,7 @@ public static function create(string $versionNumber): self * @param string $version a semantic version * @throws InvalidArgumentException when the version is not supported. */ - protected static function checkVersion(string $version) + protected static function checkVersion(string $version): void { if (!isset(static::SUPPORTED_VERSIONS[$version])) { throw QtiVersionException::unsupportedVersion(static::UNSUPPORTED_VERSION_MESSAGE, $version, static::SUPPORTED_VERSIONS); diff --git a/src/qtism/data/storage/xml/versions/QtiVersion200.php b/src/qtism/data/storage/xml/versions/QtiVersion200.php index 51358c5bd..8460915ee 100644 --- a/src/qtism/data/storage/xml/versions/QtiVersion200.php +++ b/src/qtism/data/storage/xml/versions/QtiVersion200.php @@ -30,11 +30,11 @@ */ class QtiVersion200 extends QtiVersion { - const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_v2p0'; + public const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_v2p0'; - const XSD = 'http://www.imsglobal.org/xsd/imsqti_v2p0.xsd'; + public const XSD = 'http://www.imsglobal.org/xsd/imsqti_v2p0.xsd'; - const LOCAL_XSD = 'imsqti_v2p0.xsd'; + public const LOCAL_XSD = 'imsqti_v2p0.xsd'; - const MARSHALLER_FACTORY = Qti20MarshallerFactory::class; + public const MARSHALLER_FACTORY = Qti20MarshallerFactory::class; } diff --git a/src/qtism/data/storage/xml/versions/QtiVersion210.php b/src/qtism/data/storage/xml/versions/QtiVersion210.php index a08eea806..23da279ac 100644 --- a/src/qtism/data/storage/xml/versions/QtiVersion210.php +++ b/src/qtism/data/storage/xml/versions/QtiVersion210.php @@ -30,11 +30,11 @@ */ class QtiVersion210 extends QtiVersion { - const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_v2p1'; + public const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_v2p1'; - const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1.xsd'; + public const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1.xsd'; - const LOCAL_XSD = 'qtiv2p1/imsqti_v2p1.xsd'; + public const LOCAL_XSD = 'qtiv2p1/imsqti_v2p1.xsd'; - const MARSHALLER_FACTORY = Qti21MarshallerFactory::class; + public const MARSHALLER_FACTORY = Qti21MarshallerFactory::class; } diff --git a/src/qtism/data/storage/xml/versions/QtiVersion211.php b/src/qtism/data/storage/xml/versions/QtiVersion211.php index 45253f32b..5a491c745 100644 --- a/src/qtism/data/storage/xml/versions/QtiVersion211.php +++ b/src/qtism/data/storage/xml/versions/QtiVersion211.php @@ -30,9 +30,9 @@ */ class QtiVersion211 extends QtiVersion210 { - const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1p1.xsd'; + public const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1p1.xsd'; - const LOCAL_XSD = 'qtiv2p1p1/imsqti_v2p1p1.xsd'; + public const LOCAL_XSD = 'qtiv2p1p1/imsqti_v2p1p1.xsd'; - const MARSHALLER_FACTORY = Qti211MarshallerFactory::class; + public const MARSHALLER_FACTORY = Qti211MarshallerFactory::class; } diff --git a/src/qtism/data/storage/xml/versions/QtiVersion220.php b/src/qtism/data/storage/xml/versions/QtiVersion220.php index 003aabf76..77fedc42d 100644 --- a/src/qtism/data/storage/xml/versions/QtiVersion220.php +++ b/src/qtism/data/storage/xml/versions/QtiVersion220.php @@ -30,17 +30,17 @@ */ class QtiVersion220 extends QtiVersion { - const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_v2p2'; + public const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_v2p2'; - const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2.xsd'; + public const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2.xsd'; - const LOCAL_XSD = 'qtiv2p2/imsqti_v2p2.xsd'; + public const LOCAL_XSD = 'qtiv2p2/imsqti_v2p2.xsd'; - const QH5_NS = 'http://www.imsglobal.org/xsd/imsqtiv2p2_html5_v1p0'; + public const QH5_NS = 'http://www.imsglobal.org/xsd/imsqtiv2p2_html5_v1p0'; - const QH5_XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqtiv2p2p2_html5_v1p0.xsd'; + public const QH5_XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqtiv2p2p2_html5_v1p0.xsd'; - const MARSHALLER_FACTORY = Qti22MarshallerFactory::class; + public const MARSHALLER_FACTORY = Qti22MarshallerFactory::class; public function getExternalSchemaLocation(string $prefix): string { diff --git a/src/qtism/data/storage/xml/versions/QtiVersion221.php b/src/qtism/data/storage/xml/versions/QtiVersion221.php index 91addf23e..23e33e9b6 100644 --- a/src/qtism/data/storage/xml/versions/QtiVersion221.php +++ b/src/qtism/data/storage/xml/versions/QtiVersion221.php @@ -30,9 +30,9 @@ */ class QtiVersion221 extends QtiVersion220 { - const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p1.xsd'; + public const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p1.xsd'; - const LOCAL_XSD = 'qtiv2p2p1/imsqti_v2p2p1.xsd'; + public const LOCAL_XSD = 'qtiv2p2p1/imsqti_v2p2p1.xsd'; - const MARSHALLER_FACTORY = Qti221MarshallerFactory::class; + public const MARSHALLER_FACTORY = Qti221MarshallerFactory::class; } diff --git a/src/qtism/data/storage/xml/versions/QtiVersion222.php b/src/qtism/data/storage/xml/versions/QtiVersion222.php index 74132dd0e..6552365ea 100644 --- a/src/qtism/data/storage/xml/versions/QtiVersion222.php +++ b/src/qtism/data/storage/xml/versions/QtiVersion222.php @@ -30,9 +30,9 @@ */ class QtiVersion222 extends QtiVersion220 { - const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd'; + public const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd'; - const LOCAL_XSD = 'qtiv2p2p2/imsqti_v2p2p2.xsd'; + public const LOCAL_XSD = 'qtiv2p2p2/imsqti_v2p2p2.xsd'; - const MARSHALLER_FACTORY = Qti222MarshallerFactory::class; + public const MARSHALLER_FACTORY = Qti222MarshallerFactory::class; } diff --git a/src/qtism/data/storage/xml/versions/QtiVersion223.php b/src/qtism/data/storage/xml/versions/QtiVersion223.php index d372d78a3..6e72513e7 100644 --- a/src/qtism/data/storage/xml/versions/QtiVersion223.php +++ b/src/qtism/data/storage/xml/versions/QtiVersion223.php @@ -21,8 +21,6 @@ * @license GPLv2 */ -declare(strict_types=1); - namespace qtism\data\storage\xml\versions; use qtism\data\storage\xml\marshalling\Qti223MarshallerFactory; @@ -32,9 +30,9 @@ */ class QtiVersion223 extends QtiVersion220 { - const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p3.xsd'; + public const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p3.xsd'; - const LOCAL_XSD = 'qtiv2p2p3/imsqti_v2p2p3.xsd'; + public const LOCAL_XSD = 'qtiv2p2p3/imsqti_v2p2p3.xsd'; - const MARSHALLER_FACTORY = Qti223MarshallerFactory::class; + public const MARSHALLER_FACTORY = Qti223MarshallerFactory::class; } diff --git a/src/qtism/data/storage/xml/versions/QtiVersion224.php b/src/qtism/data/storage/xml/versions/QtiVersion224.php index d9102535d..3b35f72e7 100644 --- a/src/qtism/data/storage/xml/versions/QtiVersion224.php +++ b/src/qtism/data/storage/xml/versions/QtiVersion224.php @@ -21,8 +21,6 @@ * @license GPLv2 */ -declare(strict_types=1); - namespace qtism\data\storage\xml\versions; use qtism\data\storage\xml\marshalling\Qti224MarshallerFactory; @@ -32,9 +30,9 @@ */ class QtiVersion224 extends QtiVersion220 { - const XSD = 'https://purl.imsglobal.org/spec/qti/v2p2/schema/xsd/imsqti_v2p2p4.xsd'; + public const XSD = 'https://purl.imsglobal.org/spec/qti/v2p2/schema/xsd/imsqti_v2p2p4.xsd'; - const LOCAL_XSD = 'qtiv2p2p4/imsqti_v2p2p4.xsd'; + public const LOCAL_XSD = 'qtiv2p2p4/imsqti_v2p2p4.xsd'; - const MARSHALLER_FACTORY = Qti224MarshallerFactory::class; + public const MARSHALLER_FACTORY = Qti224MarshallerFactory::class; } diff --git a/src/qtism/data/storage/xml/versions/QtiVersion300.php b/src/qtism/data/storage/xml/versions/QtiVersion300.php index 90f66786b..7101ce3f8 100644 --- a/src/qtism/data/storage/xml/versions/QtiVersion300.php +++ b/src/qtism/data/storage/xml/versions/QtiVersion300.php @@ -32,11 +32,11 @@ */ class QtiVersion300 extends QtiVersion { - const XMLNS = 'http://www.imsglobal.org/xsd/imsaqti_item_v1p0'; + public const XMLNS = 'http://www.imsglobal.org/xsd/imsaqti_item_v1p0'; - const XSD = 'http://www.imsglobal.org/xsd/qti/aqtiv1p0/imsaqti_itemv1p0_v1p0.xsd'; + public const XSD = 'http://www.imsglobal.org/xsd/qti/aqtiv1p0/imsaqti_itemv1p0_v1p0.xsd'; - const LOCAL_XSD = 'aqtiv1p0/imsaqti_itemv1p0_v1p0.xsd'; + public const LOCAL_XSD = 'aqtiv1p0/imsaqti_itemv1p0_v1p0.xsd'; - const MARSHALLER_FACTORY = Qti30MarshallerFactory::class; + public const MARSHALLER_FACTORY = Qti30MarshallerFactory::class; } diff --git a/src/qtism/data/storage/xml/versions/ResultVersion.php b/src/qtism/data/storage/xml/versions/ResultVersion.php index e25cb0f6b..ef8b7ba94 100644 --- a/src/qtism/data/storage/xml/versions/ResultVersion.php +++ b/src/qtism/data/storage/xml/versions/ResultVersion.php @@ -30,7 +30,7 @@ */ class ResultVersion extends QtiVersion { - const SUPPORTED_VERSIONS = [ + public const SUPPORTED_VERSIONS = [ '2.1.0' => ResultVersion21::class, '2.1.1' => ResultVersion21::class, '2.2.0' => ResultVersion22::class, @@ -40,9 +40,9 @@ class ResultVersion extends QtiVersion '2.2.4' => ResultVersion22::class, ]; - const UNSUPPORTED_VERSION_MESSAGE = 'QTI Result Report is not supported for version "%s".'; + public const UNSUPPORTED_VERSION_MESSAGE = 'QTI Result Report is not supported for version "%s".'; - const INFERRED_VERSIONS = [ + public const INFERRED_VERSIONS = [ ResultVersion21::XMLNS => '2.1.0', ResultVersion22::XMLNS => '2.2.0', ]; diff --git a/src/qtism/data/storage/xml/versions/ResultVersion21.php b/src/qtism/data/storage/xml/versions/ResultVersion21.php index 869f51e78..6d6282e4a 100644 --- a/src/qtism/data/storage/xml/versions/ResultVersion21.php +++ b/src/qtism/data/storage/xml/versions/ResultVersion21.php @@ -30,11 +30,11 @@ */ class ResultVersion21 extends ResultVersion { - const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_result_v2p1'; + public const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_result_v2p1'; - const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_result_v2p1.xsd'; + public const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_result_v2p1.xsd'; - const LOCAL_XSD = 'qtiv2p1/imsqti_result_v2p1.xsd'; + public const LOCAL_XSD = 'qtiv2p1/imsqti_result_v2p1.xsd'; - const MARSHALLER_FACTORY = Qti21MarshallerFactory::class; + public const MARSHALLER_FACTORY = Qti21MarshallerFactory::class; } diff --git a/src/qtism/data/storage/xml/versions/ResultVersion22.php b/src/qtism/data/storage/xml/versions/ResultVersion22.php index 536fb2c6a..50311f65e 100644 --- a/src/qtism/data/storage/xml/versions/ResultVersion22.php +++ b/src/qtism/data/storage/xml/versions/ResultVersion22.php @@ -30,11 +30,11 @@ */ class ResultVersion22 extends ResultVersion { - const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_result_v2p2'; + public const XMLNS = 'http://www.imsglobal.org/xsd/imsqti_result_v2p2'; - const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_result_v2p2.xsd'; + public const XSD = 'http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_result_v2p2.xsd'; - const LOCAL_XSD = 'qtiv2p2/imsqti_result_v2p2.xsd'; + public const LOCAL_XSD = 'qtiv2p2/imsqti_result_v2p2.xsd'; - const MARSHALLER_FACTORY = Qti22MarshallerFactory::class; + public const MARSHALLER_FACTORY = Qti22MarshallerFactory::class; } diff --git a/src/qtism/runtime/common/AbstractEngine.php b/src/qtism/runtime/common/AbstractEngine.php index ffa8ea71a..7ed29f9ca 100644 --- a/src/qtism/runtime/common/AbstractEngine.php +++ b/src/qtism/runtime/common/AbstractEngine.php @@ -71,7 +71,7 @@ public function __construct(QtiComponent $component, State $context = null) * * @param QtiComponent $component A QtiComponent object. */ - public function setComponent(QtiComponent $component) + public function setComponent(QtiComponent $component): void { $this->component = $component; } @@ -81,7 +81,7 @@ public function setComponent(QtiComponent $component) * * @return QtiComponent A QtiComponent object. */ - public function getComponent() + public function getComponent(): QtiComponent { return $this->component; } @@ -91,7 +91,7 @@ public function getComponent() * * @param State $context A State object representing the execution context. */ - public function setContext(State $context) + public function setContext(State $context): void { $this->context = $context; } @@ -101,7 +101,7 @@ public function setContext(State $context) * * @return State A State object representing the execution context. */ - public function getContext() + public function getContext(): State { return $this->context; } @@ -112,7 +112,7 @@ public function getContext() * * @param StackTrace $stackTrace A StackTrace object. */ - protected function setStackTrace(StackTrace $stackTrace) + protected function setStackTrace(StackTrace $stackTrace): void { $this->stackTrace = $stackTrace; } @@ -123,7 +123,7 @@ protected function setStackTrace(StackTrace $stackTrace) * * @return StackTrace A StackTrace object. */ - public function getStackTrace() + public function getStackTrace(): StackTrace { return $this->stackTrace; } @@ -134,7 +134,7 @@ public function getStackTrace() * * @param string $message A trace message. */ - protected function trace($message) + protected function trace($message): void { $item = new StackTraceItem($this->getComponent(), $message); $this->stackTrace->push($item); diff --git a/src/qtism/runtime/common/Container.php b/src/qtism/runtime/common/Container.php index 23ce8bfed..2b8a1fc86 100644 --- a/src/qtism/runtime/common/Container.php +++ b/src/qtism/runtime/common/Container.php @@ -81,7 +81,7 @@ public function __construct(array $array = []) /** * @param mixed $value */ - protected function checkType($value) + protected function checkType($value): void { if (!RuntimeUtils::isRuntimeCompliant($value)) { RuntimeUtils::throwTypingError($value); @@ -95,7 +95,7 @@ protected function checkType($value) * * @return bool Whether the container has to be considered as NULL. */ - public function isNull() + public function isNull(): bool { $data = $this->getDataPlaceHolder(); return empty($data); @@ -106,7 +106,7 @@ public function isNull() * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::MULTIPLE; } @@ -122,7 +122,7 @@ public function getCardinality() * @param mixed $obj A value to compare to this one. * @return bool Whether the container is equal to $obj. */ - public function equals($obj) + public function equals($obj): bool { if (is_object($obj) && $obj instanceof static && count($obj) === count($this)) { foreach (array_keys($this->getDataPlaceHolder()) as $key) { @@ -151,7 +151,7 @@ public function equals($obj) * @param mixed $obj The object you want to find the number of occurences in the container. * @return int A number of occurences. */ - public function occurences($obj) + public function occurences($obj): int { $occurences = 0; @@ -183,7 +183,7 @@ public function occurences($obj) * @return Container A Container object populated with the values found in $valueCollection. * @throws InvalidArgumentException If a value from $valueCollection is not compliant with the QTI Runtime Model or the container type. */ - public static function createFromDataModel(ValueCollection $valueCollection) + public static function createFromDataModel(ValueCollection $valueCollection): Container { $container = new static(); foreach ($valueCollection as $value) { @@ -202,7 +202,7 @@ public static function createFromDataModel(ValueCollection $valueCollection) * * @return array An array with two entries which are respectively to character lower and upper bounds. */ - protected function getToStringBounds() + protected function getToStringBounds(): array { return ['[', ']']; } @@ -212,7 +212,7 @@ protected function getToStringBounds() * * @return string */ - public function __toString() + public function __toString(): string { $bounds = $this->getToStringBounds(); $data = &$this->getDataPlaceHolder(); @@ -256,7 +256,7 @@ public function __toString() * * @return Container */ - public function distinct() + public function distinct(): Container { $container = clone $this; $newDataPlaceHolder = []; diff --git a/src/qtism/runtime/common/MultipleContainer.php b/src/qtism/runtime/common/MultipleContainer.php index 5ce02c823..5b4a02e3d 100644 --- a/src/qtism/runtime/common/MultipleContainer.php +++ b/src/qtism/runtime/common/MultipleContainer.php @@ -66,7 +66,7 @@ public function __construct($baseType, array $array = []) * @param int $baseType A value from the BaseType enumeration. * @throws InvalidArgumentException If $baseType is not a value from the BaseType enumeration. */ - protected function setBaseType($baseType) + protected function setBaseType($baseType): void { if (in_array($baseType, BaseType::asArray(), true)) { $this->baseType = $baseType; @@ -81,7 +81,7 @@ protected function setBaseType($baseType) * * @return int A value from the BaseType enumeration or -1. */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -89,7 +89,7 @@ public function getBaseType() /** * @param mixed $value */ - protected function checkType($value) + protected function checkType($value): void { parent::checkType($value); @@ -106,7 +106,7 @@ protected function checkType($value) * @return MultipleContainer A MultipleContainer object populated with the values found in $valueCollection. * @throws InvalidArgumentException If a value from $valueCollection is not compliant with the QTI Runtime Model or the container type. */ - public static function createFromDataModel(ValueCollection $valueCollection, $baseType = BaseType::INTEGER) + public static function createFromDataModel(ValueCollection $valueCollection, $baseType = BaseType::INTEGER): MultipleContainer { $container = new static($baseType); foreach ($valueCollection as $value) { @@ -119,7 +119,7 @@ public static function createFromDataModel(ValueCollection $valueCollection, $ba /** * @return array */ - protected function getToStringBounds() + protected function getToStringBounds(): array { return ['[', ']']; } @@ -127,7 +127,7 @@ protected function getToStringBounds() /** * @return int */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::MULTIPLE; } diff --git a/src/qtism/runtime/common/OrderedContainer.php b/src/qtism/runtime/common/OrderedContainer.php index f4d83b28a..c028b9eb2 100644 --- a/src/qtism/runtime/common/OrderedContainer.php +++ b/src/qtism/runtime/common/OrderedContainer.php @@ -38,7 +38,7 @@ class OrderedContainer extends MultipleContainer implements QtiDatatype * @param mixed $obj * @return bool */ - public function equals($obj) + public function equals($obj): bool { $countA = count($this); @@ -69,7 +69,7 @@ public function equals($obj) /** * @return int */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::ORDERED; } @@ -77,7 +77,7 @@ public function getCardinality() /** * @return array */ - protected function getToStringBounds() + protected function getToStringBounds(): array { return ['<', '>']; } diff --git a/src/qtism/runtime/common/OutcomeVariable.php b/src/qtism/runtime/common/OutcomeVariable.php index 6516b8c13..d8d4840c8 100644 --- a/src/qtism/runtime/common/OutcomeVariable.php +++ b/src/qtism/runtime/common/OutcomeVariable.php @@ -94,7 +94,7 @@ public function __construct($identifier, $cardinality, $baseType = -1, QtiDataty * * @return ViewCollection */ - public function getViews() + public function getViews(): ?ViewCollection { return $this->views; } @@ -104,7 +104,7 @@ public function getViews() * * @param ViewCollection $views */ - public function setViews(ViewCollection $views) + public function setViews(ViewCollection $views): void { $this->views = $views; } @@ -115,7 +115,7 @@ public function setViews(ViewCollection $views) * @param float|bool $normalMaximum The normal maximum or false if not defined. * @throws InvalidArgumentException If $normalMaximum is not false nor a floating point value. */ - public function setNormalMaximum($normalMaximum) + public function setNormalMaximum($normalMaximum): void { if ((is_bool($normalMaximum) && $normalMaximum === false) || is_float($normalMaximum)) { $this->normalMaximum = $normalMaximum; @@ -141,7 +141,7 @@ public function getNormalMaximum() * @param float|bool $normalMinimum The normal minimum or false if not defined. * @throws InvalidArgumentException If $normalMinimum is not false nor a floating point value. */ - public function setNormalMinimum($normalMinimum) + public function setNormalMinimum($normalMinimum): void { if ((is_bool($normalMinimum) && $normalMinimum === false) || is_float($normalMinimum)) { $this->normalMinimum = $normalMinimum; @@ -156,6 +156,7 @@ public function setNormalMinimum($normalMinimum) * * @return bool|float|double False if not defined, otherwise a floating point value. */ + #[\ReturnTypeWillChange] public function getNormalMinimum() { return $this->normalMinimum; @@ -167,7 +168,7 @@ public function getNormalMinimum() * @param float|double|bool $masteryValue A floating point value or false if not defined. * @throws InvalidArgumentException If $masteryValue is not a floating point value nor false. */ - public function setMasteryValue($masteryValue) + public function setMasteryValue($masteryValue): void { if ((is_bool($masteryValue) && $masteryValue === false) || is_float($masteryValue)) { $this->masteryValue = $masteryValue; @@ -182,6 +183,7 @@ public function setMasteryValue($masteryValue) * * @return float|double|bool False if not defined, otherwise a floating point value. */ + #[\ReturnTypeWillChange] public function getMasteryValue() { return $this->masteryValue; @@ -192,7 +194,7 @@ public function getMasteryValue() * * @param LookupTable $lookupTable A QTI Data Model LookupTable object or null if not specified. */ - public function setLookupTable(LookupTable $lookupTable = null) + public function setLookupTable(LookupTable $lookupTable = null): void { $this->lookupTable = $lookupTable; } @@ -202,7 +204,7 @@ public function setLookupTable(LookupTable $lookupTable = null) * * @return LookupTable A QTI Data Model LookupTable object or null if not defined. */ - public function getLookupTable() + public function getLookupTable(): ?LookupTable { return $this->lookupTable; } @@ -214,7 +216,7 @@ public function getLookupTable() * @return OutcomeVariable * @throws InvalidArgumentException */ - public static function createFromDataModel(VariableDeclaration $variableDeclaration) + public static function createFromDataModel(VariableDeclaration $variableDeclaration): self { $variable = parent::createFromDataModel($variableDeclaration); @@ -238,7 +240,7 @@ public static function createFromDataModel(VariableDeclaration $variableDeclarat * If no default value is described, and the cardinality is single and the baseType * is integer or float, the value of the variable becomes 0. */ - public function applyDefaultValue() + public function applyDefaultValue(): void { parent::applyDefaultValue(); diff --git a/src/qtism/runtime/common/Processable.php b/src/qtism/runtime/common/Processable.php index a406673a7..bd9b2031e 100644 --- a/src/qtism/runtime/common/Processable.php +++ b/src/qtism/runtime/common/Processable.php @@ -33,5 +33,6 @@ interface Processable * * @throws ProcessingException If an error occurs while processing something. */ + #[\ReturnTypeWillChange] public function process(); } diff --git a/src/qtism/runtime/common/ProcessingException.php b/src/qtism/runtime/common/ProcessingException.php index cffcd21a4..e73430708 100644 --- a/src/qtism/runtime/common/ProcessingException.php +++ b/src/qtism/runtime/common/ProcessingException.php @@ -37,7 +37,7 @@ class ProcessingException extends RuntimeException * * @var int */ - const UNKNOWN = 0; + public const UNKNOWN = 0; /** * Code to use when a runtime error occcurs. @@ -46,14 +46,14 @@ class ProcessingException extends RuntimeException * * @var int */ - const RUNTIME_ERROR = 1; + public const RUNTIME_ERROR = 1; /** * Code to use when a requested variable does not exist or is not set. * * @var int */ - const NONEXISTENT_VARIABLE = 2; + public const NONEXISTENT_VARIABLE = 2; /** * Code to use when a variable has not the expected type. @@ -63,7 +63,7 @@ class ProcessingException extends RuntimeException * * @var int */ - const WRONG_VARIABLE_TYPE = 3; + public const WRONG_VARIABLE_TYPE = 3; /** * Code to use when a variable has not the expected baseType. @@ -73,7 +73,7 @@ class ProcessingException extends RuntimeException * * @var int */ - const WRONG_VARIABLE_BASETYPE = 4; + public const WRONG_VARIABLE_BASETYPE = 4; /** * Code to use when a variable is inconsistent. @@ -83,7 +83,7 @@ class ProcessingException extends RuntimeException * * @var int */ - const INCONSISTENT_VARIABLE = 5; + public const INCONSISTENT_VARIABLE = 5; /** * Code to use when a processor encounters an internal logic error. @@ -92,14 +92,14 @@ class ProcessingException extends RuntimeException * * @var int */ - const LOGIC_ERROR = 6; + public const LOGIC_ERROR = 6; /** * Code to use when a variable has not the expected cardinality. * * @var int */ - const WRONG_VARIABLE_CARDINALITY = 7; + public const WRONG_VARIABLE_CARDINALITY = 7; private $source = null; @@ -122,7 +122,7 @@ public function __construct($msg, Processable $source, $code = 0, Exception $pre * * @param Processable $source The Processable object whithin the error occurred. */ - protected function setSource(Processable $source) + protected function setSource(Processable $source): void { $this->source = $source; } @@ -132,7 +132,7 @@ protected function setSource(Processable $source) * * @return Processable The Processable object within the error occurred. */ - public function getSource() + public function getSource(): Processable { return $this->source; } diff --git a/src/qtism/runtime/common/ProcessorFactory.php b/src/qtism/runtime/common/ProcessorFactory.php index 2ff894f6b..b2b33924e 100644 --- a/src/qtism/runtime/common/ProcessorFactory.php +++ b/src/qtism/runtime/common/ProcessorFactory.php @@ -37,5 +37,5 @@ interface ProcessorFactory * @param QtiComponent $component A QtiComponent object that the returned Processable object is able to process. * @return Processable A Processable object able to process $component. */ - public function createProcessor(QtiComponent $component); + public function createProcessor(QtiComponent $component): Processable; } diff --git a/src/qtism/runtime/common/RecordContainer.php b/src/qtism/runtime/common/RecordContainer.php index f30c91450..e5d9e6dfa 100644 --- a/src/qtism/runtime/common/RecordContainer.php +++ b/src/qtism/runtime/common/RecordContainer.php @@ -68,7 +68,7 @@ public function __construct(array $array = []) /** * @return int */ - public function getCardinality() + public function getCardinality(): int { return Cardinality::RECORD; } @@ -82,7 +82,7 @@ public function getCardinality() * * @throws RuntimeException If $offset is not a string. */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_string($offset)) { $this->checkType($value); @@ -101,7 +101,7 @@ public function offsetSet($offset, $value) * @return RecordContainer A Container object populated with the values found in $valueCollection. * @throws InvalidArgumentException If a value from $valueCollection is not compliant with the QTI Runtime Model or the container type or if a value has no fieldIdentifier. */ - public static function createFromDataModel(ValueCollection $valueCollection) + public static function createFromDataModel(ValueCollection $valueCollection): RecordContainer { $container = new static(); foreach ($valueCollection as $value) { @@ -122,7 +122,7 @@ public static function createFromDataModel(ValueCollection $valueCollection) /** * @return array */ - protected function getToStringBounds() + protected function getToStringBounds(): array { return ['{', '}']; } @@ -130,7 +130,7 @@ protected function getToStringBounds() /** * @return int */ - public function getBaseType() + public function getBaseType(): int { return -1; } diff --git a/src/qtism/runtime/common/ResponseVariable.php b/src/qtism/runtime/common/ResponseVariable.php index 30eb021aa..6b9ca7be7 100644 --- a/src/qtism/runtime/common/ResponseVariable.php +++ b/src/qtism/runtime/common/ResponseVariable.php @@ -90,7 +90,7 @@ public function __construct($identifier, $cardinality, $baseType = -1, QtiDataty * @param QtiDatatype|null $correctResponse A QtiDatatype object or null. * @throws InvalidArgumentException If $correctResponse does not match baseType and/or cardinality of the variable. */ - public function setCorrectResponse(QtiDatatype $correctResponse = null) + public function setCorrectResponse(QtiDatatype $correctResponse = null): void { if ($correctResponse !== null && (!Utils::isBaseTypeCompliant($this->getBaseType(), $correctResponse) @@ -109,7 +109,7 @@ public function setCorrectResponse(QtiDatatype $correctResponse = null) * * @return QtiDatatype|null A QTI Runtime value (primitive or container). */ - public function getCorrectResponse() + public function getCorrectResponse(): ?QtiDatatype { return $this->correctResponse; } @@ -119,7 +119,7 @@ public function getCorrectResponse() * * @return bool */ - public function hasCorrectResponse() + public function hasCorrectResponse(): bool { return $this->getCorrectResponse() !== null; } @@ -129,7 +129,7 @@ public function hasCorrectResponse() * * @param Mapping $mapping A Mapping object from the QTI Data Model. */ - public function setMapping(Mapping $mapping = null) + public function setMapping(Mapping $mapping = null): void { $this->mapping = $mapping; } @@ -139,7 +139,7 @@ public function setMapping(Mapping $mapping = null) * * @return Mapping A mapping object from the QTI Data Model. */ - public function getMapping() + public function getMapping(): ?Mapping { return $this->mapping; } @@ -149,7 +149,7 @@ public function getMapping() * * @param AreaMapping $areaMapping An AreaMapping object from the QTI Data Model. */ - public function setAreaMapping(AreaMapping $areaMapping = null) + public function setAreaMapping(AreaMapping $areaMapping = null): void { $this->areaMapping = $areaMapping; } @@ -159,7 +159,7 @@ public function setAreaMapping(AreaMapping $areaMapping = null) * * @return AreaMapping An AreaMapping object from the QTI Data Model. */ - public function getAreaMapping() + public function getAreaMapping(): ?AreaMapping { return $this->areaMapping; } @@ -170,7 +170,7 @@ public function getAreaMapping() * * @return bool */ - public function isCorrect() + public function isCorrect(): bool { if ($this->hasCorrectResponse() === true) { $correctResponse = $this->getCorrectResponse(); @@ -192,7 +192,7 @@ public function isCorrect() * @return ResponseVariable * @throws InvalidArgumentException */ - public static function createFromDataModel(VariableDeclaration $variableDeclaration) + public static function createFromDataModel(VariableDeclaration $variableDeclaration): ResponseVariable { $variable = parent::createFromDataModel($variableDeclaration); diff --git a/src/qtism/runtime/common/StackTrace.php b/src/qtism/runtime/common/StackTrace.php index e4c67a744..2bee73e69 100644 --- a/src/qtism/runtime/common/StackTrace.php +++ b/src/qtism/runtime/common/StackTrace.php @@ -37,7 +37,7 @@ class StackTrace extends AbstractCollection implements Stack * * @return StackTraceItem|null A StackTraceItem object or null if there is nothing to pop. */ - public function pop() + public function pop(): ?StackTraceItem { $data = &$this->getDataPlaceHolder(); return array_pop($data); @@ -49,7 +49,7 @@ public function pop() * @param StackTraceItem $value A StackTraceItem object. * @throws InvalidArgumentException If $value is not a StackTraceItem object. */ - public function push($value) + public function push($value): void { $this->checkType($value); $data = &$this->getDataPlaceHolder(); @@ -59,7 +59,7 @@ public function push($value) /** * @param mixed $value */ - public function checkType($value) + public function checkType($value): void { if (!$value instanceof StackTraceItem) { $msg = 'The StackTrace class only accepts to store StackTraceItem objects.'; @@ -72,7 +72,7 @@ public function checkType($value) * * @return string */ - public function __toString() + public function __toString(): string { $str = ''; $data = &$this->getDataPlaceHolder(); diff --git a/src/qtism/runtime/common/StackTraceItem.php b/src/qtism/runtime/common/StackTraceItem.php index c9af4e4df..1ab420bcd 100644 --- a/src/qtism/runtime/common/StackTraceItem.php +++ b/src/qtism/runtime/common/StackTraceItem.php @@ -66,7 +66,7 @@ public function __construct(QtiComponent $component, $traceMessage) * * @param QtiComponent $component A traced QtiComponent object. */ - public function setComponent(QtiComponent $component) + public function setComponent(QtiComponent $component): void { $this->component = $component; } @@ -76,7 +76,7 @@ public function setComponent(QtiComponent $component) * * @return QtiComponent A traced QtiComponent object. */ - public function getComponent() + public function getComponent(): QtiComponent { return $this->component; } @@ -86,7 +86,7 @@ public function getComponent() * * @return string A human-readable message. */ - public function getTraceMessage() + public function getTraceMessage(): string { return $this->traceMessage; } @@ -97,7 +97,7 @@ public function getTraceMessage() * @param string $traceMessage A human-readable message. * @throws InvalidArgumentException If $traceMessage is not a string. */ - public function setTraceMessage($traceMessage) + public function setTraceMessage($traceMessage): void { if (is_string($traceMessage)) { $this->traceMessage = $traceMessage; diff --git a/src/qtism/runtime/common/State.php b/src/qtism/runtime/common/State.php index 6448f01ab..7ae03019a 100644 --- a/src/qtism/runtime/common/State.php +++ b/src/qtism/runtime/common/State.php @@ -61,7 +61,7 @@ public function __construct(array $array = []) * * @param Variable $variable */ - public function setVariable(Variable $variable) + public function setVariable(Variable $variable): void { $this->checkType($variable); $data = &$this->getDataPlaceHolder(); @@ -72,9 +72,9 @@ public function setVariable(Variable $variable) * Get a variable with the identifier $variableIdentifier. * * @param string $variableIdentifier A QTI identifier. - * @return Variable A Variable object or null if the $variableIdentifier does not match any Variable object stored in the State. + * @return Variable|null A Variable object or null if the $variableIdentifier does not match any Variable object stored in the State. */ - public function getVariable($variableIdentifier) + public function getVariable($variableIdentifier): ?Variable { $data = &$this->getDataPlaceHolder(); return $data[$variableIdentifier] ?? null; @@ -85,7 +85,7 @@ public function getVariable($variableIdentifier) * * @return VariableCollection A collection of Variable objects. */ - public function getAllVariables() + public function getAllVariables(): VariableCollection { return new VariableCollection($this->getDataPlaceHolder()); } @@ -98,7 +98,7 @@ public function getAllVariables() * @throws InvalidArgumentException If $variable is not a string nor a Variable object. * @throws OutOfBoundsException If no variable in the current state matches $variable. */ - public function unsetVariable($variable) + public function unsetVariable($variable): void { $data = &$this->getDataPlaceHolder(); @@ -123,7 +123,7 @@ public function unsetVariable($variable) * @param string $offset * @param mixed $value */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (is_string($offset) && empty($offset) === false) { $placeholder = &$this->getDataPlaceHolder(); @@ -144,6 +144,7 @@ public function offsetSet($offset, $value) * @param string $offset * @return mixed|null */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { if (is_string($offset) && $offset !== '') { @@ -164,7 +165,7 @@ public function offsetGet($offset) * * @param bool $preserveBuiltIn Whether the built-in outcome variable 'completionStatus' should be preserved. */ - public function resetOutcomeVariables($preserveBuiltIn = true) + public function resetOutcomeVariables($preserveBuiltIn = true): void { $data = &$this->getDataPlaceHolder(); @@ -184,7 +185,7 @@ public function resetOutcomeVariables($preserveBuiltIn = true) * * @return void */ - public function resetTemplateVariables() + public function resetTemplateVariables(): void { $data = &$this->getDataPlaceHolder(); @@ -204,7 +205,7 @@ public function resetTemplateVariables() * * @return bool */ - public function containsNullOnly() + public function containsNullOnly(): bool { $data = $this->getDataPlaceHolder(); @@ -224,7 +225,7 @@ public function containsNullOnly() * * @return bool */ - public function containsValuesEqualToVariableDefaultOnly() + public function containsValuesEqualToVariableDefaultOnly(): bool { $data = $this->getDataPlaceHolder(); @@ -247,7 +248,7 @@ public function containsValuesEqualToVariableDefaultOnly() /** * @param mixed $value */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Variable) { $msg = 'A State object stores Variable objects only.'; diff --git a/src/qtism/runtime/common/TemplateVariable.php b/src/qtism/runtime/common/TemplateVariable.php index 16777384b..fa2124aee 100644 --- a/src/qtism/runtime/common/TemplateVariable.php +++ b/src/qtism/runtime/common/TemplateVariable.php @@ -79,7 +79,7 @@ public function __construct($identifier, $cardinality, $baseType = -1, $value = * @param bool $paramVariable * @throws InvalidArgumentException */ - public function setParamVariable($paramVariable) + public function setParamVariable($paramVariable): void { if (is_bool($paramVariable)) { $this->paramVariable = $paramVariable; @@ -95,7 +95,7 @@ public function setParamVariable($paramVariable) * * @return bool */ - public function isParamVariable() + public function isParamVariable(): bool { return $this->paramVariable; } @@ -107,7 +107,7 @@ public function isParamVariable() * @param bool $mathVariable * @throws InvalidArgumentException */ - public function setMathVariable($mathVariable) + public function setMathVariable($mathVariable): void { if (is_bool($mathVariable)) { $this->mathVariable = $mathVariable; @@ -123,7 +123,7 @@ public function setMathVariable($mathVariable) * * @return bool */ - public function isMathVariable() + public function isMathVariable(): bool { return $this->mathVariable; } @@ -135,7 +135,7 @@ public function isMathVariable() * @return TemplateVariable * @throws InvalidArgumentException */ - public static function createFromDataModel(VariableDeclaration $variableDeclaration) + public static function createFromDataModel(VariableDeclaration $variableDeclaration): self { $variable = parent::createFromDataModel($variableDeclaration); diff --git a/src/qtism/runtime/common/Utils.php b/src/qtism/runtime/common/Utils.php index fe3874ada..686e730e1 100644 --- a/src/qtism/runtime/common/Utils.php +++ b/src/qtism/runtime/common/Utils.php @@ -30,6 +30,8 @@ use qtism\common\datatypes\QtiIdentifier; use qtism\common\datatypes\QtiInteger; use qtism\common\datatypes\QtiIntOrIdentifier; +use qtism\common\datatypes\QtiPair; +use qtism\common\datatypes\QtiPoint; use qtism\common\datatypes\QtiScalar; use qtism\common\datatypes\QtiString; use qtism\common\datatypes\QtiUri; @@ -47,7 +49,7 @@ class Utils * @param mixed $value A value you want to check the compatibility with the QTI runtime model. * @return bool */ - public static function isRuntimeCompliant($value) + public static function isRuntimeCompliant($value): bool { return $value === null || $value instanceof QtiDatatype; } @@ -59,7 +61,7 @@ public static function isRuntimeCompliant($value) * @param mixed $value A value. * @return bool */ - public static function isBaseTypeCompliant($baseType, $value) + public static function isBaseTypeCompliant($baseType, $value): bool { return $value === null || ( @@ -75,7 +77,7 @@ public static function isBaseTypeCompliant($baseType, $value) * @param mixed $value * @return bool */ - public static function isCardinalityCompliant($cardinality, $value) + public static function isCardinalityCompliant($cardinality, $value): bool { return $value === null || ( @@ -90,7 +92,7 @@ public static function isCardinalityCompliant($cardinality, $value) * @param mixed $value A given PHP primitive value. * @throws InvalidArgumentException In any case. */ - public static function throwTypingError($value) + public static function throwTypingError($value): void { $acceptedTypes = [ 'Null', @@ -124,7 +126,7 @@ public static function throwTypingError($value) * @param mixed $value A given PHP primitive value. * @throws InvalidArgumentException In any case. */ - public static function throwBaseTypeTypingError($baseType, $value) + public static function throwBaseTypeTypingError($baseType, $value): void { $givenValue = (is_object($value)) ? get_class($value) : gettype($value) . ':' . $value; $acceptedTypes = BaseType::getNameByConstant($baseType); @@ -176,7 +178,7 @@ public static function inferCardinality($value) * @param string $string A string value. * @return bool Whether the given $string is a valid variable identifier. */ - public static function isValidVariableIdentifier($string) + public static function isValidVariableIdentifier($string): bool { if (!is_string($string) || empty($string)) { return false; @@ -193,7 +195,7 @@ public static function isValidVariableIdentifier($string) * @param array $floatArray An array containing float values. * @return array An array containing integer values. */ - public static function floatArrayToInteger($floatArray) + public static function floatArrayToInteger($floatArray): array { $integerArray = []; foreach ($floatArray as $f) { @@ -209,7 +211,7 @@ public static function floatArrayToInteger($floatArray) * @param array $integerArray An array containing integer values. * @return array An array containing float values. */ - public static function integerArrayToFloat($integerArray) + public static function integerArrayToFloat($integerArray): array { $floatArray = []; foreach ($integerArray as $i) { @@ -224,8 +226,10 @@ public static function integerArrayToFloat($integerArray) * * @param mixed|null $v * @param int $baseType A value from the BaseType enumeration. - * @return QtiScalar + * + * @return QtiScalar|QtiPoint|QtiPair */ + #[\ReturnTypeWillChange] public static function valueToRuntime($v, $baseType) { if ($v !== null) { @@ -265,7 +269,7 @@ public static function valueToRuntime($v, $baseType) * @param QtiDatatype $value * @return bool */ - public static function isNull(QtiDatatype $value = null) + public static function isNull(QtiDatatype $value = null): bool { return $value === null || ($value instanceof QtiString && $value->getValue() === '') @@ -284,7 +288,7 @@ public static function isNull(QtiDatatype $value = null) * @param QtiDatatype $b * @return bool */ - public static function equals(QtiDatatype $a = null, QtiDatatype $b = null) + public static function equals(QtiDatatype $a = null, QtiDatatype $b = null): bool { return ($a === null ? $b === null : $a->equals($b)); } diff --git a/src/qtism/runtime/common/Variable.php b/src/qtism/runtime/common/Variable.php index f41945621..baa7ca9d5 100644 --- a/src/qtism/runtime/common/Variable.php +++ b/src/qtism/runtime/common/Variable.php @@ -109,7 +109,7 @@ public function __construct($identifier, $cardinality, $baseType = -1, QtiDataty * * If the variable is supposed to contain a Container (Multiple, Ordered or Record cardinality), the variable's value becomes an empty container. * * If the variable is scalar (Cardinality single), the value becomes NULL. */ - public function initialize() + public function initialize(): void { if ($this->cardinality === Cardinality::MULTIPLE) { $value = new MultipleContainer($this->baseType); @@ -129,7 +129,7 @@ public function initialize() * * @return string An identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -139,7 +139,7 @@ public function getIdentifier() * * @param string $identifier An identifier. */ - public function setIdentifier($identifier) + public function setIdentifier($identifier): void { $this->identifier = $identifier; } @@ -149,7 +149,7 @@ public function setIdentifier($identifier) * * @return int A value from the Cardinality enumeration. */ - public function getCardinality() + public function getCardinality(): int { return $this->cardinality; } @@ -159,7 +159,7 @@ public function getCardinality() * * @param int $cardinality A value from the Cardinality enumeration. */ - public function setCardinality($cardinality) + public function setCardinality($cardinality): void { $this->cardinality = $cardinality; } @@ -169,7 +169,7 @@ public function setCardinality($cardinality) * * @return int A value from the BaseType enumeration. */ - public function getBaseType() + public function getBaseType(): int { return $this->baseType; } @@ -180,7 +180,7 @@ public function getBaseType() * @param int $baseType A value from the Cardinality enumeration or -1 if there is no baseType in a Cardinality::RECORD context. * @throws InvalidArgumentException If -1 is passed but Cardinality::RECORD is not set. */ - public function setBaseType($baseType) + public function setBaseType($baseType): void { if ($baseType === -1 && $this->isRecord() === false) { $msg = 'You are forced to specify a baseType if cardinality is not RECORD.'; @@ -195,7 +195,7 @@ public function setBaseType($baseType) * * @return QtiDatatype A QtiDatatype object or null. */ - public function getValue() + public function getValue(): ?QtiDatatype { return $this->value; } @@ -224,7 +224,7 @@ public function setValue(QtiDatatype $value = null): void * * @return QtiDatatype|null A QtiDatatype object or null. */ - public function getDefaultValue() + public function getDefaultValue(): ?QtiDatatype { return $this->defaultValue; } @@ -236,7 +236,7 @@ public function getDefaultValue() * @throws InvalidArgumentException If $defaultValue's type is not * compliant with the qti:baseType of the Variable. */ - public function setDefaultValue(QtiDatatype $defaultValue = null) + public function setDefaultValue(QtiDatatype $defaultValue = null): void { if (!Utils::isBaseTypeCompliant($this->getBaseType(), $defaultValue) || !Utils::isCardinalityCompliant($this->getCardinality(), $defaultValue)) { Utils::throwBaseTypeTypingError($this->getBaseType(), $defaultValue); @@ -252,7 +252,7 @@ public function setDefaultValue(QtiDatatype $defaultValue = null) * @return Variable A Variable object. * @throws UnexpectedValueException If $variableDeclaration is not consistent. */ - public static function createFromDataModel(VariableDeclaration $variableDeclaration) + public static function createFromDataModel(VariableDeclaration $variableDeclaration): self { $identifier = $variableDeclaration->getIdentifier(); $baseType = $variableDeclaration->getBaseType(); @@ -281,6 +281,7 @@ public static function createFromDataModel(VariableDeclaration $variableDeclarat * @return mixed The resulting QTI Runtime value (primitive or container depending on baseType/cardinality). * @throws UnexpectedValueException If $baseType or/and $cardinality are not respected by the Value objects in the ValueCollection. */ + #[\ReturnTypeWillChange] protected static function dataModelValuesToRuntime(ValueCollection $valueCollection, $baseType, $cardinality) { // Cardinality? @@ -332,7 +333,7 @@ public function isInitializedFromDefaultValue(): bool * * @return bool */ - public function isSingle() + public function isSingle(): bool { return $this->cardinality === Cardinality::SINGLE; } @@ -344,7 +345,7 @@ public function isSingle() * * @return bool Returns true in case of the cardinality is Multiple or Ordered. Otherwise the method returns false. */ - public function isMultiple() + public function isMultiple(): bool { return $this->cardinality === Cardinality::MULTIPLE || $this->cardinality === Cardinality::ORDERED; } @@ -356,7 +357,7 @@ public function isMultiple() * * @return bool */ - public function isOrdered() + public function isOrdered(): bool { return $this->cardinality === Cardinality::ORDERED; } @@ -368,7 +369,7 @@ public function isOrdered() * * @return bool */ - public function isRecord() + public function isRecord(): bool { return $this->cardinality === Cardinality::RECORD; } @@ -381,7 +382,7 @@ public function isRecord() * * @return bool */ - public function isNumeric() + public function isNumeric(): bool { return ($this->IsNull()) ? false : ($this->baseType === BaseType::INTEGER || $this->baseType === BaseType::FLOAT); } @@ -398,7 +399,7 @@ public function isNumeric() * * @return bool */ - public function isNull() + public function isNull(): bool { $value = $this->getValue(); // Containers as per QTI Spec, are considered to be NULL if empty. @@ -419,7 +420,7 @@ public function isNull() * * @return bool */ - public function isBool() + public function isBool(): bool { return (!$this->isNull() && $this->getBaseType() === BaseType::BOOLEAN); } @@ -432,7 +433,7 @@ public function isBool() * * @return bool */ - public function isInteger() + public function isInteger(): bool { return (!$this->isNull() && $this->getBaseType() === BaseType::INTEGER); } @@ -445,7 +446,7 @@ public function isInteger() * * @return boolean */ - public function isFile() + public function isFile(): bool { return (!$this->isNull() && $this->getBaseType() === BaseType::FILE); } @@ -458,7 +459,7 @@ public function isFile() * * @return bool */ - public function isFloat() + public function isFloat(): bool { return (!$this->isNull() && $this->getBaseType() === BaseType::FLOAT); } @@ -471,7 +472,7 @@ public function isFloat() * * @return bool */ - public function isPoint() + public function isPoint(): bool { return (!$this->isNull() && $this->getBaseType() === BaseType::POINT); } @@ -486,7 +487,7 @@ public function isPoint() * * @return bool */ - public function isPair() + public function isPair(): bool { return (!$this->isNull() && ($this->getBaseType() === BaseType::PAIR @@ -503,7 +504,7 @@ public function isPair() * * @return bool */ - public function isDirectedPair() + public function isDirectedPair(): bool { return (!$this->isNull() && $this->getBaseType() === BaseType::DIRECTED_PAIR); } @@ -516,7 +517,7 @@ public function isDirectedPair() * * @return bool */ - public function isDuration() + public function isDuration(): bool { return (!$this->isNull() && $this->getBaseType() === BaseType::DURATION); } @@ -529,7 +530,7 @@ public function isDuration() * * @return bool */ - public function isString() + public function isString(): bool { return (!$this->isNull() && $this->getBaseType() === BaseType::STRING); } @@ -541,7 +542,7 @@ public function isString() * * @return ValueCollection */ - public function getDataModelValues() + public function getDataModelValues(): ValueCollection { if ($this->getValue() === null) { return new ValueCollection(); @@ -618,7 +619,7 @@ private function createRecordNullValue(): Value * Set the value of the Variable with its default value. If no default * value was given, the value of the variable becomes NULL. */ - public function applyDefaultValue() + public function applyDefaultValue(): void { $this->setValue($this->getDefaultValue()); $this->isInitializedFromDefaultValue = true; diff --git a/src/qtism/runtime/common/VariableCollection.php b/src/qtism/runtime/common/VariableCollection.php index a05fd9690..846112660 100644 --- a/src/qtism/runtime/common/VariableCollection.php +++ b/src/qtism/runtime/common/VariableCollection.php @@ -37,7 +37,7 @@ class VariableCollection extends AbstractCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a Variable object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Variable) { $msg = "The VariableCollection class only accept Variable objects, '${value}' given."; diff --git a/src/qtism/runtime/common/VariableFactory.php b/src/qtism/runtime/common/VariableFactory.php index ca76bf21f..59f329b24 100644 --- a/src/qtism/runtime/common/VariableFactory.php +++ b/src/qtism/runtime/common/VariableFactory.php @@ -21,8 +21,6 @@ * @license GPLv2 */ -declare(strict_types=1); - namespace qtism\runtime\common; use qtism\data\state\OutcomeDeclaration; diff --git a/src/qtism/runtime/common/VariableFactoryInterface.php b/src/qtism/runtime/common/VariableFactoryInterface.php index de616aedd..da1d92fa7 100644 --- a/src/qtism/runtime/common/VariableFactoryInterface.php +++ b/src/qtism/runtime/common/VariableFactoryInterface.php @@ -21,8 +21,6 @@ * @license GPLv2 */ -declare(strict_types=1); - namespace qtism\runtime\common; use UnexpectedValueException; diff --git a/src/qtism/runtime/common/VariableIdentifier.php b/src/qtism/runtime/common/VariableIdentifier.php index bde87404a..a12a3595a 100644 --- a/src/qtism/runtime/common/VariableIdentifier.php +++ b/src/qtism/runtime/common/VariableIdentifier.php @@ -117,7 +117,7 @@ public function __construct($identifier) * @param string $identifier A prefixed identifier. * @throws InvalidArgumentException If $identifier is not a valid prefixed identifier. */ - protected function setIdentifier($identifier) + protected function setIdentifier($identifier): void { if (Utils::isValidVariableIdentifier($identifier)) { $this->identifier = $identifier; @@ -132,7 +132,7 @@ protected function setIdentifier($identifier) * * @return string A prefixed identifier. */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } @@ -142,7 +142,7 @@ public function getIdentifier() * * @param int $sequenceNumber A integer sequence number. */ - protected function setSequenceNumber($sequenceNumber) + protected function setSequenceNumber($sequenceNumber): void { $this->sequenceNumber = $sequenceNumber; } @@ -153,7 +153,7 @@ protected function setSequenceNumber($sequenceNumber) * * @return int A strictly positive sequence number if there is a sequence number in the identifier, otherwise zero. */ - public function getSequenceNumber() + public function getSequenceNumber(): int { return $this->sequenceNumber; } @@ -163,7 +163,7 @@ public function getSequenceNumber() * * @return bool */ - public function hasSequenceNumber() + public function hasSequenceNumber(): bool { return $this->getSequenceNumber() > 0; } @@ -173,7 +173,7 @@ public function hasSequenceNumber() * * @param string $variableName A variable name. */ - protected function setVariableName($variableName) + protected function setVariableName($variableName): void { $this->variableName = $variableName; } @@ -183,7 +183,7 @@ protected function setVariableName($variableName) * * @return string */ - public function getVariableName() + public function getVariableName(): string { return $this->variableName; } @@ -193,7 +193,7 @@ public function getVariableName() * * @param string $prefix The prefix of the variable identifier. */ - protected function setPrefix($prefix) + protected function setPrefix($prefix): void { $this->prefix = $prefix; } @@ -206,7 +206,7 @@ protected function setPrefix($prefix) * * @return string The detected variable identifier prefix or an empty string if there is no prefix in the identifier. */ - public function getPrefix() + public function getPrefix(): string { return $this->prefix; } @@ -216,7 +216,7 @@ public function getPrefix() * * @return bool */ - public function hasPrefix() + public function hasPrefix(): bool { return $this->getPrefix() !== ''; } @@ -232,7 +232,7 @@ public function hasPrefix() * * @return string The stringified VariableIdentifier object. */ - public function __toString() + public function __toString(): string { if ($this->hasSequenceNumber() === true) { return $this->getPrefix() . '.' . $this->getSequenceNumber() . '.' . $this->getVariableName(); diff --git a/src/qtism/runtime/expressions/BaseValueProcessor.php b/src/qtism/runtime/expressions/BaseValueProcessor.php index c263a1964..0d80b21ef 100644 --- a/src/qtism/runtime/expressions/BaseValueProcessor.php +++ b/src/qtism/runtime/expressions/BaseValueProcessor.php @@ -40,6 +40,7 @@ class BaseValueProcessor extends ExpressionProcessor * * @return mixed A QTI Runtime compliant scalar value. */ + #[\ReturnTypeWillChange] public function process() { $expression = $this->getExpression(); @@ -50,7 +51,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return BaseValue::class; } diff --git a/src/qtism/runtime/expressions/CorrectProcessor.php b/src/qtism/runtime/expressions/CorrectProcessor.php index 26a98798b..362b6e440 100644 --- a/src/qtism/runtime/expressions/CorrectProcessor.php +++ b/src/qtism/runtime/expressions/CorrectProcessor.php @@ -52,6 +52,7 @@ class CorrectProcessor extends ExpressionProcessor * @return mixed A QTI Runtime compliant value or null. * @throws ExpressionProcessingException */ + #[\ReturnTypeWillChange] public function process() { $expr = $this->getExpression(); @@ -73,7 +74,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Correct::class; } diff --git a/src/qtism/runtime/expressions/DefaultProcessor.php b/src/qtism/runtime/expressions/DefaultProcessor.php index e55738ff3..24d5f3df2 100644 --- a/src/qtism/runtime/expressions/DefaultProcessor.php +++ b/src/qtism/runtime/expressions/DefaultProcessor.php @@ -44,6 +44,7 @@ class DefaultProcessor extends ExpressionProcessor * * @return mixed A QTI Runtime compliant value. */ + #[\ReturnTypeWillChange] public function process() { $expr = $this->getExpression(); @@ -57,7 +58,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return DefaultVal::class; } diff --git a/src/qtism/runtime/expressions/ExpressionEngine.php b/src/qtism/runtime/expressions/ExpressionEngine.php index 3ddb18124..0009529f6 100644 --- a/src/qtism/runtime/expressions/ExpressionEngine.php +++ b/src/qtism/runtime/expressions/ExpressionEngine.php @@ -100,7 +100,7 @@ public function __construct(QtiComponent $expression, State $context = null) * @param QtiComponent $expression An Expression object. * @throws InvalidArgumentException If $expression is not an Expression object. */ - public function setComponent(QtiComponent $expression) + public function setComponent(QtiComponent $expression): void { if ($expression instanceof Expression) { parent::setComponent($expression); @@ -115,7 +115,7 @@ public function setComponent(QtiComponent $expression) * * @param ExpressionProcessorFactory $expressionProcessorFactory An ExpressionProcessorFactory object. */ - public function setExpressionProcessorFactory(ExpressionProcessorFactory $expressionProcessorFactory) + public function setExpressionProcessorFactory(ExpressionProcessorFactory $expressionProcessorFactory): void { $this->expressionProcessorFactory = $expressionProcessorFactory; } @@ -125,7 +125,7 @@ public function setExpressionProcessorFactory(ExpressionProcessorFactory $expres * * @param OperatorProcessorFactory $operatorProcessorFactory An OperatorProcessorFactory object. */ - public function setOperatorProcessorFactory(OperatorProcessorFactory $operatorProcessorFactory) + public function setOperatorProcessorFactory(OperatorProcessorFactory $operatorProcessorFactory): void { $this->operatorProcessorFactory = $operatorProcessorFactory; } @@ -135,7 +135,7 @@ public function setOperatorProcessorFactory(OperatorProcessorFactory $operatorPr * * @param OperandsCollection $operands An OperandsCo */ - protected function setOperands(OperandsCollection $operands) + protected function setOperands(OperandsCollection $operands): void { $this->operands = $operands; } @@ -145,7 +145,7 @@ protected function setOperands(OperandsCollection $operands) * * @param Expression|ExpressionCollection $expression An Expression/ExpressionCollection object to be pushed on top of the trail stack. */ - protected function pushTrail($expression) + protected function pushTrail($expression): void { if ($expression instanceof Expression) { array_push($this->trail, $expression); @@ -164,7 +164,7 @@ protected function pushTrail($expression) * * @return Expression $expression The Expression object at the top of the trail stack. */ - protected function popTrail() + protected function popTrail(): Expression { return array_pop($this->trail); } @@ -174,7 +174,7 @@ protected function popTrail() * * @return array A reference on the trail stack. */ - protected function &getTrail() + protected function &getTrail(): array { return $this->trail; } @@ -184,7 +184,7 @@ protected function &getTrail() * * @param Expression $expression An explored Expression object. */ - protected function mark(Expression $expression) + protected function mark(Expression $expression): void { array_push($this->marker, $expression); } @@ -195,7 +195,7 @@ protected function mark(Expression $expression) * @param Expression $expression An Expression object. * @return bool Whether $expression is marked as explored. */ - protected function isMarked(Expression $expression) + protected function isMarked(Expression $expression): bool { return in_array($expression, $this->marker, true); } @@ -264,7 +264,7 @@ public function process() * @param ExpressionProcessor $processor The processor that undertook the processing. * @param mixed $result The result of the processing. */ - protected function traceExpression(ExpressionProcessor $processor, $result) + protected function traceExpression(ExpressionProcessor $processor, $result): void { $qtiClassName = $processor->getExpression()->getQtiClassName(); $this->trace("${qtiClassName} [${result}]"); @@ -276,12 +276,12 @@ protected function traceExpression(ExpressionProcessor $processor, $result) * @param OperatorProcessor $processor The processor that undertook the processing. * @param mixed $result The result of the processing. */ - protected function traceOperator(OperatorProcessor $processor, $result) + protected function traceOperator(OperatorProcessor $processor, $result): void { $stringOperands = []; foreach ($processor->getOperands() as $operand) { - $stringOperands[] = '' . $operand; + $stringOperands[] = (string)$operand; } $qtiClassName = $processor->getExpression()->getQtiClassName(); diff --git a/src/qtism/runtime/expressions/ExpressionProcessingException.php b/src/qtism/runtime/expressions/ExpressionProcessingException.php index f0c13ecdc..79bad0d87 100644 --- a/src/qtism/runtime/expressions/ExpressionProcessingException.php +++ b/src/qtism/runtime/expressions/ExpressionProcessingException.php @@ -38,7 +38,7 @@ class ExpressionProcessingException extends ProcessingException * @param Processable $source The source of the error. * @throws InvalidArgumentException If $source is not an ExpressionProcessor object. */ - public function setSource(Processable $source) + public function setSource(Processable $source): void { if ($source instanceof ExpressionProcessor) { parent::setSource($source); diff --git a/src/qtism/runtime/expressions/ExpressionProcessor.php b/src/qtism/runtime/expressions/ExpressionProcessor.php index 4a2b0a2cf..83d1baf46 100644 --- a/src/qtism/runtime/expressions/ExpressionProcessor.php +++ b/src/qtism/runtime/expressions/ExpressionProcessor.php @@ -66,7 +66,7 @@ public function __construct(Expression $expression) * @param Expression $expression A QTI Data Model Expression object. * @throws InvalidArgumentException If $expression is not a subclass nor implements the Expression type returned by the getExpressionType method. */ - public function setExpression(Expression $expression) + public function setExpression(Expression $expression): void { $expectedType = $this->getExpressionType(); @@ -88,7 +88,7 @@ public function setExpression(Expression $expression) * * @return Expression A QTI Data Model Expression object. */ - public function getExpression() + public function getExpression(): Expression { return $this->expression; } @@ -98,7 +98,7 @@ public function getExpression() * * @param State $state A State object. */ - public function setState(State $state) + public function setState(State $state): void { $this->state = $state; } @@ -108,7 +108,7 @@ public function setState(State $state) * * @return State */ - public function getState() + public function getState(): State { return $this->state; } @@ -119,5 +119,5 @@ public function getState() * * @return string A Fully Qualified PHP Class Name (FQCN). */ - abstract protected function getExpressionType(); + abstract protected function getExpressionType(): string; } diff --git a/src/qtism/runtime/expressions/ExpressionProcessorFactory.php b/src/qtism/runtime/expressions/ExpressionProcessorFactory.php index e0519876a..dd177d327 100644 --- a/src/qtism/runtime/expressions/ExpressionProcessorFactory.php +++ b/src/qtism/runtime/expressions/ExpressionProcessorFactory.php @@ -50,7 +50,7 @@ public function __construct() * @return Processable The related ExpressionProcessor object. * @throws RuntimeException If no ExpressionProcessor can be found for the given $expression. */ - public function createProcessor(QtiComponent $expression) + public function createProcessor(QtiComponent $expression): Processable { $qtiClassName = ucfirst($expression->getQtiClassName()); $nsPackage = 'qtism\\runtime\\expressions\\'; diff --git a/src/qtism/runtime/expressions/ItemSubsetProcessor.php b/src/qtism/runtime/expressions/ItemSubsetProcessor.php index 43be45a4f..7b7006a33 100644 --- a/src/qtism/runtime/expressions/ItemSubsetProcessor.php +++ b/src/qtism/runtime/expressions/ItemSubsetProcessor.php @@ -62,7 +62,7 @@ abstract class ItemSubsetProcessor extends ExpressionProcessor * * @return string A section identifier. If no sectionIdentifier attribute was specified, an empty string ('') is returned. */ - protected function getSectionIdentifier() + protected function getSectionIdentifier(): string { return $this->getExpression()->getSectionIdentifier(); } @@ -73,7 +73,7 @@ protected function getSectionIdentifier() * * @return IdentifierCollection A collection of category identifiers or NULL if no categories to be included were specified. */ - protected function getIncludeCategories() + protected function getIncludeCategories(): ?IdentifierCollection { $categories = $this->getExpression()->getIncludeCategories(); @@ -86,7 +86,7 @@ protected function getIncludeCategories() * * @return IdentifierCollection A collection of category identifiers or NULL if no categories to be excluded were specified. */ - protected function getExcludeCategories() + protected function getExcludeCategories(): ?IdentifierCollection { $categories = $this->getExpression()->getExcludeCategories(); @@ -123,7 +123,7 @@ protected static function getMappedVariableIdentifier(AssessmentItemRef $assessm * * @return AssessmentItemRefCollection A collection of AssessmentItemRef object that match the criteria expressed by the ItemSubset expression to be processed. */ - protected function getItemSubset() + protected function getItemSubset(): AssessmentItemRefCollection { $sectionIdentifier = $this->getSectionIdentifier(); $includeCategories = $this->getIncludeCategories(); diff --git a/src/qtism/runtime/expressions/MapResponsePointProcessor.php b/src/qtism/runtime/expressions/MapResponsePointProcessor.php index 2cf7c2593..0a9da923f 100644 --- a/src/qtism/runtime/expressions/MapResponsePointProcessor.php +++ b/src/qtism/runtime/expressions/MapResponsePointProcessor.php @@ -57,7 +57,7 @@ class MapResponsePointProcessor extends ExpressionProcessor * @return QtiFloat A transformed float value according to the areaMapping of the target variable. * @throws ExpressionProcessingException */ - public function process() + public function process(): QtiFloat { $expr = $this->getExpression(); $identifier = $expr->getIdentifier(); @@ -133,7 +133,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return MapResponsePoint::class; } diff --git a/src/qtism/runtime/expressions/MapResponseProcessor.php b/src/qtism/runtime/expressions/MapResponseProcessor.php index 0a1f8f33a..46e433b1a 100644 --- a/src/qtism/runtime/expressions/MapResponseProcessor.php +++ b/src/qtism/runtime/expressions/MapResponseProcessor.php @@ -62,7 +62,7 @@ class MapResponseProcessor extends ExpressionProcessor * @return QtiFloat a QTI float value. * @throws ExpressionProcessingException */ - public function process() + public function process(): QtiFloat { $expr = $this->getExpression(); $state = $this->getState(); @@ -169,7 +169,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return MapResponse::class; } diff --git a/src/qtism/runtime/expressions/MathConstantProcessor.php b/src/qtism/runtime/expressions/MathConstantProcessor.php index 8d4cde13e..b8ab6dab2 100644 --- a/src/qtism/runtime/expressions/MathConstantProcessor.php +++ b/src/qtism/runtime/expressions/MathConstantProcessor.php @@ -41,7 +41,7 @@ class MathConstantProcessor extends ExpressionProcessor * * @return QtiFloat A float value (e or pi). */ - public function process() + public function process(): QtiFloat { $expr = $this->getExpression(); if ($expr->getName() === MathEnumeration::E) { @@ -54,7 +54,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return MathConstant::class; } diff --git a/src/qtism/runtime/expressions/NullProcessor.php b/src/qtism/runtime/expressions/NullProcessor.php index fdafdb6b6..9fdcfd58a 100644 --- a/src/qtism/runtime/expressions/NullProcessor.php +++ b/src/qtism/runtime/expressions/NullProcessor.php @@ -48,7 +48,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return NullValue::class; } diff --git a/src/qtism/runtime/expressions/NumberCorrectProcessor.php b/src/qtism/runtime/expressions/NumberCorrectProcessor.php index c6ffc2d39..23f014f60 100644 --- a/src/qtism/runtime/expressions/NumberCorrectProcessor.php +++ b/src/qtism/runtime/expressions/NumberCorrectProcessor.php @@ -45,7 +45,7 @@ class NumberCorrectProcessor extends ItemSubsetProcessor * @return QtiInteger The number of items of the given sub-set for which all the response variables match their associated correct response. * @throws ExpressionProcessingException */ - public function process() + public function process(): QtiInteger { $testSession = $this->getState(); $itemSubset = $this->getItemSubset(); @@ -69,7 +69,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return NumberCorrect::class; } diff --git a/src/qtism/runtime/expressions/NumberIncorrectProcessor.php b/src/qtism/runtime/expressions/NumberIncorrectProcessor.php index 845335a43..2274c7858 100644 --- a/src/qtism/runtime/expressions/NumberIncorrectProcessor.php +++ b/src/qtism/runtime/expressions/NumberIncorrectProcessor.php @@ -46,7 +46,7 @@ class NumberIncorrectProcessor extends ItemSubsetProcessor * @return QtiInteger The number of items in the given sub-set for which at least one of the defined response does not match its associated correct response. * @throws ExpressionProcessingException */ - public function process() + public function process(): QtiInteger { $testSession = $this->getState(); $itemSubset = $this->getItemSubset(); @@ -70,7 +70,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return NumberIncorrect::class; } diff --git a/src/qtism/runtime/expressions/NumberPresentedProcessor.php b/src/qtism/runtime/expressions/NumberPresentedProcessor.php index b35316c64..d54b5ff5f 100644 --- a/src/qtism/runtime/expressions/NumberPresentedProcessor.php +++ b/src/qtism/runtime/expressions/NumberPresentedProcessor.php @@ -45,7 +45,7 @@ class NumberPresentedProcessor extends ItemSubsetProcessor * @return QtiInteger The number of items in the given item sub-set that have been attempted (at least once). * @throws ExpressionProcessingException */ - public function process() + public function process(): QtiInteger { $testSession = $this->getState(); $itemSubset = $this->getItemSubset(); @@ -69,7 +69,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return NumberPresented::class; } diff --git a/src/qtism/runtime/expressions/NumberRespondedProcessor.php b/src/qtism/runtime/expressions/NumberRespondedProcessor.php index 63e175511..4521119cf 100644 --- a/src/qtism/runtime/expressions/NumberRespondedProcessor.php +++ b/src/qtism/runtime/expressions/NumberRespondedProcessor.php @@ -46,7 +46,7 @@ class NumberRespondedProcessor extends ItemSubsetProcessor * @return QtiInteger The number of items in the given sub-set that been attempted (at least once) and for which a response was given. * @throws ExpressionProcessingException */ - public function process() + public function process(): QtiInteger { $testSession = $this->getState(); $itemSubset = $this->getItemSubset(); @@ -70,7 +70,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return NumberResponded::class; } diff --git a/src/qtism/runtime/expressions/NumberSelectedProcessor.php b/src/qtism/runtime/expressions/NumberSelectedProcessor.php index c317efe68..050ef8c2e 100644 --- a/src/qtism/runtime/expressions/NumberSelectedProcessor.php +++ b/src/qtism/runtime/expressions/NumberSelectedProcessor.php @@ -45,7 +45,7 @@ class NumberSelectedProcessor extends ItemSubsetProcessor * @return QtiInteger The number of items in the given sub-set that have been selected for presentation to the candidate. * @throws ExpressionProcessingException */ - public function process() + public function process(): QtiInteger { $testSession = $this->getState(); $itemSubset = $this->getItemSubset(); @@ -69,7 +69,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return NumberSelected::class; } diff --git a/src/qtism/runtime/expressions/OutcomeMaximumProcessor.php b/src/qtism/runtime/expressions/OutcomeMaximumProcessor.php index 2184615dc..34fb8b871 100644 --- a/src/qtism/runtime/expressions/OutcomeMaximumProcessor.php +++ b/src/qtism/runtime/expressions/OutcomeMaximumProcessor.php @@ -48,7 +48,7 @@ class OutcomeMaximumProcessor extends ItemSubsetProcessor * @return MultipleContainer|null A MultipleContainer object with baseType float containing all the retrieved normalMaximum values or NULL if no declared maximum in the sub-set. * @throws ExpressionProcessingException */ - public function process() + public function process(): ?MultipleContainer { $itemSubset = $this->getItemSubset(); @@ -104,7 +104,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return OutcomeMaximum::class; } diff --git a/src/qtism/runtime/expressions/OutcomeMinimumProcessor.php b/src/qtism/runtime/expressions/OutcomeMinimumProcessor.php index 65f86b831..5e0fb2559 100644 --- a/src/qtism/runtime/expressions/OutcomeMinimumProcessor.php +++ b/src/qtism/runtime/expressions/OutcomeMinimumProcessor.php @@ -48,7 +48,7 @@ class OutcomeMinimumProcessor extends ItemSubsetProcessor * @return MultipleContainer|null A MultipleContainer object with baseType float containing all the retrieved normalMinimum values or NULL if no declared minimum in the sub-set. * @throws ExpressionProcessingException */ - public function process() + public function process(): ?MultipleContainer { $itemSubset = $this->getItemSubset(); $testSession = $this->getState(); @@ -94,7 +94,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return OutcomeMinimum::class; } diff --git a/src/qtism/runtime/expressions/RandomFloatProcessor.php b/src/qtism/runtime/expressions/RandomFloatProcessor.php index 84b019f9d..8e861754c 100644 --- a/src/qtism/runtime/expressions/RandomFloatProcessor.php +++ b/src/qtism/runtime/expressions/RandomFloatProcessor.php @@ -43,7 +43,7 @@ class RandomFloatProcessor extends ExpressionProcessor * @return QtiFloat A Random float value. * @throws ExpressionProcessingException */ - public function process() + public function process(): QtiFloat { $expr = $this->getExpression(); $min = $expr->getMin(); @@ -70,7 +70,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return RandomFloat::class; } diff --git a/src/qtism/runtime/expressions/RandomIntegerProcessor.php b/src/qtism/runtime/expressions/RandomIntegerProcessor.php index 5d0a39e21..aaab0c1bf 100644 --- a/src/qtism/runtime/expressions/RandomIntegerProcessor.php +++ b/src/qtism/runtime/expressions/RandomIntegerProcessor.php @@ -46,7 +46,7 @@ class RandomIntegerProcessor extends ExpressionProcessor * @return QtiInteger A random integer value. * @throws ExpressionProcessingException */ - public function process() + public function process(): QtiInteger { $expr = $this->getExpression(); $min = $expr->getMin(); @@ -80,7 +80,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return RandomInteger::class; } diff --git a/src/qtism/runtime/expressions/TestVariablesProcessor.php b/src/qtism/runtime/expressions/TestVariablesProcessor.php index 24f4cf244..7d5bf568b 100644 --- a/src/qtism/runtime/expressions/TestVariablesProcessor.php +++ b/src/qtism/runtime/expressions/TestVariablesProcessor.php @@ -67,7 +67,7 @@ class TestVariablesProcessor extends ItemSubsetProcessor * @return MultipleContainer * @throws ExpressionProcessingException */ - public function process() + public function process(): MultipleContainer { $testSession = $this->getState(); $itemSubset = $this->getItemSubset(); @@ -152,7 +152,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return TestVariables::class; } diff --git a/src/qtism/runtime/expressions/Utils.php b/src/qtism/runtime/expressions/Utils.php index afabd2e6d..ca7e1c69d 100644 --- a/src/qtism/runtime/expressions/Utils.php +++ b/src/qtism/runtime/expressions/Utils.php @@ -38,7 +38,7 @@ class Utils * @param string $variableRef * @return string A sanitized variableRef. */ - public static function sanitizeVariableRef($variableRef) + public static function sanitizeVariableRef($variableRef): string { if (is_string($variableRef)) { return trim($variableRef, '{}'); @@ -57,7 +57,7 @@ public static function sanitizeVariableRef($variableRef) * @param string $message A formatted error reporting message. * @return string */ - public static function errorReporting(Expression $expression, $message) + public static function errorReporting(Expression $expression, $message): string { $shortClassName = Reflection::shortClassName($expression); diff --git a/src/qtism/runtime/expressions/VariableProcessor.php b/src/qtism/runtime/expressions/VariableProcessor.php index 3db6ec969..2b1579f0d 100644 --- a/src/qtism/runtime/expressions/VariableProcessor.php +++ b/src/qtism/runtime/expressions/VariableProcessor.php @@ -145,7 +145,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Variable::class; } diff --git a/src/qtism/runtime/expressions/operators/AndProcessor.php b/src/qtism/runtime/expressions/operators/AndProcessor.php index 38c2c6b82..479c84f36 100644 --- a/src/qtism/runtime/expressions/operators/AndProcessor.php +++ b/src/qtism/runtime/expressions/operators/AndProcessor.php @@ -48,7 +48,7 @@ class AndProcessor extends OperatorProcessor * @return QtiBoolean True if the expression is true, false otherwise. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -78,7 +78,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return AndOperator::class; } diff --git a/src/qtism/runtime/expressions/operators/AnyNProcessor.php b/src/qtism/runtime/expressions/operators/AnyNProcessor.php index c67a47dfc..2fa02de23 100644 --- a/src/qtism/runtime/expressions/operators/AnyNProcessor.php +++ b/src/qtism/runtime/expressions/operators/AnyNProcessor.php @@ -54,7 +54,7 @@ class AnyNProcessor extends OperatorProcessor * @return QtiBoolean|null A boolean value of true if at least min of the sub-expressions are true and at most max of the sub-expressions are true. NULL is returned if the correct value for the operator cannot be determined. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -129,7 +129,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return AnyN::class; } diff --git a/src/qtism/runtime/expressions/operators/ContainerSizeProcessor.php b/src/qtism/runtime/expressions/operators/ContainerSizeProcessor.php index a04e093df..50f0fd9e8 100644 --- a/src/qtism/runtime/expressions/operators/ContainerSizeProcessor.php +++ b/src/qtism/runtime/expressions/operators/ContainerSizeProcessor.php @@ -44,7 +44,7 @@ class ContainerSizeProcessor extends OperatorProcessor * @return QtiInteger The size of the container or null if it contains NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): QtiInteger { $operands = $this->getOperands(); @@ -63,7 +63,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return ContainerSize::class; } diff --git a/src/qtism/runtime/expressions/operators/ContainsProcessor.php b/src/qtism/runtime/expressions/operators/ContainsProcessor.php index 68e8fcd55..028d7f799 100644 --- a/src/qtism/runtime/expressions/operators/ContainsProcessor.php +++ b/src/qtism/runtime/expressions/operators/ContainsProcessor.php @@ -46,7 +46,7 @@ class ContainsProcessor extends OperatorProcessor * @return QtiBoolean * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -117,7 +117,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Contains::class; } diff --git a/src/qtism/runtime/expressions/operators/CustomOperatorProcessor.php b/src/qtism/runtime/expressions/operators/CustomOperatorProcessor.php index e105fbbca..45b44cb22 100644 --- a/src/qtism/runtime/expressions/operators/CustomOperatorProcessor.php +++ b/src/qtism/runtime/expressions/operators/CustomOperatorProcessor.php @@ -66,7 +66,7 @@ public function __construct(Expression $expression, OperandsCollection $operands /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return CustomOperator::class; } diff --git a/src/qtism/runtime/expressions/operators/DeleteProcessor.php b/src/qtism/runtime/expressions/operators/DeleteProcessor.php index 77c429115..73ca4b6d3 100644 --- a/src/qtism/runtime/expressions/operators/DeleteProcessor.php +++ b/src/qtism/runtime/expressions/operators/DeleteProcessor.php @@ -54,7 +54,7 @@ class DeleteProcessor extends OperatorProcessor * @return Container|null A new container derived from the second sub-expression with all instances of the first sub-expression removed, or NULL if either sub-expression is considered to be NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?Container { $operands = $this->getOperands(); @@ -98,7 +98,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Delete::class; } diff --git a/src/qtism/runtime/expressions/operators/DivideProcessor.php b/src/qtism/runtime/expressions/operators/DivideProcessor.php index 94c1c1071..1c3ec9e23 100644 --- a/src/qtism/runtime/expressions/operators/DivideProcessor.php +++ b/src/qtism/runtime/expressions/operators/DivideProcessor.php @@ -49,7 +49,7 @@ class DivideProcessor extends OperatorProcessor * @return QtiFloat|null A float value that corresponds to the first expression divided by the second or NULL if either of the sub-expressions is NULL or the result is outside the value set defined by float. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiFloat { $operands = $this->getOperands(); @@ -82,7 +82,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Divide::class; } diff --git a/src/qtism/runtime/expressions/operators/DurationGTEProcessor.php b/src/qtism/runtime/expressions/operators/DurationGTEProcessor.php index 539ab7141..d970ffb5f 100644 --- a/src/qtism/runtime/expressions/operators/DurationGTEProcessor.php +++ b/src/qtism/runtime/expressions/operators/DurationGTEProcessor.php @@ -47,7 +47,7 @@ class DurationGTEProcessor extends OperatorProcessor * @return QtiBoolean|null A boolean with a value of true if the first duration is longer or equal to the second, otherwise false. If either sub-expression is NULL, the result of the operator is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -71,7 +71,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return DurationGTE::class; } diff --git a/src/qtism/runtime/expressions/operators/DurationLTProcessor.php b/src/qtism/runtime/expressions/operators/DurationLTProcessor.php index 3342b0aaa..aeb279269 100644 --- a/src/qtism/runtime/expressions/operators/DurationLTProcessor.php +++ b/src/qtism/runtime/expressions/operators/DurationLTProcessor.php @@ -54,7 +54,7 @@ class DurationLTProcessor extends OperatorProcessor * @return QtiBoolean|null A boolean value of true if the first duration is shorter than the second or NULL if either sub-expression is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -78,7 +78,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return DurationLT::class; } diff --git a/src/qtism/runtime/expressions/operators/EqualProcessor.php b/src/qtism/runtime/expressions/operators/EqualProcessor.php index 0ebf6cba0..803a9774c 100644 --- a/src/qtism/runtime/expressions/operators/EqualProcessor.php +++ b/src/qtism/runtime/expressions/operators/EqualProcessor.php @@ -67,7 +67,7 @@ class EqualProcessor extends OperatorProcessor * @return QtiBoolean|null Whether the two expressions are numerically equal and false if they are not or NULL if either sub-expression is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -148,7 +148,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Equal::class; } diff --git a/src/qtism/runtime/expressions/operators/EqualRoundedProcessor.php b/src/qtism/runtime/expressions/operators/EqualRoundedProcessor.php index a6ddd601c..0f07ed068 100644 --- a/src/qtism/runtime/expressions/operators/EqualRoundedProcessor.php +++ b/src/qtism/runtime/expressions/operators/EqualRoundedProcessor.php @@ -62,7 +62,7 @@ class EqualRoundedProcessor extends OperatorProcessor * @return QtiBoolean|null A boolean with a value of true if the two expressions are numerically equal after rounding and false if they are not. If either sub-expression is NULL, the operator results in NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -124,7 +124,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return EqualRounded::class; } diff --git a/src/qtism/runtime/expressions/operators/FieldValueProcessor.php b/src/qtism/runtime/expressions/operators/FieldValueProcessor.php index 6e96bc66f..8e61cd913 100644 --- a/src/qtism/runtime/expressions/operators/FieldValueProcessor.php +++ b/src/qtism/runtime/expressions/operators/FieldValueProcessor.php @@ -42,6 +42,7 @@ class FieldValueProcessor extends OperatorProcessor * @return mixed|null A QTI Runtime compliant value or null if there is no field with that identifier. * @throws OperatorProcessingException */ + #[\ReturnTypeWillChange] public function process() { $operands = $this->getOperands(); @@ -59,7 +60,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return FieldValue::class; } diff --git a/src/qtism/runtime/expressions/operators/GcdProcessor.php b/src/qtism/runtime/expressions/operators/GcdProcessor.php index 9ed572a94..b88381996 100644 --- a/src/qtism/runtime/expressions/operators/GcdProcessor.php +++ b/src/qtism/runtime/expressions/operators/GcdProcessor.php @@ -50,7 +50,7 @@ class GcdProcessor extends OperatorProcessor * @return QtiInteger|null The integer value equal in value to the greatest common divisor of the sub-expressions. If any of the sub-expressions is NULL, the result is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiInteger { $operands = $this->getOperands(); @@ -119,7 +119,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Gcd::class; } diff --git a/src/qtism/runtime/expressions/operators/GtProcessor.php b/src/qtism/runtime/expressions/operators/GtProcessor.php index bad09a3e1..8bcb5bdf6 100644 --- a/src/qtism/runtime/expressions/operators/GtProcessor.php +++ b/src/qtism/runtime/expressions/operators/GtProcessor.php @@ -45,7 +45,7 @@ class GtProcessor extends OperatorProcessor * @return QtiBoolean|null Whether the first sub-expression is numerically greather than the second or NULL if either sub-expression is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -69,7 +69,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Gt::class; } diff --git a/src/qtism/runtime/expressions/operators/GteProcessor.php b/src/qtism/runtime/expressions/operators/GteProcessor.php index 75ede019b..a721d055f 100644 --- a/src/qtism/runtime/expressions/operators/GteProcessor.php +++ b/src/qtism/runtime/expressions/operators/GteProcessor.php @@ -45,7 +45,7 @@ class GteProcessor extends OperatorProcessor * @return QtiBoolean|null Whether the first sub-expression is numerically greather than or equal to the second or NULL if either sub-expression is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -69,7 +69,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Gte::class; } diff --git a/src/qtism/runtime/expressions/operators/IndexProcessor.php b/src/qtism/runtime/expressions/operators/IndexProcessor.php index 1ffecdd19..d9bd1a774 100644 --- a/src/qtism/runtime/expressions/operators/IndexProcessor.php +++ b/src/qtism/runtime/expressions/operators/IndexProcessor.php @@ -48,6 +48,7 @@ class IndexProcessor extends OperatorProcessor * @return mixed|null A QTIRuntime compliant scalar value. NULL is returned if expression->n exceeds the number of values in the container or the sub-expression is NULL. * @throws OperatorProcessingException */ + #[\ReturnTypeWillChange] public function process() { $operands = $this->getOperands(); @@ -96,7 +97,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Index::class; } diff --git a/src/qtism/runtime/expressions/operators/InsideProcessor.php b/src/qtism/runtime/expressions/operators/InsideProcessor.php index 2e1220977..5a91e1bbf 100644 --- a/src/qtism/runtime/expressions/operators/InsideProcessor.php +++ b/src/qtism/runtime/expressions/operators/InsideProcessor.php @@ -45,7 +45,7 @@ class InsideProcessor extends OperatorProcessor * @return QtiBoolean|null Whether the given point is inside the area defined by shape and coords or NULL if the sub-expression is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -72,7 +72,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Inside::class; } diff --git a/src/qtism/runtime/expressions/operators/IntegerDivideProcessor.php b/src/qtism/runtime/expressions/operators/IntegerDivideProcessor.php index 2a90d9d05..73fc11cb4 100644 --- a/src/qtism/runtime/expressions/operators/IntegerDivideProcessor.php +++ b/src/qtism/runtime/expressions/operators/IntegerDivideProcessor.php @@ -44,7 +44,7 @@ class IntegerDivideProcessor extends OperatorProcessor * * @return QtiInteger|null An integer value that corresponds to the first expression divided by the second rounded down to the greatest integer i such that i <= x / y. If the second expression is 0 or if either of the sub-expressions is NULL, the result is NULL. */ - public function process() + public function process(): ?QtiInteger { $operands = $this->getOperands(); @@ -76,7 +76,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return IntegerDivide::class; } diff --git a/src/qtism/runtime/expressions/operators/IntegerModulusProcessor.php b/src/qtism/runtime/expressions/operators/IntegerModulusProcessor.php index d47d82990..89b2dabaf 100644 --- a/src/qtism/runtime/expressions/operators/IntegerModulusProcessor.php +++ b/src/qtism/runtime/expressions/operators/IntegerModulusProcessor.php @@ -46,7 +46,7 @@ class IntegerModulusProcessor extends OperatorProcessor * @return QtiInteger|null An integer value that corresponds to the remainder of the Integer Division or NULL if the second expression is 0 or if either of the sub-expressions is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiInteger { $operands = $this->getOperands(); @@ -78,7 +78,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return IntegerModulus::class; } diff --git a/src/qtism/runtime/expressions/operators/IntegerToFloatProcessor.php b/src/qtism/runtime/expressions/operators/IntegerToFloatProcessor.php index 56818d94b..bb83f50bf 100644 --- a/src/qtism/runtime/expressions/operators/IntegerToFloatProcessor.php +++ b/src/qtism/runtime/expressions/operators/IntegerToFloatProcessor.php @@ -44,7 +44,7 @@ class IntegerToFloatProcessor extends OperatorProcessor * @return QtiFloat|null A float value with the same numeric value as the sub-expression or NULL if the sub-expression is considered to be NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiFloat { $operands = $this->getOperands(); @@ -70,7 +70,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return IntegerToFloat::class; } diff --git a/src/qtism/runtime/expressions/operators/IsNullProcessor.php b/src/qtism/runtime/expressions/operators/IsNullProcessor.php index 558dd0be3..a636df222 100644 --- a/src/qtism/runtime/expressions/operators/IsNullProcessor.php +++ b/src/qtism/runtime/expressions/operators/IsNullProcessor.php @@ -44,7 +44,7 @@ class IsNullProcessor extends OperatorProcessor * @return QtiBoolean Whether the sub-expression is considered to be NULL. * @throws OperatorProcessingException If something goes wrong. */ - public function process() + public function process(): QtiBoolean { $operands = $this->getOperands(); $expression = $this->getExpression(); @@ -55,7 +55,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return IsNull::class; } diff --git a/src/qtism/runtime/expressions/operators/LcmProcessor.php b/src/qtism/runtime/expressions/operators/LcmProcessor.php index c77489998..a9e96e730 100644 --- a/src/qtism/runtime/expressions/operators/LcmProcessor.php +++ b/src/qtism/runtime/expressions/operators/LcmProcessor.php @@ -48,7 +48,7 @@ class LcmProcessor extends OperatorProcessor * @return QtiInteger|null A single integer equal in value to the lowest common multiple of the sub-expressions. If all arguments are 0, the result is 0, If any of the sub-expressions is NULL, the result is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiInteger { $operands = $this->getOperands(); @@ -109,7 +109,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Lcm::class; } diff --git a/src/qtism/runtime/expressions/operators/LtProcessor.php b/src/qtism/runtime/expressions/operators/LtProcessor.php index 952f4b03c..d1f076eaa 100644 --- a/src/qtism/runtime/expressions/operators/LtProcessor.php +++ b/src/qtism/runtime/expressions/operators/LtProcessor.php @@ -45,7 +45,7 @@ class LtProcessor extends OperatorProcessor * @return QtiBoolean|null Whether the first sub-expression is numerically less than the second or NULL if either sub-expression is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -69,7 +69,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Lt::class; } diff --git a/src/qtism/runtime/expressions/operators/LteProcessor.php b/src/qtism/runtime/expressions/operators/LteProcessor.php index 6b13341bf..5631005f1 100644 --- a/src/qtism/runtime/expressions/operators/LteProcessor.php +++ b/src/qtism/runtime/expressions/operators/LteProcessor.php @@ -45,7 +45,7 @@ class LteProcessor extends OperatorProcessor * @return QtiBoolean|null Whether the first sub-expression is numerically less than or equal to the second or NULL if either sub-expression is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -69,7 +69,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Lte::class; } diff --git a/src/qtism/runtime/expressions/operators/MatchProcessor.php b/src/qtism/runtime/expressions/operators/MatchProcessor.php index 4abeb0e9b..b00bb564e 100644 --- a/src/qtism/runtime/expressions/operators/MatchProcessor.php +++ b/src/qtism/runtime/expressions/operators/MatchProcessor.php @@ -49,7 +49,7 @@ class MatchProcessor extends OperatorProcessor * @return QtiBoolean|null Whether the two expressions represent the same value or NULL if either of the sub-expressions is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); $expression = $this->getExpression(); @@ -82,7 +82,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return MatchOperator::class; } diff --git a/src/qtism/runtime/expressions/operators/MathOperatorProcessor.php b/src/qtism/runtime/expressions/operators/MathOperatorProcessor.php index 2a311edf5..469932325 100644 --- a/src/qtism/runtime/expressions/operators/MathOperatorProcessor.php +++ b/src/qtism/runtime/expressions/operators/MathOperatorProcessor.php @@ -79,6 +79,7 @@ class MathOperatorProcessor extends OperatorProcessor * * @return QtiFloat|int|null The result of the MathOperator call or NULL if any of the sub-expressions is NULL. See the class documentation for special cases. */ + #[\ReturnTypeWillChange] public function process() { $operands = $this->getOperands(); @@ -112,7 +113,7 @@ public function process() /** * @return QtiFloat */ - protected function processSin() + protected function processSin(): QtiFloat { $operands = $this->getOperands(); @@ -122,7 +123,7 @@ protected function processSin() /** * @return QtiFloat */ - protected function processCos() + protected function processCos(): QtiFloat { $operands = $this->getOperands(); @@ -132,7 +133,7 @@ protected function processCos() /** * @return QtiFloat */ - protected function processTan() + protected function processTan(): QtiFloat { $operands = $this->getOperands(); @@ -142,7 +143,7 @@ protected function processTan() /** * @return null|QtiFloat */ - protected function processSec() + protected function processSec(): ?QtiFloat { $operands = $this->getOperands(); $cos = cos($operands[0]->getValue()); @@ -152,7 +153,7 @@ protected function processSec() /** * @return null|QtiFloat */ - protected function processCsc() + protected function processCsc(): ?QtiFloat { $operands = $this->getOperands(); $sin = sin($operands[0]->getValue()); @@ -162,7 +163,7 @@ protected function processCsc() /** * @return QtiFloat|null */ - protected function processCot() + protected function processCot(): ?QtiFloat { $operands = $this->getOperands(); $tan = tan($operands[0]->getValue()); @@ -178,7 +179,7 @@ protected function processCot() /** * @return QtiFloat */ - protected function processAsin() + protected function processAsin(): QtiFloat { $operands = $this->getOperands(); @@ -188,7 +189,7 @@ protected function processAsin() /** * @return QtiFloat */ - protected function processAcos() + protected function processAcos(): QtiFloat { $operands = $this->getOperands(); @@ -198,7 +199,7 @@ protected function processAcos() /** * @return QtiFloat */ - protected function processAtan() + protected function processAtan(): QtiFloat { $operands = $this->getOperands(); @@ -209,7 +210,7 @@ protected function processAtan() * @return QtiFloat * @throws OperatorProcessingException */ - protected function processAtan2() + protected function processAtan2(): QtiFloat { $operands = $this->getOperands(); @@ -230,7 +231,7 @@ protected function processAtan2() /** * @return null|QtiFloat */ - protected function processAsec() + protected function processAsec(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -245,7 +246,7 @@ protected function processAsec() /** * @return null|QtiFloat */ - protected function processAcsc() + protected function processAcsc(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -260,7 +261,7 @@ protected function processAcsc() /** * @return QtiFloat */ - protected function processAcot() + protected function processAcot(): QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -275,7 +276,7 @@ protected function processAcot() /** * @return QtiFloat */ - protected function processSinh() + protected function processSinh(): QtiFloat { $operands = $this->getOperands(); @@ -285,7 +286,7 @@ protected function processSinh() /** * @return QtiFloat */ - protected function processCosh() + protected function processCosh(): QtiFloat { $operands = $this->getOperands(); @@ -295,7 +296,7 @@ protected function processCosh() /** * @return QtiFloat */ - protected function processTanh() + protected function processTanh(): QtiFloat { $operands = $this->getOperands(); @@ -305,7 +306,7 @@ protected function processTanh() /** * @return null|QtiFloat */ - protected function processSech() + protected function processSech(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -320,7 +321,7 @@ protected function processSech() /** * @return null|QtiFloat */ - protected function processCsch() + protected function processCsch(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -335,7 +336,7 @@ protected function processCsch() /** * @return null|QtiFloat */ - protected function processCoth() + protected function processCoth(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -352,7 +353,7 @@ protected function processCoth() /** * @return null|QtiFloat */ - protected function processLog() + protected function processLog(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -369,7 +370,7 @@ protected function processLog() /** * @return null|QtiFloat */ - protected function processLn() + protected function processLn(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -386,7 +387,7 @@ protected function processLn() /** * @return null|QtiFloat */ - protected function processExp() + protected function processExp(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -405,7 +406,7 @@ protected function processExp() /** * @return null|QtiFloat */ - protected function processAbs() + protected function processAbs(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -422,6 +423,7 @@ protected function processAbs() * * @link https://en.wikipedia.org/wiki/Sign_function */ + #[\ReturnTypeWillChange] protected function processSignum() { $operands = $this->getOperands(); @@ -441,6 +443,7 @@ protected function processSignum() /** * @return null|QtiFloat|QtiInteger */ + #[\ReturnTypeWillChange] protected function processFloor() { $operands = $this->getOperands(); @@ -460,6 +463,7 @@ protected function processFloor() /** * @return null|QtiFloat|QtiInteger */ + #[\ReturnTypeWillChange] protected function processCeil() { $operands = $this->getOperands(); @@ -479,7 +483,7 @@ protected function processCeil() /** * @return null|QtiFloat */ - protected function processToDegrees() + protected function processToDegrees(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -498,7 +502,7 @@ protected function processToDegrees() /** * @return null|QtiFloat */ - protected function processToRadians() + protected function processToRadians(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -517,7 +521,7 @@ protected function processToRadians() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return MathOperator::class; } diff --git a/src/qtism/runtime/expressions/operators/MaxProcessor.php b/src/qtism/runtime/expressions/operators/MaxProcessor.php index 264e9f77c..84e183318 100644 --- a/src/qtism/runtime/expressions/operators/MaxProcessor.php +++ b/src/qtism/runtime/expressions/operators/MaxProcessor.php @@ -52,6 +52,7 @@ class MaxProcessor extends OperatorProcessor * @return QtiFloat|QtiInteger|null The greatest of the operand values or NULL if any of the operand values is NULL. * @throws OperatorProcessingException */ + #[\ReturnTypeWillChange] public function process() { $operands = $this->getOperands(); @@ -104,7 +105,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Max::class; } diff --git a/src/qtism/runtime/expressions/operators/MemberProcessor.php b/src/qtism/runtime/expressions/operators/MemberProcessor.php index 1d67131ef..89e08a10c 100644 --- a/src/qtism/runtime/expressions/operators/MemberProcessor.php +++ b/src/qtism/runtime/expressions/operators/MemberProcessor.php @@ -50,7 +50,7 @@ class MemberProcessor extends OperatorProcessor * @return QtiBoolean Whether the first operand is contained by the second one as a boolean value, or NULL if any of the sub-expressions are NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -88,7 +88,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Member::class; } diff --git a/src/qtism/runtime/expressions/operators/MinProcessor.php b/src/qtism/runtime/expressions/operators/MinProcessor.php index 48bb62187..6a86d72a0 100644 --- a/src/qtism/runtime/expressions/operators/MinProcessor.php +++ b/src/qtism/runtime/expressions/operators/MinProcessor.php @@ -53,6 +53,7 @@ class MinProcessor extends OperatorProcessor * @return QtiFloat|QtiInteger|null The smallest of the operand values or NULL if any of the operand values is NULL. * @throws OperatorProcessingException */ + #[\ReturnTypeWillChange] public function process() { $operands = $this->getOperands(); @@ -105,7 +106,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Min::class; } diff --git a/src/qtism/runtime/expressions/operators/MultipleProcessor.php b/src/qtism/runtime/expressions/operators/MultipleProcessor.php index 361380601..27e18f452 100644 --- a/src/qtism/runtime/expressions/operators/MultipleProcessor.php +++ b/src/qtism/runtime/expressions/operators/MultipleProcessor.php @@ -47,7 +47,7 @@ class MultipleProcessor extends OperatorProcessor * @return MultipleContainer|null A MultipleContainer object or NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?MultipleContainer { $operands = $this->getOperands(); @@ -94,7 +94,7 @@ public function process() * @param MultipleContainer $container A MultipleContainer object you want to append something to. * @param mixed $value A value to append to the $container. */ - protected static function appendValue(MultipleContainer $container, $value) + protected static function appendValue(MultipleContainer $container, $value): void { if ($value instanceof MultipleContainer) { foreach ($value as $v) { @@ -109,7 +109,7 @@ protected static function appendValue(MultipleContainer $container, $value) /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Multiple::class; } diff --git a/src/qtism/runtime/expressions/operators/NotProcessor.php b/src/qtism/runtime/expressions/operators/NotProcessor.php index 2559a722c..4e2f1e036 100644 --- a/src/qtism/runtime/expressions/operators/NotProcessor.php +++ b/src/qtism/runtime/expressions/operators/NotProcessor.php @@ -44,7 +44,7 @@ class NotProcessor extends OperatorProcessor * @return QtiBoolean * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -70,7 +70,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return NotOperator::class; } diff --git a/src/qtism/runtime/expressions/operators/OperandsCollection.php b/src/qtism/runtime/expressions/operators/OperandsCollection.php index c00a2dba9..ad806ef63 100644 --- a/src/qtism/runtime/expressions/operators/OperandsCollection.php +++ b/src/qtism/runtime/expressions/operators/OperandsCollection.php @@ -51,7 +51,7 @@ class OperandsCollection extends AbstractCollection implements Stack * @param mixed $value * @throws InvalidArgumentException If $value is not a QTI Runtime compliant value. */ - protected function checkType($value) + protected function checkType($value): void { if (!RuntimeUtils::isRuntimeCompliant($value)) { $value = (is_object($value)) ? get_class($value) : $value; @@ -70,7 +70,7 @@ protected function checkType($value) * * @return bool */ - public function containsNull() + public function containsNull(): bool { foreach (array_keys($this->getDataPlaceHolder()) as $key) { $v = $this[$key]; @@ -124,7 +124,7 @@ public function exclusivelyNumeric() * * @return bool */ - public function exclusivelyBoolean() + public function exclusivelyBoolean(): bool { if (count($this) === 0) { return false; @@ -148,7 +148,7 @@ public function exclusivelyBoolean() * * @return bool */ - public function exclusivelySingle() + public function exclusivelySingle(): bool { if (count($this) === 0) { return false; @@ -176,7 +176,7 @@ public function exclusivelySingle() * * @return bool */ - public function exclusivelyString() + public function exclusivelyString(): bool { if (count($this) === 0) { return false; @@ -199,7 +199,7 @@ public function exclusivelyString() * * @return bool */ - public function exclusivelyMultipleOrOrdered() + public function exclusivelyMultipleOrOrdered(): bool { if (count($this) === 0) { return false; @@ -225,7 +225,7 @@ public function exclusivelyMultipleOrOrdered() * * @return bool. */ - public function exclusivelyInteger() + public function exclusivelyInteger(): bool { if (count($this) === 0) { return false; @@ -253,7 +253,7 @@ public function exclusivelyInteger() * * @return bool */ - public function exclusivelySingleOrMultiple() + public function exclusivelySingleOrMultiple(): bool { if (count($this) === 0) { return false; @@ -280,7 +280,7 @@ public function exclusivelySingleOrMultiple() * * @return bool */ - public function exclusivelySingleOrOrdered() + public function exclusivelySingleOrOrdered(): bool { if (count($this) === 0) { return false; @@ -306,7 +306,7 @@ public function exclusivelySingleOrOrdered() * * @return bool */ - public function exclusivelyRecord() + public function exclusivelyRecord(): bool { if (count($this) === 0) { return false; @@ -331,7 +331,7 @@ public function exclusivelyRecord() * * @return bool */ - public function exclusivelyOrdered() + public function exclusivelyOrdered(): bool { if (count($this) === 0) { return false; @@ -352,7 +352,7 @@ public function exclusivelyOrdered() * * @return bool */ - public function anythingButRecord() + public function anythingButRecord(): bool { foreach (array_keys($this->getDataPlaceHolder()) as $key) { $v = $this[$key]; @@ -374,7 +374,7 @@ public function anythingButRecord() * * @return bool */ - public function sameBaseType() + public function sameBaseType(): bool { $operandsCount = count($this); if ($operandsCount > 0 && !$this->containsNull()) { @@ -407,7 +407,7 @@ public function sameBaseType() * * @return bool */ - public function sameCardinality() + public function sameCardinality(): bool { $operandsCount = count($this); if ($operandsCount > 0 && !$this->containsNull()) { @@ -434,7 +434,7 @@ public function sameCardinality() * * @return bool */ - public function exclusivelyPoint() + public function exclusivelyPoint(): bool { if (count($this) === 0) { return false; @@ -461,7 +461,7 @@ public function exclusivelyPoint() * * @return bool */ - public function exclusivelyDuration() + public function exclusivelyDuration(): bool { if (count($this) === 0) { return false; @@ -482,7 +482,7 @@ public function exclusivelyDuration() /** * @param mixed $value */ - public function push($value) + public function push($value): void { $this->checkType($value); diff --git a/src/qtism/runtime/expressions/operators/OperatorProcessingException.php b/src/qtism/runtime/expressions/operators/OperatorProcessingException.php index cddf64620..dd060316d 100644 --- a/src/qtism/runtime/expressions/operators/OperatorProcessingException.php +++ b/src/qtism/runtime/expressions/operators/OperatorProcessingException.php @@ -37,7 +37,7 @@ class OperatorProcessingException extends ExpressionProcessingException * * @var int */ - const WRONG_CARDINALITY = 100; + public const WRONG_CARDINALITY = 100; /** * The code to use when an operand with a not compliant baseType is @@ -45,7 +45,7 @@ class OperatorProcessingException extends ExpressionProcessingException * * @var int */ - const WRONG_BASETYPE = 101; + public const WRONG_BASETYPE = 101; /** * The code to use when an operand has a not compliant baseType OR @@ -53,19 +53,19 @@ class OperatorProcessingException extends ExpressionProcessingException * * @var int */ - const WRONG_BASETYPE_OR_CARDINALITY = 102; + public const WRONG_BASETYPE_OR_CARDINALITY = 102; /** * The code to use when not enough operands are given to a processor. * * @var int */ - const NOT_ENOUGH_OPERANDS = 103; + public const NOT_ENOUGH_OPERANDS = 103; /** * The code to use when too much operands are given to a processor. * * @var int */ - const TOO_MUCH_OPERANDS = 104; + public const TOO_MUCH_OPERANDS = 104; } diff --git a/src/qtism/runtime/expressions/operators/OperatorProcessor.php b/src/qtism/runtime/expressions/operators/OperatorProcessor.php index b17b369f5..777b6d552 100644 --- a/src/qtism/runtime/expressions/operators/OperatorProcessor.php +++ b/src/qtism/runtime/expressions/operators/OperatorProcessor.php @@ -59,7 +59,7 @@ public function __construct(Expression $expression, OperandsCollection $operands * @param OperandsCollection $operands A collection of QTI Runtime compliant values. * @throws OperatorProcessingException If The operands are not compliant with minimum or maximum amount of operands the operator can take. */ - public function setOperands(OperandsCollection $operands) + public function setOperands(OperandsCollection $operands): void { // Check minimal operand count. $min = $this->getExpression()->getMinOperands(); @@ -90,7 +90,7 @@ public function setOperands(OperandsCollection $operands) * * @return OperandsCollection A collection of QTI Runtime compliant values. */ - public function getOperands() + public function getOperands(): OperandsCollection { return $this->operands; } diff --git a/src/qtism/runtime/expressions/operators/OperatorProcessorFactory.php b/src/qtism/runtime/expressions/operators/OperatorProcessorFactory.php index fac498acd..a92b715b1 100644 --- a/src/qtism/runtime/expressions/operators/OperatorProcessorFactory.php +++ b/src/qtism/runtime/expressions/operators/OperatorProcessorFactory.php @@ -54,7 +54,7 @@ public function __construct() * @throws InvalidArgumentException If $expression is not an Operator object. * @throws RuntimeException If no relevant OperatorProcessor is found for the given $expression. */ - public function createProcessor(QtiComponent $expression, OperandsCollection $operands = null) + public function createProcessor(QtiComponent $expression, OperandsCollection $operands = null): OperatorProcessor { if (!($expression instanceof Operator)) { $msg = 'The OperatorProcessorFactory only accepts to create processors for Operator objects.'; diff --git a/src/qtism/runtime/expressions/operators/OrProcessor.php b/src/qtism/runtime/expressions/operators/OrProcessor.php index 4b39c8caf..f8ccadbac 100644 --- a/src/qtism/runtime/expressions/operators/OrProcessor.php +++ b/src/qtism/runtime/expressions/operators/OrProcessor.php @@ -48,7 +48,7 @@ class OrProcessor extends OperatorProcessor * @return QtiBoolean True if the expression is true, false otherwise. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); $allFalse = true; @@ -83,7 +83,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return OrOperator::class; } diff --git a/src/qtism/runtime/expressions/operators/OrderedProcessor.php b/src/qtism/runtime/expressions/operators/OrderedProcessor.php index 0d5eaaac3..7b30605a7 100644 --- a/src/qtism/runtime/expressions/operators/OrderedProcessor.php +++ b/src/qtism/runtime/expressions/operators/OrderedProcessor.php @@ -53,7 +53,7 @@ class OrderedProcessor extends OperatorProcessor * @return OrderedContainer|null An OrderedContainer object or NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?OrderedContainer { $operands = $this->getOperands(); @@ -100,7 +100,7 @@ public function process() * @param OrderedContainer $container An OrderedContainer object you want to append something to. * @param QtiScalar|OrderedContainer $value A value to append to the $container. */ - protected static function appendValue(OrderedContainer $container, $value) + protected static function appendValue(OrderedContainer $container, $value): void { if ($value instanceof OrderedContainer) { foreach ($value as $v) { @@ -115,7 +115,7 @@ protected static function appendValue(OrderedContainer $container, $value) /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Ordered::class; } diff --git a/src/qtism/runtime/expressions/operators/PatternMatchProcessor.php b/src/qtism/runtime/expressions/operators/PatternMatchProcessor.php index e816306cd..db8156463 100644 --- a/src/qtism/runtime/expressions/operators/PatternMatchProcessor.php +++ b/src/qtism/runtime/expressions/operators/PatternMatchProcessor.php @@ -53,7 +53,7 @@ class PatternMatchProcessor extends OperatorProcessor * @return QtiBoolean|null A single boolean with a value of true if the sub-expression matches the pattern and false if it does not. If the sub-expression is NULL, the the operator results in NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -92,7 +92,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return PatternMatch::class; } diff --git a/src/qtism/runtime/expressions/operators/PowerProcessor.php b/src/qtism/runtime/expressions/operators/PowerProcessor.php index 9907804c1..cc53c87e2 100644 --- a/src/qtism/runtime/expressions/operators/PowerProcessor.php +++ b/src/qtism/runtime/expressions/operators/PowerProcessor.php @@ -47,7 +47,7 @@ class PowerProcessor extends OperatorProcessor * @return QtiFloat|null A float value that corresponds to the first expression raised to the power of the second or NULL if the either sub-expression is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiFloat { $operands = $this->getOperands(); @@ -103,7 +103,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Power::class; } diff --git a/src/qtism/runtime/expressions/operators/ProductProcessor.php b/src/qtism/runtime/expressions/operators/ProductProcessor.php index 57cd84ee1..60a3c7435 100644 --- a/src/qtism/runtime/expressions/operators/ProductProcessor.php +++ b/src/qtism/runtime/expressions/operators/ProductProcessor.php @@ -47,6 +47,7 @@ class ProductProcessor extends OperatorProcessor * @return QtiInteger|QtiFloat * @throws OperatorProcessingException If invalid operands are given. */ + #[\ReturnTypeWillChange] public function process() { $operands = $this->getOperands(); @@ -79,7 +80,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Product::class; } diff --git a/src/qtism/runtime/expressions/operators/RandomProcessor.php b/src/qtism/runtime/expressions/operators/RandomProcessor.php index a823e1d78..76b24de9e 100644 --- a/src/qtism/runtime/expressions/operators/RandomProcessor.php +++ b/src/qtism/runtime/expressions/operators/RandomProcessor.php @@ -43,6 +43,7 @@ class RandomProcessor extends OperatorProcessor * @return mixed|null A single cardinality QTI runtime compliant value or NULL if the operand is considered to be NULL. * @throws OperatorProcessingException */ + #[\ReturnTypeWillChange] public function process() { $operands = $this->getOperands(); @@ -65,7 +66,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Random::class; } diff --git a/src/qtism/runtime/expressions/operators/RepeatProcessor.php b/src/qtism/runtime/expressions/operators/RepeatProcessor.php index 20fcf7da8..cf50d5d68 100644 --- a/src/qtism/runtime/expressions/operators/RepeatProcessor.php +++ b/src/qtism/runtime/expressions/operators/RepeatProcessor.php @@ -60,7 +60,7 @@ class RepeatProcessor extends OperatorProcessor * @return OrderedContainer An ordered container filled sequentially by evaluating each sub-expressions, repeated a 'numberRepeats' of times. NULL is returned if all sub-expressions are NULL or numberRepeats < 1. * @throws OperatorProcessingException */ - public function process() + public function process(): ?OrderedContainer { $operands = $this->getOperands(); @@ -138,7 +138,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Repeat::class; } diff --git a/src/qtism/runtime/expressions/operators/RoundProcessor.php b/src/qtism/runtime/expressions/operators/RoundProcessor.php index e44a8f9ea..5a5939058 100644 --- a/src/qtism/runtime/expressions/operators/RoundProcessor.php +++ b/src/qtism/runtime/expressions/operators/RoundProcessor.php @@ -48,7 +48,7 @@ class RoundProcessor extends OperatorProcessor * @return QtiInteger|null An integer value formed by rounding the value of the sub-expression or NULL if the sub-expression is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiInteger { $operands = $this->getOperands(); @@ -75,7 +75,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Round::class; } diff --git a/src/qtism/runtime/expressions/operators/RoundToProcessor.php b/src/qtism/runtime/expressions/operators/RoundToProcessor.php index f51c99f2c..d10e52717 100644 --- a/src/qtism/runtime/expressions/operators/RoundToProcessor.php +++ b/src/qtism/runtime/expressions/operators/RoundToProcessor.php @@ -68,7 +68,7 @@ class RoundToProcessor extends OperatorProcessor * @return null|QtiFloat A single float with the value nearest to that of the expression's value or NULL if the sub-expression is NaN. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiFloat { $operands = $this->getOperands(); $state = $this->getState(); @@ -147,7 +147,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return RoundTo::class; } diff --git a/src/qtism/runtime/expressions/operators/StatsOperatorProcessor.php b/src/qtism/runtime/expressions/operators/StatsOperatorProcessor.php index 965e30347..e1490b30e 100644 --- a/src/qtism/runtime/expressions/operators/StatsOperatorProcessor.php +++ b/src/qtism/runtime/expressions/operators/StatsOperatorProcessor.php @@ -61,7 +61,7 @@ class StatsOperatorProcessor extends OperatorProcessor * @return QtiFloat A single float or NULL if the sub-expression or any value contained therein is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiFloat { $operands = $this->getOperands(); @@ -88,7 +88,7 @@ public function process() /** * @return null|QtiFloat */ - protected function processMean() + protected function processMean(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -101,7 +101,7 @@ protected function processMean() /** * @return QtiFloat|null */ - protected function processSampleVariance() + protected function processSampleVariance(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -114,7 +114,7 @@ protected function processSampleVariance() /** * @return QtiFloat|null */ - protected function processSampleSD() + protected function processSampleSD(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -127,7 +127,7 @@ protected function processSampleSD() /** * @return QtiFloat|null */ - protected function processPopVariance() + protected function processPopVariance(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -140,7 +140,7 @@ protected function processPopVariance() /** * @return QtiFloat|null */ - protected function processPopSD() + protected function processPopSD(): ?QtiFloat { $operands = $this->getOperands(); $operand = $operands[0]; @@ -157,7 +157,7 @@ protected function processPopSD() * @param array $data An array of Float and/or Integer values. * @return array A filtered array with PHP float and integers. */ - protected static function filterValues(array $data) + protected static function filterValues(array $data): array { $returnValue = []; foreach ($data as $d) { @@ -174,7 +174,7 @@ protected static function filterValues(array $data) /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return StatsOperator::class; } diff --git a/src/qtism/runtime/expressions/operators/StringMatchProcessor.php b/src/qtism/runtime/expressions/operators/StringMatchProcessor.php index ce6f5b4ca..dc2d7f66a 100644 --- a/src/qtism/runtime/expressions/operators/StringMatchProcessor.php +++ b/src/qtism/runtime/expressions/operators/StringMatchProcessor.php @@ -48,7 +48,7 @@ class StringMatchProcessor extends OperatorProcessor * @return QtiBoolean Whether the two string match according to the comparison rules of the operator's attributes or NULL if either of the sub-expressions is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -79,7 +79,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return StringMatch::class; } diff --git a/src/qtism/runtime/expressions/operators/SubstringProcessor.php b/src/qtism/runtime/expressions/operators/SubstringProcessor.php index 55ee4982f..f5a34f1a6 100644 --- a/src/qtism/runtime/expressions/operators/SubstringProcessor.php +++ b/src/qtism/runtime/expressions/operators/SubstringProcessor.php @@ -45,7 +45,7 @@ class SubstringProcessor extends OperatorProcessor * @return QtiBoolean|null Whether the first sub-expression is a substring of the second sub-expression or NULL if either sub-expression is NULL. * @throws OperatorProcessingException */ - public function process() + public function process(): ?QtiBoolean { $operands = $this->getOperands(); @@ -74,7 +74,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Substring::class; } diff --git a/src/qtism/runtime/expressions/operators/SubtractProcessor.php b/src/qtism/runtime/expressions/operators/SubtractProcessor.php index 75ef6b8ad..0962aad10 100644 --- a/src/qtism/runtime/expressions/operators/SubtractProcessor.php +++ b/src/qtism/runtime/expressions/operators/SubtractProcessor.php @@ -46,6 +46,7 @@ class SubtractProcessor extends OperatorProcessor * @return QtiFloat|QtiInteger|null A single float or if both sub-expressions are integers, a single integer or NULL if either of the sub-expressions is NULL. * @throws OperatorProcessingException */ + #[\ReturnTypeWillChange] public function process() { $operands = $this->getOperands(); @@ -75,7 +76,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Subtract::class; } diff --git a/src/qtism/runtime/expressions/operators/SumProcessor.php b/src/qtism/runtime/expressions/operators/SumProcessor.php index 5018f6f0b..31fa8609a 100644 --- a/src/qtism/runtime/expressions/operators/SumProcessor.php +++ b/src/qtism/runtime/expressions/operators/SumProcessor.php @@ -46,6 +46,7 @@ class SumProcessor extends OperatorProcessor * @return QtiInteger|QtiFloat|null A single integer/float that corresponds to the sum of the numerical values of the sub-expressions. If any of the sub-expressions are NULL, the operator results in NULL. * @throws OperatorProcessingException If invalid operands are given. */ + #[\ReturnTypeWillChange] public function process() { $operands = $this->getOperands(); @@ -88,7 +89,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Sum::class; } diff --git a/src/qtism/runtime/expressions/operators/TruncateProcessor.php b/src/qtism/runtime/expressions/operators/TruncateProcessor.php index d2d8ecc51..9e671c61c 100644 --- a/src/qtism/runtime/expressions/operators/TruncateProcessor.php +++ b/src/qtism/runtime/expressions/operators/TruncateProcessor.php @@ -46,9 +46,10 @@ class TruncateProcessor extends OperatorProcessor /** * Process the Truncate operator. * - * @return QtiInteger|null The truncated value or NULL if the sub-expression is NaN or if the sub-expression is NULL. + * @return QtiInteger|QtiFloat|null The truncated value or NULL if the sub-expression is NaN or if the sub-expression is NULL. * @throws OperatorProcessingException */ + #[\ReturnTypeWillChange] public function process() { $operands = $this->getOperands(); @@ -81,7 +82,7 @@ public function process() /** * @return string */ - protected function getExpressionType() + protected function getExpressionType(): string { return Truncate::class; } diff --git a/src/qtism/runtime/expressions/operators/Utils.php b/src/qtism/runtime/expressions/operators/Utils.php index 0fd134995..3134c8f54 100644 --- a/src/qtism/runtime/expressions/operators/Utils.php +++ b/src/qtism/runtime/expressions/operators/Utils.php @@ -40,7 +40,7 @@ class Utils * @param int $b A positive integer * @return int The GCD of $a and $b. */ - public static function gcd($a, $b) + public static function gcd($a, $b): int { $a = abs($a); $b = abs($b); @@ -64,7 +64,7 @@ public static function gcd($a, $b) * @param int $b * @return int the LCM of $a and $b. */ - public static function lcm($a, $b) + public static function lcm($a, $b): int { $a = abs($a); $b = abs($b); @@ -201,7 +201,7 @@ public static function pregAddDelimiter(string $string) * @param int $offset * @return int */ - public static function getPrecedingBackslashesCount($string, $offset) + public static function getPrecedingBackslashesCount($string, $offset): int { $count = 0; @@ -297,7 +297,7 @@ public static function customOperatorClassToPhpClass($class) * * @return string */ - public static function lastPregErrorMessage() + public static function lastPregErrorMessage(): string { $error = preg_last_error(); $errorType = 'PCRE Engine error'; diff --git a/src/qtism/runtime/expressions/operators/custom/Explode.php b/src/qtism/runtime/expressions/operators/custom/Explode.php index a79284106..0188fbf1e 100644 --- a/src/qtism/runtime/expressions/operators/custom/Explode.php +++ b/src/qtism/runtime/expressions/operators/custom/Explode.php @@ -54,7 +54,7 @@ class Explode extends CustomOperatorProcessor * @return OrderedContainer The split value of the second sub-expression given as a parameter. * @throws OperatorProcessingException If something goes wrong. */ - public function process() + public function process(): ?OrderedContainer { $operands = $this->getOperands(); diff --git a/src/qtism/runtime/expressions/operators/custom/Implode.php b/src/qtism/runtime/expressions/operators/custom/Implode.php index 6e8f129c0..4fb56dcb7 100644 --- a/src/qtism/runtime/expressions/operators/custom/Implode.php +++ b/src/qtism/runtime/expressions/operators/custom/Implode.php @@ -47,7 +47,7 @@ class Implode extends CustomOperatorProcessor * @return QtiString The split value of the second sub-expression given as a parameter. * @throws OperatorProcessingException If something goes wrong. */ - public function process() + public function process(): ?QtiString { $operands = $this->getOperands(); diff --git a/src/qtism/runtime/expressions/operators/custom/math/graph/CountPointsThatSatisfyEquation.php b/src/qtism/runtime/expressions/operators/custom/math/graph/CountPointsThatSatisfyEquation.php index 837d4400b..dedbc2f3b 100644 --- a/src/qtism/runtime/expressions/operators/custom/math/graph/CountPointsThatSatisfyEquation.php +++ b/src/qtism/runtime/expressions/operators/custom/math/graph/CountPointsThatSatisfyEquation.php @@ -4,33 +4,36 @@ use Exception; use oat\beeme\Parser; -use qtism\common\enums\BaseType; use qtism\common\datatypes\QtiInteger as QtismInteger; -use qtism\common\datatypes\QtiString as QtismString; use qtism\common\datatypes\QtiPoint; +use qtism\common\datatypes\QtiString as QtismString; +use qtism\common\enums\BaseType; use qtism\runtime\common\MultipleContainer; use qtism\runtime\common\OrderedContainer; use qtism\runtime\expressions\operators\CustomOperatorProcessor; class CountPointsThatSatisfyEquation extends CustomOperatorProcessor { - public function process() + /** + * @return QtismInteger|null + */ + public function process(): ?QtismInteger { $returnValue = new QtismInteger(0); $operands = $this->getOperands(); - + if (count($operands) >= 2) { $points = $operands[0]; $equation = $operands[1]; - + if (($points instanceof MultipleContainer || $points instanceof OrderedContainer) && ($points->getBaseType() === BaseType::POINT || $points->getBaseType() === BaseType::STRING) && $equation instanceof QtismString) { // Check every Point X,Y against the equation... $math = new Parser(); $math->setConstant('#pi', M_PI); - + try { foreach ($points as $point) { - + if ($point instanceof QtiPoint) { $x = floatval($point->getX()); $y = floatval($point->getY()); @@ -44,7 +47,7 @@ public function process() $y = floatval($strs[1]); } } - + $result = $math->evaluate( $equation->getValue(), array( @@ -52,7 +55,7 @@ public function process() 'y' => $y ) ); - + if ($result === true) { // The Point X,Y satisfies the equation... $returnValue->setValue($returnValue->getValue() + 1); @@ -67,7 +70,7 @@ public function process() return null; } } - + return $returnValue; } } diff --git a/src/qtism/runtime/pci/json/Marshaller.php b/src/qtism/runtime/pci/json/Marshaller.php index 88a95f435..9665d6e73 100644 --- a/src/qtism/runtime/pci/json/Marshaller.php +++ b/src/qtism/runtime/pci/json/Marshaller.php @@ -60,14 +60,14 @@ class Marshaller * * @var int */ - const MARSHALL_ARRAY = 0; + public const MARSHALL_ARRAY = 0; /** * Output of marshalling as JSON string. * * @var int */ - const MARSHALL_JSON = 1; + public const MARSHALL_JSON = 1; /** * Create a new JSON Marshaller object. @@ -122,7 +122,7 @@ public function marshall($data, $output = Marshaller::MARSHALL_JSON) * @return array An array representing the JSON data to be encoded later on. * @throws MarshallingException */ - protected function marshallUnit($unit) + protected function marshallUnit($unit): array { if ($unit === null) { $json = ['base' => null]; @@ -171,7 +171,7 @@ protected function marshallUnit($unit) * @return array An array representing the JSON data to be encoded later on. * @throws MarshallingException */ - protected function marshallScalar($scalar) + protected function marshallScalar($scalar): ?array { if ($scalar === null) { return null; @@ -214,7 +214,7 @@ protected function marshallScalar($scalar) * @return array An array representing the JSON data to be encoded later on. * @throws MarshallingException */ - protected function marshallComplex(QtiDatatype $complex) + protected function marshallComplex(QtiDatatype $complex): array { if ($complex === null) { return $complex; @@ -250,7 +250,7 @@ protected function marshallComplex(QtiDatatype $complex) * @param QtiBoolean $boolean * @return array */ - protected function marshallBoolean(QtiBoolean $boolean) + protected function marshallBoolean(QtiBoolean $boolean): array { return ['base' => ['boolean' => $boolean->getValue()]]; } @@ -261,7 +261,7 @@ protected function marshallBoolean(QtiBoolean $boolean) * @param QtiInteger $integer * @return array */ - protected function marshallInteger(QtiInteger $integer) + protected function marshallInteger(QtiInteger $integer): array { return ['base' => ['integer' => $integer->getValue()]]; } @@ -272,7 +272,7 @@ protected function marshallInteger(QtiInteger $integer) * @param QtiFloat $float * @return array */ - protected function marshallFloat(QtiFloat $float) + protected function marshallFloat(QtiFloat $float): array { return ['base' => ['float' => $float->getValue()]]; } @@ -283,7 +283,7 @@ protected function marshallFloat(QtiFloat $float) * @param QtiIdentifier $identifier * @return array */ - protected function marshallIdentifier(QtiIdentifier $identifier) + protected function marshallIdentifier(QtiIdentifier $identifier): array { return ['base' => ['identifier' => $identifier->getValue()]]; } @@ -294,7 +294,7 @@ protected function marshallIdentifier(QtiIdentifier $identifier) * @param QtiUri $uri * @return array */ - protected function marshallUri(QtiUri $uri) + protected function marshallUri(QtiUri $uri): array { return ['base' => ['uri' => $uri->getValue()]]; } @@ -305,7 +305,7 @@ protected function marshallUri(QtiUri $uri) * @param QtiString $string * @return array */ - protected function marshallString(QtiString $string) + protected function marshallString(QtiString $string): array { return ['base' => ['string' => $string->getValue()]]; } @@ -316,7 +316,7 @@ protected function marshallString(QtiString $string) * @param QtiIntOrIdentifier $intOrIdentifier * @return array */ - protected function marshallIntOrIdentifier(QtiIntOrIdentifier $intOrIdentifier) + protected function marshallIntOrIdentifier(QtiIntOrIdentifier $intOrIdentifier): array { return ['base' => ['intOrIdentifier' => $intOrIdentifier->getValue()]]; } @@ -327,7 +327,7 @@ protected function marshallIntOrIdentifier(QtiIntOrIdentifier $intOrIdentifier) * @param QtiPoint $point * @return array */ - protected function marshallPoint(QtiPoint $point) + protected function marshallPoint(QtiPoint $point): array { return ['base' => ['point' => [$point->getX(), $point->getY()]]]; } @@ -338,7 +338,7 @@ protected function marshallPoint(QtiPoint $point) * @param QtiDirectedPair $directedPair * @return array */ - protected function marshallDirectedPair(QtiDirectedPair $directedPair) + protected function marshallDirectedPair(QtiDirectedPair $directedPair): array { return ['base' => ['directedPair' => [$directedPair->getFirst(), $directedPair->getSecond()]]]; } @@ -349,7 +349,7 @@ protected function marshallDirectedPair(QtiDirectedPair $directedPair) * @param QtiPair $pair * @return array */ - protected function marshallPair(QtiPair $pair) + protected function marshallPair(QtiPair $pair): array { return ['base' => ['pair' => [$pair->getFirst(), $pair->getSecond()]]]; } @@ -360,7 +360,7 @@ protected function marshallPair(QtiPair $pair) * @param QtiDuration $duration * @return array */ - protected function marshallDuration(QtiDuration $duration) + protected function marshallDuration(QtiDuration $duration): array { return ['base' => ['duration' => $duration->__toString()]]; } @@ -371,7 +371,7 @@ protected function marshallDuration(QtiDuration $duration) * @param QtiFile $file * @return array */ - protected function marshallFile(QtiFile $file) + protected function marshallFile(QtiFile $file): array { $data = [ 'base' => [ @@ -396,7 +396,7 @@ protected function marshallFile(QtiFile $file) * @param FileHash $file * @return array */ - protected function marshallFileHash(FileHash $file) + protected function marshallFileHash(FileHash $file): array { return [ 'base' => [ diff --git a/src/qtism/runtime/pci/json/MarshallingException.php b/src/qtism/runtime/pci/json/MarshallingException.php index f5af92505..13839ea91 100644 --- a/src/qtism/runtime/pci/json/MarshallingException.php +++ b/src/qtism/runtime/pci/json/MarshallingException.php @@ -32,9 +32,9 @@ */ class MarshallingException extends Exception implements QtiSdkPackageContentException { - const UNKNOWN = 0; + public const UNKNOWN = 0; - const NOT_SUPPORTED = 1; + public const NOT_SUPPORTED = 1; /** * Create a new MarshallingException object. diff --git a/src/qtism/runtime/pci/json/Unmarshaller.php b/src/qtism/runtime/pci/json/Unmarshaller.php index 7907e297c..b1be458cf 100644 --- a/src/qtism/runtime/pci/json/Unmarshaller.php +++ b/src/qtism/runtime/pci/json/Unmarshaller.php @@ -81,7 +81,7 @@ public function __construct(FileManager $fileManager) * * @param FileManager $fileManager A FileManager object. */ - protected function setFileManager(FileManager $fileManager) + protected function setFileManager(FileManager $fileManager): void { $this->fileManager = $fileManager; } @@ -92,7 +92,7 @@ protected function setFileManager(FileManager $fileManager) * * @return FileManager A FileManager object. */ - protected function getFileManager() + protected function getFileManager(): FileManager { return $this->fileManager; } @@ -193,7 +193,7 @@ public function unmarshall($json) * @throws FileManagerException * @throws UnmarshallingException */ - protected function unmarshallUnit(array $unit) + protected function unmarshallUnit(array $unit): ?QtiDatatype { if ($unit['base'] === null) { return null; @@ -271,7 +271,7 @@ protected function unmarshallUnit(array $unit) * @param array $unit * @return QtiBoolean */ - protected function unmarshallBoolean(array $unit) + protected function unmarshallBoolean(array $unit): QtiBoolean { return new QtiBoolean($unit['base']['boolean']); } @@ -282,7 +282,7 @@ protected function unmarshallBoolean(array $unit) * @param array $unit * @return QtiInteger */ - protected function unmarshallInteger(array $unit) + protected function unmarshallInteger(array $unit): QtiInteger { return new QtiInteger($unit['base']['integer']); } @@ -293,7 +293,7 @@ protected function unmarshallInteger(array $unit) * @param array $unit * @return QtiFloat */ - protected function unmarshallFloat(array $unit) + protected function unmarshallFloat(array $unit): QtiFloat { $val = $unit['base']['float']; @@ -310,7 +310,7 @@ protected function unmarshallFloat(array $unit) * @param array $unit * @return QtiString */ - protected function unmarshallString(array $unit) + protected function unmarshallString(array $unit): QtiString { return new QtiString($unit['base']['string']); } @@ -321,7 +321,7 @@ protected function unmarshallString(array $unit) * @param array $unit * @return QtiPoint */ - protected function unmarshallPoint(array $unit) + protected function unmarshallPoint(array $unit): QtiPoint { return new QtiPoint($unit['base']['point'][0], $unit['base']['point'][1]); } @@ -332,7 +332,7 @@ protected function unmarshallPoint(array $unit) * @param array $unit * @return QtiPair */ - protected function unmarshallPair(array $unit) + protected function unmarshallPair(array $unit): QtiPair { return new QtiPair($unit['base']['pair'][0], $unit['base']['pair'][1]); } @@ -343,7 +343,7 @@ protected function unmarshallPair(array $unit) * @param array $unit * @return QtiDirectedPair */ - protected function unmarshallDirectedPair(array $unit) + protected function unmarshallDirectedPair(array $unit): QtiDirectedPair { return new QtiDirectedPair($unit['base']['directedPair'][0], $unit['base']['directedPair'][1]); } @@ -354,7 +354,7 @@ protected function unmarshallDirectedPair(array $unit) * @param array $unit * @return QtiDuration */ - protected function unmarshallDuration(array $unit) + protected function unmarshallDuration(array $unit): QtiDuration { return new QtiDuration($unit['base']['duration']); } @@ -366,7 +366,7 @@ protected function unmarshallDuration(array $unit) * @return QtiFile * @throws FileManagerException */ - protected function unmarshallFile(array $unit) + protected function unmarshallFile(array $unit): QtiFile { $fileArray = $unit['base']['file']; return $this->getFileManager()->createFromData( @@ -391,7 +391,7 @@ protected function unmarshallFile(array $unit) * @return QtiFile * @throws FileManagerException */ - protected function unmarshallFileHash(array $unit) + protected function unmarshallFileHash(array $unit): QtiFile { $fileHashArray = $unit['base'][FileHash::FILE_HASH_KEY]; if (empty($fileHashArray['id'])) { @@ -412,7 +412,7 @@ protected function unmarshallFileHash(array $unit) * @param array $unit * @return QtiUri */ - protected function unmarshallUri(array $unit) + protected function unmarshallUri(array $unit): QtiUri { return new QtiUri($unit['base']['uri']); } @@ -423,7 +423,7 @@ protected function unmarshallUri(array $unit) * @param array $unit * @return QtiIntOrIdentifier */ - protected function unmarshallIntOrIdentifier(array $unit) + protected function unmarshallIntOrIdentifier(array $unit): QtiIntOrIdentifier { return new QtiIntOrIdentifier($unit['base']['intOrIdentifier']); } @@ -434,7 +434,7 @@ protected function unmarshallIntOrIdentifier(array $unit) * @param array $unit * @return QtiIdentifier */ - protected function unmarshallIdentifier(array $unit) + protected function unmarshallIdentifier(array $unit): QtiIdentifier { return new QtiIdentifier($unit['base']['identifier']); } @@ -448,7 +448,7 @@ protected function unmarshallIdentifier(array $unit) * @throws FileManagerException * @throws UnmarshallingException */ - protected function unmarshallList(array $parsedJson) + protected function unmarshallList(array $parsedJson): MultipleContainer { $list = $parsedJson['list']; $key = key($list); diff --git a/src/qtism/runtime/pci/json/UnmarshallingException.php b/src/qtism/runtime/pci/json/UnmarshallingException.php index 0468f1bc4..aeea98c92 100644 --- a/src/qtism/runtime/pci/json/UnmarshallingException.php +++ b/src/qtism/runtime/pci/json/UnmarshallingException.php @@ -31,13 +31,13 @@ */ class UnmarshallingException extends Exception { - const UNKNOWN = 0; + public const UNKNOWN = 0; - const NOT_SUPPORTED = 1; + public const NOT_SUPPORTED = 1; - const JSON_DECODE = 2; + public const JSON_DECODE = 2; - const NOT_PCI = 3; + public const NOT_PCI = 3; /** * Create a new UnmarshallingException object. diff --git a/src/qtism/runtime/processing/OutcomeProcessingEngine.php b/src/qtism/runtime/processing/OutcomeProcessingEngine.php index ac41d93ff..4e615d9f9 100644 --- a/src/qtism/runtime/processing/OutcomeProcessingEngine.php +++ b/src/qtism/runtime/processing/OutcomeProcessingEngine.php @@ -83,7 +83,7 @@ public function __construct(QtiComponent $outcomeProcessing, State $context = nu * @param QtiComponent $outcomeProcessing An OutcomeProcessing object. * @throws InvalidArgumentException If $outcomeProcessing is not An OutcomeProcessing object. */ - public function setComponent(QtiComponent $outcomeProcessing) + public function setComponent(QtiComponent $outcomeProcessing): void { if ($outcomeProcessing instanceof OutcomeProcessing) { parent::setComponent($outcomeProcessing); @@ -98,7 +98,7 @@ public function setComponent(QtiComponent $outcomeProcessing) * * @param RuleProcessorFactory $ruleProcessorFactory A RuleProcessorFactory object. */ - public function setRuleProcessorFactory(RuleProcessorFactory $ruleProcessorFactory) + public function setRuleProcessorFactory(RuleProcessorFactory $ruleProcessorFactory): void { $this->ruleProcessorFactory = $ruleProcessorFactory; } @@ -108,7 +108,7 @@ public function setRuleProcessorFactory(RuleProcessorFactory $ruleProcessorFacto * * @return RuleProcessorFactory A RuleProcessorFactory object. */ - public function getRuleProcessorFactory() + public function getRuleProcessorFactory(): RuleProcessorFactory { return $this->ruleProcessorFactory; } @@ -123,7 +123,7 @@ public function getRuleProcessorFactory() * * @throws ProcessingException If an error occurs while executing the OutcomeProcessing. */ - public function process() + public function process(): void { $context = $this->getContext(); diff --git a/src/qtism/runtime/processing/PrintedVariableEngine.php b/src/qtism/runtime/processing/PrintedVariableEngine.php index a48ae560e..e6b230e8d 100644 --- a/src/qtism/runtime/processing/PrintedVariableEngine.php +++ b/src/qtism/runtime/processing/PrintedVariableEngine.php @@ -84,7 +84,7 @@ class PrintedVariableEngine extends AbstractEngine * @param QtiComponent $printedVariable A PrintedVariable object. * @throws InvalidArgumentException If $printedVariable is not a PrintedVariable object. */ - public function setComponent(QtiComponent $printedVariable) + public function setComponent(QtiComponent $printedVariable): void { if ($printedVariable instanceof PrintedVariable) { parent::setComponent($printedVariable); @@ -104,7 +104,7 @@ public function setComponent(QtiComponent $printedVariable) * @return string A processed PrintedVariable as a string or the NULL value if the variable's value is NULL. * @throws PrintedVariableProcessingException If an error occurs while processing the PrintedVariable object into a TextRun object. */ - public function process() + public function process(): string { /** @var PrintedVariable $printedVariable */ $printedVariable = $this->getComponent(); @@ -173,7 +173,7 @@ public function process() * @param Variable $variable The ordered/multiple container Variable to process. * @return string All the values delimited by printedVariable->delimiter. */ - private function processOrderedMultiple(Variable $variable) + private function processOrderedMultiple(Variable $variable): string { $processedValues = []; $baseType = $variable->getBaseType(); @@ -192,7 +192,7 @@ private function processOrderedMultiple(Variable $variable) * @param Variable $variable The record to process. * @return string All the key/values delimited by printedVariable->delimiter. Indicator between keys and values is defined by printedVariable->mappingIndicator. */ - private function processRecord(Variable $variable) + private function processRecord(Variable $variable): string { $processedValues = []; $baseType = $variable->getBaseType(); @@ -213,7 +213,7 @@ private function processRecord(Variable $variable) * @return string * @throws PrintedVariableProcessingException If the baseType is unknown. */ - private function processValue($baseType, $value) + private function processValue($baseType, $value): string { /** @var PrintedVariable $printedVariable */ $printedVariable = $this->getComponent(); @@ -233,7 +233,7 @@ private function processValue($baseType, $value) } if ($baseType === BaseType::STRING) { - return $value->getValue(); + return (string)$value->getValue(); } elseif ($baseType === BaseType::INTEGER || $baseType === BaseType::FLOAT) { $format = $printedVariable->getFormat(); @@ -245,10 +245,10 @@ private function processValue($baseType, $value) return sprintf('%e', $value->getValue()); } else { // integer to string - return '' . $value->getValue(); + return (string)$value->getValue(); } } elseif ($baseType === BaseType::DURATION) { - return '' . $value->getSeconds(true); + return (string)$value->getSeconds(true); } elseif ($baseType === BaseType::BOOLEAN) { return ($value->getValue() === true) ? 'true' : 'false'; } elseif ($baseType === BaseType::POINT || $baseType === BaseType::PAIR || $baseType === BaseType::DIRECTED_PAIR) { diff --git a/src/qtism/runtime/processing/PrintedVariableProcessingException.php b/src/qtism/runtime/processing/PrintedVariableProcessingException.php index 01ef9c55c..f4b7eeaa1 100644 --- a/src/qtism/runtime/processing/PrintedVariableProcessingException.php +++ b/src/qtism/runtime/processing/PrintedVariableProcessingException.php @@ -38,7 +38,7 @@ class PrintedVariableProcessingException extends ProcessingException * @param Processable $source The source of the error. * @throws InvalidArgumentException If $source is not a PrintedVariableEngine object. */ - public function setSource(Processable $source) + public function setSource(Processable $source): void { if ($source instanceof PrintedVariableEngine) { parent::setSource($source); diff --git a/src/qtism/runtime/processing/ResponseProcessingEngine.php b/src/qtism/runtime/processing/ResponseProcessingEngine.php index e096733c9..96e726745 100644 --- a/src/qtism/runtime/processing/ResponseProcessingEngine.php +++ b/src/qtism/runtime/processing/ResponseProcessingEngine.php @@ -26,6 +26,7 @@ use InvalidArgumentException; use qtism\data\processing\ResponseProcessing; use qtism\data\QtiComponent; +use qtism\data\rules\ResponseRuleCollection; use qtism\data\storage\php\PhpDocument; use qtism\data\storage\php\PhpStorageException; use qtism\runtime\common\AbstractEngine; @@ -83,7 +84,7 @@ public function __construct(QtiComponent $responseProcessing, State $context = n * @param QtiComponent $responseProcessing A ResponseProcessing object. * @throws InvalidArgumentException If $responseProcessing is not a ResponseProcessing object. */ - public function setComponent(QtiComponent $responseProcessing) + public function setComponent(QtiComponent $responseProcessing): void { if ($responseProcessing instanceof ResponseProcessing) { parent::setComponent($responseProcessing); @@ -100,7 +101,7 @@ public function setComponent(QtiComponent $responseProcessing) * @param string $url The actual template URL, i.e. where to find the file containing the template markup. * @throws InvalidArgumentException If $uri or $url are not strings. */ - public function addTemplateMapping($uri, $url) + public function addTemplateMapping($uri, $url): void { if (!is_string($uri)) { $msg = "The uri argument must be a string, '" . gettype($uri) . "' given."; @@ -123,7 +124,7 @@ public function addTemplateMapping($uri, $url) * @param string $uri The $uri you want to remove the mapping. * @throws InvalidArgumentException If $uri is not a string. */ - public function removeTemplateMapping($uri) + public function removeTemplateMapping($uri): void { if (!is_string($uri)) { $msg = "The uri argument must be a string, '" . gettype($uri) . "' given."; @@ -142,7 +143,7 @@ public function removeTemplateMapping($uri) * * @return array An array where keys are template URIs and values template URL (their location). */ - protected function &getTemplateMapping() + protected function &getTemplateMapping(): array { return $this->templateMapping; } @@ -158,7 +159,7 @@ protected function &getTemplateMapping() * * @throws PhpStorageException */ - public function process() + public function process(): void { $rules = $this->getResponseProcessingRules(); $processingCollectionException = null; @@ -193,7 +194,7 @@ public function process() * @return mixed * @throws PhpStorageException */ - public function getResponseProcessingRules() + public function getResponseProcessingRules(): ResponseRuleCollection { // @todo Figure out how to provide a way to the ResponseProcessingEngine to know the folder where to seek for templateLocation, which is a relative URI. $responseProcessing = $this->getComponent(); diff --git a/src/qtism/runtime/processing/ResponseProcessingException.php b/src/qtism/runtime/processing/ResponseProcessingException.php index 58d27823d..b59601e25 100644 --- a/src/qtism/runtime/processing/ResponseProcessingException.php +++ b/src/qtism/runtime/processing/ResponseProcessingException.php @@ -38,7 +38,7 @@ class ResponseProcessingException extends ProcessingException * * @var int */ - const TEMPLATE_NOT_FOUND = 11; + public const TEMPLATE_NOT_FOUND = 11; /** * Error code to use when a response processing @@ -46,7 +46,7 @@ class ResponseProcessingException extends ProcessingException * * @var int */ - const TEMPLATE_ERROR = 12; + public const TEMPLATE_ERROR = 12; /** * Set the source of the error. @@ -54,7 +54,7 @@ class ResponseProcessingException extends ProcessingException * @param Processable $source The source of the error. * @throws InvalidArgumentException If $source is not a ResponseProcessingEngine object. */ - public function setSource(Processable $source) + public function setSource(Processable $source): void { if ($source instanceof ResponseProcessingEngine) { parent::setSource($source); diff --git a/src/qtism/runtime/processing/TemplateProcessingEngine.php b/src/qtism/runtime/processing/TemplateProcessingEngine.php index a78c6d0e4..9e2ac892d 100644 --- a/src/qtism/runtime/processing/TemplateProcessingEngine.php +++ b/src/qtism/runtime/processing/TemplateProcessingEngine.php @@ -66,7 +66,7 @@ public function __construct(QtiComponent $templateProcessing, State $context = n * @param QtiComponent $templateProcessing A TemplateProcessing object. * @throws InvalidArgumentException If $templateProcessing is not A TemplateProcessing object. */ - public function setComponent(QtiComponent $templateProcessing) + public function setComponent(QtiComponent $templateProcessing): void { if ($templateProcessing instanceof TemplateProcessing) { parent::setComponent($templateProcessing); @@ -81,7 +81,7 @@ public function setComponent(QtiComponent $templateProcessing) * * @param RuleProcessorFactory $ruleProcessorFactory A RuleProcessorFactory object. */ - public function setRuleProcessorFactory(RuleProcessorFactory $ruleProcessorFactory) + public function setRuleProcessorFactory(RuleProcessorFactory $ruleProcessorFactory): void { $this->ruleProcessorFactory = $ruleProcessorFactory; } @@ -91,7 +91,7 @@ public function setRuleProcessorFactory(RuleProcessorFactory $ruleProcessorFacto * * @return RuleProcessorFactory A RuleProcessorFactory object. */ - public function getRuleProcessorFactory() + public function getRuleProcessorFactory(): RuleProcessorFactory { return $this->ruleProcessorFactory; } @@ -101,7 +101,7 @@ public function getRuleProcessorFactory() * * @throws ProcessingException If an error occurs while executing the TemplateProcessing. */ - public function process() + public function process(): void { $context = $this->getContext(); /** @var TemplateProcessing $templateProcessing */ diff --git a/src/qtism/runtime/processing/Utils.php b/src/qtism/runtime/processing/Utils.php index d286f9033..f9d3d497a 100644 --- a/src/qtism/runtime/processing/Utils.php +++ b/src/qtism/runtime/processing/Utils.php @@ -43,7 +43,7 @@ class Utils * @param TemplateProcessing $templateProcessing * @return array A list of QTI identifiers. */ - public static function templateProcessingImpactedVariables(TemplateProcessing $templateProcessing) + public static function templateProcessingImpactedVariables(TemplateProcessing $templateProcessing): array { $identifiers = []; $classNames = [ diff --git a/src/qtism/runtime/rendering/Renderable.php b/src/qtism/runtime/rendering/Renderable.php index af00645ee..b67fd89ff 100644 --- a/src/qtism/runtime/rendering/Renderable.php +++ b/src/qtism/runtime/rendering/Renderable.php @@ -35,5 +35,6 @@ interface Renderable * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ + #[\ReturnTypeWillChange] public function render($something); } diff --git a/src/qtism/runtime/rendering/RenderingException.php b/src/qtism/runtime/rendering/RenderingException.php index d282be30d..8e85616af 100644 --- a/src/qtism/runtime/rendering/RenderingException.php +++ b/src/qtism/runtime/rendering/RenderingException.php @@ -40,7 +40,7 @@ class RenderingException extends Exception implements QtiSdkPackageContentExcept * * @var int */ - const UNKNOWN = 0; + public const UNKNOWN = 0; /** * Error code to use when no renderer is found @@ -48,14 +48,14 @@ class RenderingException extends Exception implements QtiSdkPackageContentExcept * * @var int */ - const NO_RENDERER = 1; + public const NO_RENDERER = 1; /** * Error code to use for exception only occuring/detectable at runtime. * * @var int */ - const RUNTIME = 2; + public const RUNTIME = 2; /** * Create a new RenderingException object. diff --git a/src/qtism/runtime/rendering/css/CssScoper.php b/src/qtism/runtime/rendering/css/CssScoper.php index be2b52962..94ba73060 100644 --- a/src/qtism/runtime/rendering/css/CssScoper.php +++ b/src/qtism/runtime/rendering/css/CssScoper.php @@ -35,49 +35,49 @@ */ class CssScoper implements Renderable { - const RUNNING = 0; + public const RUNNING = 0; - const IN_ATRULE = 1; + public const IN_ATRULE = 1; - const IN_ATRULESTRING = 2; + public const IN_ATRULESTRING = 2; - const IN_MAINCOMMENT = 3; + public const IN_MAINCOMMENT = 3; - const IN_SELECTOR = 4; + public const IN_SELECTOR = 4; - const IN_CLASSBODY = 5; + public const IN_CLASSBODY = 5; - const IN_CLASSSTRING = 6; + public const IN_CLASSSTRING = 6; - const IN_CLASSCOMMENT = 7; + public const IN_CLASSCOMMENT = 7; - const IN_ATRULEBODY = 8; + public const IN_ATRULEBODY = 8; - const CHAR_AT = '@'; + public const CHAR_AT = '@'; - const CHAR_DOUBLEQUOTE = '"'; + public const CHAR_DOUBLEQUOTE = '"'; - const CHAR_TERMINATOR = ';'; + public const CHAR_TERMINATOR = ';'; - const CHAR_ESCAPE = "\\"; + public const CHAR_ESCAPE = "\\"; - const CHAR_TAB = "\t"; + public const CHAR_TAB = "\t"; - const CHAR_SPACE = ' '; + public const CHAR_SPACE = ' '; - const CHAR_NEWLINE = "\n"; + public const CHAR_NEWLINE = "\n"; - const CHAR_CARRIAGERETURN = "\r"; + public const CHAR_CARRIAGERETURN = "\r"; - const CHAR_VERTICALTAB = "\v"; + public const CHAR_VERTICALTAB = "\v"; - const CHAR_OPENINGBRACE = '{'; + public const CHAR_OPENINGBRACE = '{'; - const CHAR_CLOSINGBRACE = '}'; + public const CHAR_CLOSINGBRACE = '}'; - const CHAR_STAR = '*'; + public const CHAR_STAR = '*'; - const CHAR_SLASH = '/'; + public const CHAR_SLASH = '/'; /** * The current state. @@ -350,7 +350,7 @@ public function __construct($mapQtiClasses = false, $mapQtiPseudoClasses = false * * @return bool */ - public function doesMapQtiClasses() + public function doesMapQtiClasses(): bool { return $this->mapQtiClasses; } @@ -360,7 +360,7 @@ public function doesMapQtiClasses() * * @param bool $mapQtiClasses */ - public function mapQtiClasses($mapQtiClasses) + public function mapQtiClasses($mapQtiClasses): void { $this->mapQtiClasses = $mapQtiClasses; } @@ -370,7 +370,7 @@ public function mapQtiClasses($mapQtiClasses) * * @return bool */ - public function doesMapQtiPseudoClasses() + public function doesMapQtiPseudoClasses(): bool { return $this->mapQtiPseudoClasses; } @@ -380,7 +380,7 @@ public function doesMapQtiPseudoClasses() * * @param bool $mapQtiPseudoClasses */ - public function mapQtiPseudoClasses($mapQtiPseudoClasses) + public function mapQtiPseudoClasses($mapQtiPseudoClasses): void { $this->mapQtiPseudoClasses = $mapQtiPseudoClasses; } @@ -388,7 +388,7 @@ public function mapQtiPseudoClasses($mapQtiPseudoClasses) /** * @param $webComponentFriendly */ - public function setWebComponentFriendly($webComponentFriendly) + public function setWebComponentFriendly($webComponentFriendly): void { $this->webComponentFriendly = $webComponentFriendly; } @@ -396,7 +396,7 @@ public function setWebComponentFriendly($webComponentFriendly) /** * @return bool */ - public function isWebComponentFriendly() + public function isWebComponentFriendly(): bool { return $this->webComponentFriendly; } @@ -410,7 +410,7 @@ public function isWebComponentFriendly() * @throws MemoryStreamException * @throws RenderingException If something goes wrong while rescoping the content. */ - public function render($file, $id = '') + public function render($file, $id = ''): string { if (empty($id)) { $id = uniqid(); @@ -484,7 +484,7 @@ public function render($file, $id = '') * @throws MemoryStreamException * @throws RenderingException */ - protected function init($id, $file) + protected function init($id, $file): void { $this->setState(self::RUNNING); $this->setId($id); @@ -507,7 +507,7 @@ protected function init($id, $file) * * @param int $state */ - protected function setState($state) + protected function setState($state): void { $this->state = $state; } @@ -517,7 +517,7 @@ protected function setState($state) * * @return int */ - protected function getState() + protected function getState(): int { return $this->state; } @@ -527,7 +527,7 @@ protected function getState() * * @param string $id */ - protected function setId($id) + protected function setId($id): void { $this->id = $id; } @@ -537,7 +537,7 @@ protected function setId($id) * * @return string */ - protected function getId() + protected function getId(): string { return $this->id; } @@ -547,7 +547,7 @@ protected function getId() * * @param MemoryStream $stream */ - protected function setStream(MemoryStream $stream) + protected function setStream(MemoryStream $stream): void { $this->stream = $stream; } @@ -557,7 +557,7 @@ protected function setStream(MemoryStream $stream) * * @return MemoryStream */ - protected function getStream() + protected function getStream(): MemoryStream { return $this->stream; } @@ -567,7 +567,7 @@ protected function getStream() * * @param string $char */ - protected function beforeCharReading($char) + protected function beforeCharReading($char): void { $this->setCurrentChar($char); } @@ -577,7 +577,7 @@ protected function beforeCharReading($char) * * @param string $char */ - protected function afterCharReading($char) + protected function afterCharReading($char): void { $this->setPreviousChar($char); @@ -591,7 +591,7 @@ protected function afterCharReading($char) * * @param string $char */ - protected function setPreviousSignificantChar($char) + protected function setPreviousSignificantChar($char): void { $this->previousSignificantChar = $char; } @@ -601,7 +601,7 @@ protected function setPreviousSignificantChar($char) * * @return string */ - protected function getPreviousChar() + protected function getPreviousChar(): string { return $this->previousChar; } @@ -611,7 +611,7 @@ protected function getPreviousChar() * * @param string $char */ - protected function setPreviousChar($char) + protected function setPreviousChar($char): void { $this->previousChar = $char; } @@ -621,7 +621,7 @@ protected function setPreviousChar($char) * * @param string $char */ - protected function setCurrentChar($char) + protected function setCurrentChar($char): void { $this->currentChar = $char; } @@ -631,7 +631,7 @@ protected function setCurrentChar($char) * * @return string $char A char or false if no current char is set. */ - protected function getCurrentChar() + protected function getCurrentChar(): string { return $this->currentChar; } @@ -645,7 +645,7 @@ protected function getCurrentChar() * * @return array */ - protected static function getQtiClassMapping() + protected static function getQtiClassMapping(): array { return self::$qtiClassMapping; } @@ -659,7 +659,7 @@ protected static function getQtiClassMapping() * * @return array */ - protected static function getQtiPseudoClassMapping() + protected static function getQtiPseudoClassMapping(): array { return self::$qtiPseudoClassMapping; } @@ -667,7 +667,7 @@ protected static function getQtiPseudoClassMapping() /** * Instructions to be performed in 'running' state. */ - protected function runningState() + protected function runningState(): void { $char = $this->getCurrentChar(); @@ -691,7 +691,7 @@ protected function runningState() /** * Instructions to be performed in 'atRule' state. */ - protected function inAtRuleState() + protected function inAtRuleState(): void { $char = $this->getCurrentChar(); @@ -717,7 +717,7 @@ protected function inAtRuleState() /** * Instructions to be performed in 'atRuleString' state. */ - protected function inAtRuleStringState() + protected function inAtRuleStringState(): void { $char = $this->getCurrentChar(); @@ -736,7 +736,7 @@ protected function inAtRuleStringState() /** * Instructions to be performed in 'atRuleBody' state. */ - protected function inAtRuleBodyState() + protected function inAtRuleBodyState(): void { $char = $this->getCurrentChar(); @@ -761,7 +761,7 @@ protected function inAtRuleBodyState() /** * Instructions to be performed in 'selector' state. */ - protected function inSelectorState() + protected function inSelectorState(): void { $char = $this->getCurrentChar(); @@ -777,7 +777,7 @@ protected function inSelectorState() /** * Instructions to be performed in 'classBody' state. */ - protected function inClassBodyState() + protected function inClassBodyState(): void { $char = $this->getCurrentChar(); @@ -795,7 +795,7 @@ protected function inClassBodyState() /** * Instructions to be performed in 'mainComment' state. */ - protected function inMainCommentState() + protected function inMainCommentState(): void { $char = $this->getCurrentChar(); @@ -809,7 +809,7 @@ protected function inMainCommentState() /** * Instructions to be performed in 'classComment' state. */ - protected function inClassCommentState() + protected function inClassCommentState(): void { $char = $this->getCurrentChar(); @@ -823,7 +823,7 @@ protected function inClassCommentState() /** * Instructions to be performed in 'classString' state. */ - protected function inClassStringState() + protected function inClassStringState(): void { $char = $this->getCurrentChar(); @@ -845,7 +845,7 @@ protected function inClassStringState() * @param string $char * @return bool */ - private static function isWhiteSpace($char) + private static function isWhiteSpace($char): bool { return $char === self::CHAR_SPACE || $char === self::CHAR_CARRIAGERETURN || $char === self::CHAR_NEWLINE || $char === self::CHAR_TAB || $char === self::CHAR_VERTICALTAB; } @@ -855,7 +855,7 @@ private static function isWhiteSpace($char) * * @return array */ - protected function getBuffer() + protected function getBuffer(): array { return $this->buffer; } @@ -865,7 +865,7 @@ protected function getBuffer() * * @param array $buffer */ - protected function setBuffer(array $buffer) + protected function setBuffer(array $buffer): void { $this->buffer = $buffer; } @@ -873,7 +873,7 @@ protected function setBuffer(array $buffer) /** * Clean the read buffer. */ - protected function cleanBuffer() + protected function cleanBuffer(): void { $this->setBuffer([]); } @@ -883,7 +883,7 @@ protected function cleanBuffer() * * @param string $char */ - protected function bufferize($char) + protected function bufferize($char): void { $buffer = $this->getBuffer(); $buffer[] = $char; @@ -895,7 +895,7 @@ protected function bufferize($char) * * @param string $output */ - protected function setOutput($output) + protected function setOutput($output): void { $this->output = $output; } @@ -905,7 +905,7 @@ protected function setOutput($output) * * @return string */ - protected function getOutput() + protected function getOutput(): string { return $this->output; } @@ -915,7 +915,7 @@ protected function getOutput() * * @param string $char */ - protected function output($char) + protected function output($char): void { $output = $this->getOutput(); $output .= $char; @@ -927,7 +927,7 @@ protected function output($char) * * @return bool */ - protected function isEscaping() + protected function isEscaping(): bool { $count = count($this->getBuffer()); @@ -944,7 +944,7 @@ protected function isEscaping() * Update the currently processed CSS selector by prefixing it * with the appropriate id. */ - protected function updateSelector() + protected function updateSelector(): void { $buffer = implode('', $this->getBuffer()); $qtiClassMap = ($this->isWebComponentFriendly()) ? array_merge(self::$qtiClassMapping, self::$wcFriendlyQtiClassMapping) : self::$qtiClassMapping; diff --git a/src/qtism/runtime/rendering/css/Utils.php b/src/qtism/runtime/rendering/css/Utils.php index 0939b0cef..cd07849b7 100644 --- a/src/qtism/runtime/rendering/css/Utils.php +++ b/src/qtism/runtime/rendering/css/Utils.php @@ -44,7 +44,7 @@ class Utils * @param array $map A QTI to XHTML CSS class map. * @return string */ - public static function mapSelector($selector, array $map) + public static function mapSelector($selector, array $map): string { foreach ($map as $k => $v) { $pattern = "/(?:(^|\s|\+|,|~|>)(${k})(\$|\s|,|\+|\.|\~|>|:|\[))/u"; diff --git a/src/qtism/runtime/rendering/markup/AbstractMarkupRenderer.php b/src/qtism/runtime/rendering/markup/AbstractMarkupRenderer.php index cc314032b..4746513ad 100644 --- a/src/qtism/runtime/rendering/markup/AbstractMarkupRenderer.php +++ b/src/qtism/runtime/rendering/markup/AbstractMarkupRenderer.php @@ -52,7 +52,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul /** * @param AbstractMarkupRenderingEngine|null $renderingEngine */ - public function setRenderingEngine(AbstractMarkupRenderingEngine $renderingEngine = null) + public function setRenderingEngine(AbstractMarkupRenderingEngine $renderingEngine = null): void { $this->renderingEngine = $renderingEngine; } @@ -63,7 +63,7 @@ public function setRenderingEngine(AbstractMarkupRenderingEngine $renderingEngin * * @return AbstractMarkupRenderingEngine */ - public function getRenderingEngine() + public function getRenderingEngine(): AbstractMarkupRenderingEngine { return $this->renderingEngine; } @@ -76,7 +76,7 @@ public function getRenderingEngine() * @param string $baseUrl a baseUrl (xml:base). * @return string A transformed URL. */ - protected function transformUri($url, $baseUrl) + protected function transformUri($url, $baseUrl): string { // Only relative URIs must be transformed while // taking xml:base into account. @@ -105,7 +105,7 @@ protected function transformUri($url, $baseUrl) * @param QtiComponent $component * @param DOMNode $node */ - protected function handleXmlBase(QtiComponent $component, DOMNode $node) + protected function handleXmlBase(QtiComponent $component, DOMNode $node): void { if ( $node instanceof DOMElement diff --git a/src/qtism/runtime/rendering/markup/AbstractMarkupRenderingEngine.php b/src/qtism/runtime/rendering/markup/AbstractMarkupRenderingEngine.php index e268bb7ca..c7fee3edf 100644 --- a/src/qtism/runtime/rendering/markup/AbstractMarkupRenderingEngine.php +++ b/src/qtism/runtime/rendering/markup/AbstractMarkupRenderingEngine.php @@ -61,28 +61,28 @@ abstract class AbstractMarkupRenderingEngine implements Renderable * * @var int */ - const CONTEXT_STATIC = 0; + public const CONTEXT_STATIC = 0; /** * Context-aware rendering. * * @var int */ - const CONTEXT_AWARE = 1; + public const CONTEXT_AWARE = 1; /** * Template oriented rendering. * * @var int */ - const TEMPLATE_ORIENTED = 2; + public const TEMPLATE_ORIENTED = 2; /** * Ignore xml:base constraints. * * @var int */ - const XMLBASE_IGNORE = 3; + public const XMLBASE_IGNORE = 3; /** * Keep xml:base in final rendering, @@ -90,7 +90,7 @@ abstract class AbstractMarkupRenderingEngine implements Renderable * * @var int */ - const XMLBASE_KEEP = 4; + public const XMLBASE_KEEP = 4; /** * Process all URL resolutions by taking @@ -99,7 +99,7 @@ abstract class AbstractMarkupRenderingEngine implements Renderable * * @var int */ - const XMLBASE_PROCESS = 5; + public const XMLBASE_PROCESS = 5; /** * Stylesheet components are rendered at the same place @@ -107,7 +107,7 @@ abstract class AbstractMarkupRenderingEngine implements Renderable * * @var int */ - const STYLESHEET_INLINE = 6; + public const STYLESHEET_INLINE = 6; /** * Stylesheet components are rendered separately and pushed into @@ -115,7 +115,7 @@ abstract class AbstractMarkupRenderingEngine implements Renderable * * @var int */ - const STYLESHEET_SEPARATE = 7; + public const STYLESHEET_SEPARATE = 7; /** * QTI specific CSS classes will be ones related to @@ -123,7 +123,7 @@ abstract class AbstractMarkupRenderingEngine implements Renderable * * @var int */ - const CSSCLASS_CONCRETE = 8; + public const CSSCLASS_CONCRETE = 8; /** * QTI specific CSS classes will be corresponding to the @@ -131,7 +131,7 @@ abstract class AbstractMarkupRenderingEngine implements Renderable * * @var int */ - const CSSCLASS_ABSTRACT = 9; + public const CSSCLASS_ABSTRACT = 9; /** * An array used to 'tag' explored Component object. @@ -326,7 +326,7 @@ public function __construct() * * @return SplStack */ - protected function getExploration() + protected function getExploration(): SplStack { return $this->exploration; } @@ -336,7 +336,7 @@ protected function getExploration() * * @param SplStack $exploration */ - protected function setExploration(SplStack $exploration) + protected function setExploration(SplStack $exploration): void { $this->exploration = $exploration; } @@ -347,7 +347,7 @@ protected function setExploration(SplStack $exploration) * * @return array */ - protected function getExplorationMarker() + protected function getExplorationMarker(): array { return $this->explorationMarker; } @@ -358,7 +358,7 @@ protected function getExplorationMarker() * * @param array $explorationMarker */ - protected function setExplorationMarker(array $explorationMarker) + protected function setExplorationMarker(array $explorationMarker): void { $this->explorationMarker = $explorationMarker; } @@ -368,7 +368,7 @@ protected function setExplorationMarker(array $explorationMarker) * * @return QtiComponent */ - protected function getExploredComponent() + protected function getExploredComponent(): QtiComponent { return $this->exploredComponent; } @@ -378,7 +378,7 @@ protected function getExploredComponent() * * @param QtiComponent $component */ - protected function setExploredComponent(QtiComponent $component = null) + protected function setExploredComponent(QtiComponent $component = null): void { $this->exploredComponent = $component; } @@ -388,7 +388,7 @@ protected function setExploredComponent(QtiComponent $component = null) * * @param mixed $rendering */ - protected function setLastRendering($rendering) + protected function setLastRendering($rendering): void { $this->lastRendering = $rendering; } @@ -398,6 +398,7 @@ protected function setLastRendering($rendering) * * @return mixed */ + #[\ReturnTypeWillChange] protected function getLastRendering() { return $this->lastRendering; @@ -408,7 +409,7 @@ protected function getLastRendering() * * @param Interaction $interaction */ - protected function setCurrentInteraction(Interaction $interaction = null) + protected function setCurrentInteraction(Interaction $interaction = null): void { $this->currentInteraction = $interaction; } @@ -418,7 +419,7 @@ protected function setCurrentInteraction(Interaction $interaction = null) * * @return Interaction */ - protected function getCurrentInteraction() + protected function getCurrentInteraction(): ?Interaction { return $this->currentInteraction; } @@ -429,7 +430,7 @@ protected function getCurrentInteraction() * @return mixed * @throws RenderingException */ - public function render($component, $base = '') + public function render($component, $base = ''): DOMDocument { // Reset the engine to its initial state. $this->reset(); @@ -513,7 +514,7 @@ public function render($component, $base = '') * * @return bool */ - protected function isFinal() + protected function isFinal(): bool { return count($this->getNextExploration()) === 0; } @@ -524,7 +525,7 @@ protected function isFinal() * * @return QtiComponentCollection The children Component object of the currently explored Component object. */ - protected function getNextExploration() + protected function getNextExploration(): QtiComponentCollection { return new QtiComponentCollection(array_reverse($this->getExploredComponent()->getComponents()->getArrayCopy())); } @@ -534,7 +535,7 @@ protected function getNextExploration() * * @return bool */ - protected function isExplored() + protected function isExplored(): bool { return in_array($this->getExploredComponent(), $this->getExplorationMarker(), true); } @@ -542,7 +543,7 @@ protected function isExplored() /** * @param QtiComponent $component */ - protected function markAsExplored(QtiComponent $component) + protected function markAsExplored(QtiComponent $component): void { $marker = $this->getExplorationMarker(); $marker[] = $component; @@ -556,7 +557,7 @@ protected function markAsExplored(QtiComponent $component) * @param QtiComponent $component * @return mixed */ - protected function createFinalRendering(QtiComponent $component) + protected function createFinalRendering(QtiComponent $component): DOMDocument { $dom = $this->getDocument(); if (($last = $this->getLastRendering()) !== null) { @@ -615,7 +616,7 @@ protected function createFinalRendering(QtiComponent $component) * @param string $base the value of xml:base for the node to be processed. * @throws RenderingException If an error occurs while processing the node. */ - protected function processNode($base = '') + protected function processNode($base = ''): void { $component = $this->getExploredComponent(); $renderer = $this->getRenderer($component); @@ -651,7 +652,7 @@ protected function processNode($base = '') * @param QtiComponent $component A Component you want to know if it has to be ignored or not. * @return bool */ - protected function mustIgnoreComponent(QtiComponent $component) + protected function mustIgnoreComponent(QtiComponent $component): bool { // In the list of QTI class names to be ignored? if (in_array($component->getQtiClassName(), $this->getIgnoreClasses())) { @@ -688,7 +689,7 @@ protected function mustIgnoreComponent(QtiComponent $component) * @param QtiComponent $component A TemplateElement or FeedbackElement or Choice element. * @return bool */ - protected function identifierMatches(QtiComponent $component) + protected function identifierMatches(QtiComponent $component): bool { $variableIdentifier = ($component instanceof FeedbackElement || $component instanceof ModalFeedback) ? $component->getOutcomeIdentifier() : $component->getTemplateIdentifier(); $identifier = new QtiIdentifier($component->getIdentifier()); @@ -713,7 +714,7 @@ protected function identifierMatches(QtiComponent $component) * * @param array $renderers */ - protected function setRenderers(array $renderers) + protected function setRenderers(array $renderers): void { $this->renderers = $renderers; } @@ -723,7 +724,7 @@ protected function setRenderers(array $renderers) * * @return array */ - protected function getRenderers() + protected function getRenderers(): ?array { return $this->renderers; } @@ -734,7 +735,7 @@ protected function getRenderers() * * @param array $ignoreClasses */ - protected function setIgnoreClasses(array $ignoreClasses) + protected function setIgnoreClasses(array $ignoreClasses): void { $this->ignoreClasses = $ignoreClasses; } @@ -742,7 +743,7 @@ protected function setIgnoreClasses(array $ignoreClasses) /** * @return array */ - public function getIgnoreClasses() + public function getIgnoreClasses(): array { return $this->ignoreClasses; } @@ -750,7 +751,7 @@ public function getIgnoreClasses() /** * @param $classes */ - public function ignoreQtiClasses($classes) + public function ignoreQtiClasses($classes): void { if (is_string($classes)) { $classes = [$classes]; @@ -769,7 +770,7 @@ public function ignoreQtiClasses($classes) * @param AbstractMarkupRenderer $renderer An AbstractRenderer object. * @param string $ns */ - public function registerRenderer($qtiClassName, AbstractMarkupRenderer $renderer, $ns = 'qtism') + public function registerRenderer($qtiClassName, AbstractMarkupRenderer $renderer, $ns = 'qtism'): void { $renderer->setRenderingEngine($this); $renderers = $this->getRenderers(); @@ -785,7 +786,7 @@ public function registerRenderer($qtiClassName, AbstractMarkupRenderer $renderer * @return AbstractMarkupRenderer The AbstractRenderer implementation to render $component. * @throws RenderingException If no implementation of AbstractRenderer is registered for $component. */ - public function getRenderer(QtiComponent $component) + public function getRenderer(QtiComponent $component): AbstractMarkupRenderer { $renderers = $this->getRenderers(); $className = $component->getQtiClassName(); @@ -806,7 +807,7 @@ public function getRenderer(QtiComponent $component) * * @return SplStack */ - protected function getRenderingStack() + protected function getRenderingStack(): SplStack { return $this->renderingStack; } @@ -817,7 +818,7 @@ protected function getRenderingStack() * * @param SplStack $renderingStack */ - protected function setRenderingStack(SplStack $renderingStack) + protected function setRenderingStack(SplStack $renderingStack): void { $this->renderingStack = $renderingStack; } @@ -828,7 +829,7 @@ protected function setRenderingStack(SplStack $renderingStack) * * @param SplStack $xmlBaseStack */ - protected function setXmlBaseStack(SplStack $xmlBaseStack) + protected function setXmlBaseStack(SplStack $xmlBaseStack): void { $this->xmlBaseStack = $xmlBaseStack; } @@ -839,7 +840,7 @@ protected function setXmlBaseStack(SplStack $xmlBaseStack) * * @return SplStack */ - protected function getXmlBaseStack() + protected function getXmlBaseStack(): SplStack { return $this->xmlBaseStack; } @@ -851,7 +852,7 @@ protected function getXmlBaseStack() * @param QtiComponent $component The $component from which the rendering was made. * @param mixed $rendering A component rendered in another format. */ - public function storeRendering(QtiComponent $component, $rendering) + public function storeRendering(QtiComponent $component, $rendering): void { $this->getRenderingStack()->push([$component, $rendering]); } @@ -862,7 +863,7 @@ public function storeRendering(QtiComponent $component, $rendering) * @param QtiComponent $component A QtiComponent object to be rendered. * @return array */ - public function getChildrenRenderings(QtiComponent $component) + public function getChildrenRenderings(QtiComponent $component): array { $returnValue = []; @@ -887,7 +888,7 @@ public function getChildrenRenderings(QtiComponent $component) * to be ready for reuse i.e. render a new component. However, * configuration such as policies are kept intact. */ - public function reset() + public function reset(): void { $this->choiceCounter = 0; $this->setExploration(new SplStack()); @@ -906,7 +907,7 @@ public function reset() * * @param string $substitution If set, the registered xml:base value will be the value of the argument instead of the currently explored component's xml:base value. */ - protected function registerXmlBase($substitution = '') + protected function registerXmlBase($substitution = ''): void { $c = $this->getExploredComponent(); $toPush = $substitution; @@ -923,7 +924,7 @@ protected function registerXmlBase($substitution = '') * * @return string A URL or the empty string ('') if no base URL could be resolved. */ - protected function resolveXmlBase() + protected function resolveXmlBase(): string { $stack = $this->getXmlBaseStack(); $stack->rewind(); @@ -959,7 +960,7 @@ protected function resolveXmlBase() * @param QtiComponent $component * @return bool */ - protected function mustTemplateFeedbackComponent(QtiComponent $component) + protected function mustTemplateFeedbackComponent(QtiComponent $component): bool { return (self::isFeedback($component) && $this->getFeedbackShowHidePolicy() === self::TEMPLATE_ORIENTED); } @@ -974,7 +975,7 @@ protected function mustTemplateFeedbackComponent(QtiComponent $component) * @param QtiComponent $component * @return bool */ - protected function mustTemplateRubricBlockComponent(QtiComponent $component) + protected function mustTemplateRubricBlockComponent(QtiComponent $component): bool { return (self::isRubricBlock($component) && $this->getViewPolicy() === self::TEMPLATE_ORIENTED); } @@ -989,7 +990,7 @@ protected function mustTemplateRubricBlockComponent(QtiComponent $component) * @param QtiComponent $component * @return bool */ - protected function mustTemplateChoiceComponent(QtiComponent $component) + protected function mustTemplateChoiceComponent(QtiComponent $component): bool { return self::isChoice($component) && $this->getChoiceShowHidePolicy() === self::TEMPLATE_ORIENTED && $component->hasTemplateIdentifier(); } @@ -998,7 +999,7 @@ protected function mustTemplateChoiceComponent(QtiComponent $component) * @param QtiComponent $component * @return bool */ - protected function mustIncludeChoiceComponent(QtiComponent $component) + protected function mustIncludeChoiceComponent(QtiComponent $component): bool { $shufflables = [ 'choiceInteraction', @@ -1025,7 +1026,7 @@ protected function mustIncludeChoiceComponent(QtiComponent $component) * @param QtiComponent $component A QtiComponent object. * @return bool */ - protected static function isFeedback(QtiComponent $component) + protected static function isFeedback(QtiComponent $component): bool { return ($component instanceof FeedbackElement || $component instanceof ModalFeedback); } @@ -1036,7 +1037,7 @@ protected static function isFeedback(QtiComponent $component) * @param QtiComponent $component A QtiComponent object. * @return bool */ - protected static function isChoice(QtiComponent $component) + protected static function isChoice(QtiComponent $component): bool { return $component instanceof Choice; } @@ -1048,7 +1049,7 @@ protected static function isChoice(QtiComponent $component) * @param QtiComponent $component A QtiComponent object. * @return bool */ - protected static function isRubricBlock(QtiComponent $component) + protected static function isRubricBlock(QtiComponent $component): bool { return ($component instanceof RubricBlock); } @@ -1060,7 +1061,7 @@ protected static function isRubricBlock(QtiComponent $component) * @param DOMDocumentFragment $rendering The rendering corresponding to $component. * @throws RenderingException If $component is not an instance of FeedbackElement nor ModalFeedback. */ - protected function templateFeedbackComponent(QtiComponent $component, DOMDocumentFragment $rendering) + protected function templateFeedbackComponent(QtiComponent $component, DOMDocumentFragment $rendering): void { if (self::isFeedback($component) === false) { $msg = 'Cannot template a component which is not an instance of FeedbackElement nor ModalFeedback.'; @@ -1094,7 +1095,7 @@ protected function templateFeedbackComponent(QtiComponent $component, DOMDocumen * @param DOMDocumentFragment $rendering The rendering corresponding to $component. * @throws RenderingException If $component is not an instance of RubricBlock. */ - protected function templateRubricBlockComponent(QtiComponent $component, DOMDocumentFragment $rendering) + protected function templateRubricBlockComponent(QtiComponent $component, DOMDocumentFragment $rendering): void { if (self::isRubricBlock($component) === false) { $msg = 'Cannot template a component which is not an instance of RubricBlock.'; @@ -1127,7 +1128,7 @@ protected function templateRubricBlockComponent(QtiComponent $component, DOMDocu * @param DOMDocumentFragment $rendering The rendering corresponding to $component * @throws RenderingException If $component is not an instance of Choice. */ - protected function templateChoiceComponent(QtiComponent $component, DOMDocumentFragment $rendering) + protected function templateChoiceComponent(QtiComponent $component, DOMDocumentFragment $rendering): void { if (self::isChoice($component) === false) { $msg = 'Cannot template a component which is not an instance of Choice.'; @@ -1158,7 +1159,7 @@ protected function templateChoiceComponent(QtiComponent $component, DOMDocumentF * @param QtiComponent $component * @param DOMDocumentFragment $rendering */ - protected function includeChoiceComponent(QtiComponent $component, DOMDocumentFragment $rendering) + protected function includeChoiceComponent(QtiComponent $component, DOMDocumentFragment $rendering): void { $choiceIndex = $this->choiceCounter; $choiceIdentifier = PhpUtils::doubleQuotedPhpString($component->getIdentifier()); @@ -1181,7 +1182,7 @@ protected function includeChoiceComponent(QtiComponent $component, DOMDocumentFr * @param int $policy AbstractMarkupRenderingEngine::CONTEXT_STATIC or AbstractMarkupRenderingEngine::CONTEXT_AWARE. * @see http://www.imsglobal.org/question/qtiv2p1/imsqti_infov2p1.html#element10271 The qti:choice class. */ - public function setChoiceShowHidePolicy($policy) + public function setChoiceShowHidePolicy($policy): void { $this->choiceShowHidePolicy = $policy; } @@ -1196,7 +1197,7 @@ public function setChoiceShowHidePolicy($policy) * @return int AbstractMarkupRenderingEngine::CONTEXT_STATIC or AbstractMarkupRenderingEngine::CONTEXT_AWARE. * @see http://www.imsglobal.org/question/qtiv2p1/imsqti_infov2p1.html#element10271 The qti:choice class. */ - public function getChoiceShowHidePolicy() + public function getChoiceShowHidePolicy(): int { return $this->choiceShowHidePolicy; } @@ -1210,7 +1211,7 @@ public function getChoiceShowHidePolicy() * * @param int $policy AbstractMarkupRenderingEngine::CONTEXT_STATIC or AbstractMarkupRenderingEngine::CONTEXT_AWARE or AbstractMarkupRenderingEngine::TEMPLATE_ORIENTED. */ - public function setFeedbackShowHidePolicy($policy) + public function setFeedbackShowHidePolicy($policy): void { $this->feedbackShowHidePolicy = $policy; } @@ -1223,7 +1224,7 @@ public function setFeedbackShowHidePolicy($policy) * * @return int AbstractMarkupRenderingEngine::CONTEXT_STATIC or AbstractMarkupRenderingEngine::CONTEXT_AWARE. */ - public function getFeedbackShowHidePolicy() + public function getFeedbackShowHidePolicy(): int { return $this->feedbackShowHidePolicy; } @@ -1237,7 +1238,7 @@ public function getFeedbackShowHidePolicy() * * @param int $policy AbstractMarkupRenderingEngine::CONTEXT_STATIC or AbstractMarkupRenderingEngine::CONTEXT_AWARE. */ - public function setViewPolicy($policy) + public function setViewPolicy($policy): void { $this->viewPolicy = $policy; } @@ -1251,7 +1252,7 @@ public function setViewPolicy($policy) * * @return int AbstractMarkupRenderingEngine::CONTEXT_STATIC or AbstractMarkupRenderingEngine::CONTEXT_AWARE. */ - public function getViewPolicy() + public function getViewPolicy(): int { return $this->viewPolicy; } @@ -1265,7 +1266,7 @@ public function getViewPolicy() * * @param int $printedVariablePolicy AbstractMarkup */ - public function setPrintedVariablePolicy($printedVariablePolicy) + public function setPrintedVariablePolicy($printedVariablePolicy): void { $this->printedVariablePolicy = $printedVariablePolicy; } @@ -1279,7 +1280,7 @@ public function setPrintedVariablePolicy($printedVariablePolicy) * * @return int */ - public function getPrintedVariablePolicy() + public function getPrintedVariablePolicy(): int { return $this->printedVariablePolicy; } @@ -1287,7 +1288,7 @@ public function getPrintedVariablePolicy() /** * @param $shufflingPolicy */ - public function setShufflingPolicy($shufflingPolicy) + public function setShufflingPolicy($shufflingPolicy): void { $this->shufflingPolicy = $shufflingPolicy; } @@ -1295,7 +1296,7 @@ public function setShufflingPolicy($shufflingPolicy) /** * @return int */ - public function getShufflingPolicy() + public function getShufflingPolicy(): int { return $this->shufflingPolicy; } @@ -1310,7 +1311,7 @@ public function getShufflingPolicy() * @param int $xmlBasePolicy AbstractMarkupRenderingEngine::XMLBASE_IGNORE, AbstractMarkupRenderingEngine::XMLBASE_KEEP or AbstractMarkupRenderingEngine::XMLBASE_PROCESS. * @see http://www.w3.org/TR/xmlbase/#syntax W3C XML Base (Second Edition) */ - public function setXmlBasePolicy($xmlBasePolicy) + public function setXmlBasePolicy($xmlBasePolicy): void { $this->xmlBasePolicy = $xmlBasePolicy; } @@ -1325,7 +1326,7 @@ public function setXmlBasePolicy($xmlBasePolicy) * @return int AbstractMarkupRenderingEngine::XMLBASE_IGNORE, AbstractMarkupRenderingEngine::XMLBASE_KEEP or AbstractMarkupRenderingEngine::XMLBASE_PROCESS. * @see http://www.w3.org/TR/xmlbase/#syntax W3C XML Base (Second Edition) */ - public function getXmlBasePolicy() + public function getXmlBasePolicy(): int { return $this->xmlBasePolicy; } @@ -1338,7 +1339,7 @@ public function getXmlBasePolicy() * * @param int $stylesheetPolicy AbstractMarkupRenderingEngine::STYLESHEET_INLINE or AbstractMarkupRenderingEngine::STYLESHEET_SEPARATE. */ - public function setStylesheetPolicy($stylesheetPolicy) + public function setStylesheetPolicy($stylesheetPolicy): void { $this->stylesheetPolicy = $stylesheetPolicy; } @@ -1351,7 +1352,7 @@ public function setStylesheetPolicy($stylesheetPolicy) * * @return int AbstractMarkupRenderingEngine::STYLESHEET_INLINE or AbstractMarkupRenderingEngine::STYLESHEET_SEPARATE. */ - public function getStylesheetPolicy() + public function getStylesheetPolicy(): int { return $this->stylesheetPolicy; } @@ -1364,7 +1365,7 @@ public function getStylesheetPolicy() * * @param int $cssClassPolicy */ - public function setCssClassPolicy($cssClassPolicy) + public function setCssClassPolicy($cssClassPolicy): void { $this->cssClassPolicy = $cssClassPolicy; } @@ -1377,7 +1378,7 @@ public function setCssClassPolicy($cssClassPolicy) * * @return int */ - public function getCssClassPolicy() + public function getCssClassPolicy(): int { return $this->cssClassPolicy; } @@ -1388,7 +1389,7 @@ public function getCssClassPolicy() * * @param string $rootBase A URL. */ - public function setRootBase($rootBase) + public function setRootBase($rootBase): void { $this->rootBase = $rootBase; } @@ -1399,7 +1400,7 @@ public function setRootBase($rootBase) * * @return string A URL. */ - public function getRootBase() + public function getRootBase(): string { return $this->rootBase; } @@ -1410,7 +1411,7 @@ public function getRootBase() * * @param string $stateName A variable name (without the leading dollar sign ('$')). */ - public function setStateName($stateName) + public function setStateName($stateName): void { $this->stateName = $stateName; } @@ -1421,7 +1422,7 @@ public function setStateName($stateName) * * @return string A variable name (without the leading dollar sign('$')). */ - public function getStateName() + public function getStateName(): string { return $this->stateName; } @@ -1432,7 +1433,7 @@ public function getStateName() * * @param string $viewsName A variable name (without the leading dollar sign ('$')). */ - public function setViewsName($viewsName) + public function setViewsName($viewsName): void { $this->viewsName = $viewsName; } @@ -1443,7 +1444,7 @@ public function setViewsName($viewsName) * * @return string A variable name (without the leading dollar sign ('$')). */ - public function getViewsName() + public function getViewsName(): string { return $this->viewsName; } @@ -1454,7 +1455,7 @@ public function getViewsName() * * @return bool */ - protected function hasRootBase() + protected function hasRootBase(): bool { return $this->getRootBase() !== ''; } @@ -1464,7 +1465,7 @@ protected function hasRootBase() * * @param ViewCollection $views A collection of values from the View enumeration. */ - public function setViews(ViewCollection $views) + public function setViews(ViewCollection $views): void { $this->views = $views; } @@ -1474,7 +1475,7 @@ public function setViews(ViewCollection $views) * * @return ViewCollection A collection of values from the View enumeration. */ - public function getViews() + public function getViews(): ViewCollection { return $this->views; } @@ -1484,7 +1485,7 @@ public function getViews() * * @param State $state A State object. */ - public function setState(State $state) + public function setState(State $state): void { $this->state = $state; } @@ -1494,7 +1495,7 @@ public function setState(State $state) * * @return State A State object. */ - public function getState() + public function getState(): State { return $this->state; } @@ -1506,7 +1507,7 @@ public function getState() * * @param DOMDocumentFragment $stylesheets A DOMDocumentFragment object. */ - protected function setStylesheets(DOMDocumentFragment $stylesheets) + protected function setStylesheets(DOMDocumentFragment $stylesheets): void { $this->stylesheets = $stylesheets; } @@ -1525,7 +1526,7 @@ protected function setStylesheets(DOMDocumentFragment $stylesheets) * @return DOMDocumentFragment A DOMDocumentFragment object. * @see XhtmlRenderingEngine::getDocument() The method to get the owner document of the DOMDocument fragment. */ - public function getStylesheets() + public function getStylesheets(): DOMDocumentFragment { return $this->stylesheets; } @@ -1535,7 +1536,7 @@ public function getStylesheets() * * @param DOMDocument $document */ - public function setDocument(DOMDocument $document) + public function setDocument(DOMDocument $document): void { $this->document = $document; } @@ -1545,7 +1546,7 @@ public function setDocument(DOMDocument $document) * * @return DOMDocument */ - public function getDocument() + public function getDocument(): DOMDocument { return $this->document; } diff --git a/src/qtism/runtime/rendering/markup/MarkupPostRenderer.php b/src/qtism/runtime/rendering/markup/MarkupPostRenderer.php index f2bb2172c..6a05d2f96 100644 --- a/src/qtism/runtime/rendering/markup/MarkupPostRenderer.php +++ b/src/qtism/runtime/rendering/markup/MarkupPostRenderer.php @@ -25,7 +25,6 @@ use qtism\runtime\rendering\Renderable; use qtism\runtime\rendering\RenderingException; -use qtism\runtime\rendering\markup\Utils; /** * Class MarkupPostRenderer @@ -87,7 +86,7 @@ public function __construct($formatOutput = false, $cleanUpXmlDeclaration = fals * * @param bool $formatOutput */ - public function formatOutput($formatOutput) + public function formatOutput($formatOutput): void { $this->formatOutput = $formatOutput; } @@ -97,7 +96,7 @@ public function formatOutput($formatOutput) * * @return bool */ - public function mustFormatOutput() + public function mustFormatOutput(): bool { return $this->formatOutput; } @@ -108,7 +107,7 @@ public function mustFormatOutput() * * @param bool $cleanUpXmlDeclaration */ - public function cleanUpXmlDeclaration($cleanUpXmlDeclaration) + public function cleanUpXmlDeclaration($cleanUpXmlDeclaration): void { $this->cleanUpXmlDeclaration = $cleanUpXmlDeclaration; } @@ -118,7 +117,7 @@ public function cleanUpXmlDeclaration($cleanUpXmlDeclaration) * * @return bool */ - public function mustCleanUpXmlDeclaration() + public function mustCleanUpXmlDeclaration(): bool { return $this->cleanUpXmlDeclaration; } @@ -129,7 +128,7 @@ public function mustCleanUpXmlDeclaration() * * @param bool $templateOriented */ - public function templateOriented($templateOriented) + public function templateOriented($templateOriented): void { $this->templateOriented = $templateOriented; } @@ -140,7 +139,7 @@ public function templateOriented($templateOriented) * * @return bool */ - public function isTemplateOriented() + public function isTemplateOriented(): bool { return $this->templateOriented; } @@ -155,7 +154,7 @@ public function isTemplateOriented() * * @return array */ - public function getFragments() + public function getFragments(): array { return $this->fragments; } @@ -165,7 +164,7 @@ public function getFragments() * * @param array $fragments */ - protected function setFragments(array $fragments) + protected function setFragments(array $fragments): void { $this->fragments = $fragments; } @@ -175,7 +174,7 @@ protected function setFragments(array $fragments) * * @param string $fragmentPrefix . */ - public function setFragmentPrefix($fragmentPrefix) + public function setFragmentPrefix($fragmentPrefix): void { $this->fragmentPrefix = $fragmentPrefix; } @@ -193,7 +192,7 @@ protected function getFragmentPrefix() * @return mixed|string|string[]|null * @throws RenderingException */ - public function render($document) + public function render($document): string { if ($document->documentElement === null) { $msg = 'The XML Document to be rendered has no root element (i.e. it is empty).'; diff --git a/src/qtism/runtime/rendering/markup/Utils.php b/src/qtism/runtime/rendering/markup/Utils.php index 8a5c1860d..f9b085bc9 100644 --- a/src/qtism/runtime/rendering/markup/Utils.php +++ b/src/qtism/runtime/rendering/markup/Utils.php @@ -50,7 +50,7 @@ class Utils * @param string $mappingIndicator The mapping indicator to use between field name and field value when displaying record cardinality variables. * @return string The formatted variable or an error message. */ - public static function printVariable(State $context, $identifier, $format = '', $powerForm = false, $base = 10, $index = -1, $delimiter = ';', $field = '', $mappingIndicator = '=') + public static function printVariable(State $context, $identifier, $format = '', $powerForm = false, $base = 10, $index = -1, $delimiter = ';', $field = '', $mappingIndicator = '='): string { try { $printedVariable = new PrintedVariable($identifier); diff --git a/src/qtism/runtime/rendering/markup/xhtml/ARenderer.php b/src/qtism/runtime/rendering/markup/xhtml/ARenderer.php index c3b9614cc..7855dfd3a 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/ARenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/ARenderer.php @@ -36,7 +36,7 @@ class ARenderer extends BodyElementRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $fragment->firstChild->setAttribute('href', $this->transformUri($component->getHref(), $base)); diff --git a/src/qtism/runtime/rendering/markup/xhtml/AbstractXhtmlRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/AbstractXhtmlRenderer.php index 986e14dd2..320b62b65 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/AbstractXhtmlRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/AbstractXhtmlRenderer.php @@ -77,7 +77,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param string $base * @return DOMDocumentFragment A DOMDocumentFragment object containing the rendered $component into another constitution with its children rendering appended. */ - public function render($component, $base = '') + public function render($component, $base = ''): DOMDocumentFragment { $renderingEngine = $this->getRenderingEngine(); $doc = $renderingEngine->getDocument(); @@ -106,7 +106,7 @@ public function render($component, $base = '') * @param QtiComponent $component * @param string $base An optional base path to be used for rendering. */ - protected function renderingImplementation(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function renderingImplementation(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { $this->appendElement($fragment, $component, $base); $this->appendChildren($fragment, $component, $base); @@ -147,7 +147,7 @@ protected function renderingImplementation(DOMDocumentFragment $fragment, QtiCom * @param QtiComponent $component * @param string $base */ - protected function appendElement(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendElement(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { $tagName = ($this->hasReplacementTagName() === true) ? $this->getReplacementTagName() : $component->getQtiClassName(); $fragment->appendChild($this->getRenderingEngine()->getDocument()->createElement($tagName)); @@ -160,7 +160,7 @@ protected function appendElement(DOMDocumentFragment $fragment, QtiComponent $co * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { foreach ($this->getRenderingEngine()->getChildrenRenderings($component) as $childrenRendering) { $fragment->firstChild->appendChild($childrenRendering); @@ -174,7 +174,7 @@ protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $c * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { $this->handleXmlBase($component, $fragment->firstChild); } @@ -184,7 +184,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * * @param string $replacementTagName */ - protected function setReplacementTagName($replacementTagName) + protected function setReplacementTagName($replacementTagName): void { $this->replacementTagName = $replacementTagName; } @@ -194,7 +194,7 @@ protected function setReplacementTagName($replacementTagName) * * @return string */ - protected function getReplacementTagName() + protected function getReplacementTagName(): string { return $this->replacementTagName; } @@ -204,7 +204,7 @@ protected function getReplacementTagName() * * @return bool */ - protected function hasReplacementTagName() + protected function hasReplacementTagName(): bool { return $this->getReplacementTagName() !== ''; } @@ -218,7 +218,7 @@ protected function hasReplacementTagName() * * @param string $tagName A tagname e.g. 'div'. */ - public function transform($tagName) + public function transform($tagName): void { $this->setReplacementTagName($tagName); } @@ -228,7 +228,7 @@ public function transform($tagName) * * @param array $additionalClasses */ - protected function setAdditionalClasses(array $additionalClasses) + protected function setAdditionalClasses(array $additionalClasses): void { $this->additionalClasses = $additionalClasses; } @@ -238,7 +238,7 @@ protected function setAdditionalClasses(array $additionalClasses) * * @return array */ - protected function getAdditionalClasses() + protected function getAdditionalClasses(): array { return $this->additionalClasses; } @@ -248,7 +248,7 @@ protected function getAdditionalClasses() * * @return bool */ - protected function hasAdditionalClasses() + protected function hasAdditionalClasses(): bool { return count($this->getAdditionalClasses()) > 0; } @@ -258,7 +258,7 @@ protected function hasAdditionalClasses() * * @param string $additionalClass A CSS class. */ - public function additionalClass($additionalClass) + public function additionalClass($additionalClass): void { $additionalClasses = $this->getAdditionalClasses(); @@ -275,7 +275,7 @@ public function additionalClass($additionalClass) * * @param array $additionalUserClasses */ - public function setAdditionalUserClasses(array $additionalUserClasses) + public function setAdditionalUserClasses(array $additionalUserClasses): void { $this->additionalUserClasses = $additionalUserClasses; } @@ -285,7 +285,7 @@ public function setAdditionalUserClasses(array $additionalUserClasses) * * @return array */ - public function getAdditionalUserClasses() + public function getAdditionalUserClasses(): array { return $this->additionalUserClasses; } @@ -295,7 +295,7 @@ public function getAdditionalUserClasses() * * @return bool */ - public function hasAdditionalUserClasses() + public function hasAdditionalUserClasses(): bool { return count($this->getAdditionalUserClasses()) > 0; } @@ -305,7 +305,7 @@ public function hasAdditionalUserClasses() * * @param string $additionalUserClass */ - public function additionalUserClass($additionalUserClass) + public function additionalUserClass($additionalUserClass): void { $additionalClasses = $this->getAdditionalUserClasses(); diff --git a/src/qtism/runtime/rendering/markup/xhtml/AssessmentItemRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/AssessmentItemRenderer.php index c355e4e8e..25a94d587 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/AssessmentItemRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/AssessmentItemRenderer.php @@ -59,7 +59,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-assessmentItem'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/AssociableHotspotRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/AssociableHotspotRenderer.php index 2cf599f02..0d1d9a9d1 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/AssociableHotspotRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/AssociableHotspotRenderer.php @@ -67,14 +67,14 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-associableHotspot'); $this->additionalClass('qti-associableChoice'); - $fragment->firstChild->setAttribute('data-match-min', $component->getMatchMin()); - $fragment->firstChild->setAttribute('data-match-max', $component->getMatchMax()); + $fragment->firstChild->setAttribute('data-match-min', (string)$component->getMatchMin()); + $fragment->firstChild->setAttribute('data-match-max', (string)$component->getMatchMax()); if (count($component->getMatchGroup()) > 0) { $fragment->firstChild->setAttribute('data-match-group', implode(' ', $component->getMatchGroup()->getArrayCopy())); diff --git a/src/qtism/runtime/rendering/markup/xhtml/AssociateInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/AssociateInteractionRenderer.php index 6f76be62c..e9d69ab83 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/AssociateInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/AssociateInteractionRenderer.php @@ -57,15 +57,18 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-blockInteraction'); $this->additionalClass('qti-associateInteraction'); - $fragment->firstChild->setAttribute('data-shuffle', ($component->mustShuffle() === true) ? 'true' : 'false'); - $fragment->firstChild->setAttribute('data-max-associations', $component->getMaxAssociations()); - $fragment->firstChild->setAttribute('data-min-associations', $component->getMinAssociations()); + $fragment->firstChild->setAttribute( + 'data-shuffle', + (string)($component->mustShuffle() === true) ? 'true' : 'false' + ); + $fragment->firstChild->setAttribute('data-max-associations', (string)$component->getMaxAssociations()); + $fragment->firstChild->setAttribute('data-min-associations', (string)$component->getMinAssociations()); } /** @@ -73,7 +76,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendChildren($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/BlockquoteRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/BlockquoteRenderer.php index 272dcaf7a..3937dfbc9 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/BlockquoteRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/BlockquoteRenderer.php @@ -36,7 +36,7 @@ class BlockquoteRenderer extends BodyElementRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/BodyElementRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/BodyElementRenderer.php index b3e15a4f1..6e165cf18 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/BodyElementRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/BodyElementRenderer.php @@ -54,7 +54,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-' . $component->getQtiClassName()); diff --git a/src/qtism/runtime/rendering/markup/xhtml/ChoiceInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/ChoiceInteractionRenderer.php index 0f3ea40ba..ab3741352 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/ChoiceInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/ChoiceInteractionRenderer.php @@ -59,7 +59,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-blockInteraction'); @@ -71,8 +71,8 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $this->additionalUserClass("qti-count-${qtiCount}"); $fragment->firstChild->setAttribute('data-shuffle', ($component->mustShuffle() === true) ? 'true' : 'false'); - $fragment->firstChild->setAttribute('data-max-choices', $component->getMaxChoices()); - $fragment->firstChild->setAttribute('data-min-choices', $component->getMinChoices()); + $fragment->firstChild->setAttribute('data-max-choices', (string)$component->getMaxChoices()); + $fragment->firstChild->setAttribute('data-min-choices', (string)$component->getMinChoices()); $fragment->firstChild->setAttribute('data-orientation', ($component->getOrientation() === Orientation::VERTICAL) ? 'vertical' : 'horizontal'); } @@ -81,7 +81,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendChildren($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/ChoiceRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/ChoiceRenderer.php index 5bdb8723b..8f45eb757 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/ChoiceRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/ChoiceRenderer.php @@ -64,7 +64,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-choice'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/ColRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/ColRenderer.php index 12ebd78bd..731759dde 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/ColRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/ColRenderer.php @@ -36,7 +36,7 @@ class ColRenderer extends BodyElementRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/DrawingInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/DrawingInteractionRenderer.php index 9a8d300d5..6dd5915e0 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/DrawingInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/DrawingInteractionRenderer.php @@ -64,7 +64,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-blockInteraction'); @@ -76,7 +76,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendChildren($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/EndAttemptInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/EndAttemptInteractionRenderer.php index 613464357..45abb6d70 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/EndAttemptInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/EndAttemptInteractionRenderer.php @@ -58,7 +58,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-inlineInteraction'); @@ -71,7 +71,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendChildren($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/ExtendedTextInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/ExtendedTextInteractionRenderer.php index de59e33f3..49250b8e6 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/ExtendedTextInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/ExtendedTextInteractionRenderer.php @@ -68,21 +68,24 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-blockInteraction'); $this->additionalClass('qti-extendedTextInteraction'); - $fragment->firstChild->setAttribute('data-min-strings', $component->getMinStrings()); - $fragment->firstChild->setAttribute('data-format', TextFormat::getNameByConstant($component->getFormat())); + $fragment->firstChild->setAttribute('data-min-strings', (string)$component->getMinStrings()); + $fragment->firstChild->setAttribute( + 'data-format', + (string)TextFormat::getNameByConstant($component->getFormat()) + ); if ($component->hasMaxStrings() === true) { - $fragment->firstChild->setAttribute('data-max-strings', $component->getMaxStrings()); + $fragment->firstChild->setAttribute('data-max-strings', (string)$component->getMaxStrings()); } if ($component->hasExpectedLines() === true) { - $fragment->firstChild->setAttribute('data-expected-lines', $component->getExpectedLines()); + $fragment->firstChild->setAttribute('data-expected-lines', (string)$component->getExpectedLines()); } } @@ -91,7 +94,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendChildren($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/ExternalQtiComponentRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/ExternalQtiComponentRenderer.php index a6f93eef9..b869f2bfc 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/ExternalQtiComponentRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/ExternalQtiComponentRenderer.php @@ -38,7 +38,7 @@ class ExternalQtiComponentRenderer extends AbstractXhtmlRenderer * @param QtiComponent $component * @param string $base */ - protected function appendElement(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendElement(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { return; } @@ -49,7 +49,7 @@ protected function appendElement(DOMDocumentFragment $fragment, QtiComponent $co * @param string $base * @throws RenderingException */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { try { $dom = $component->getXml(); diff --git a/src/qtism/runtime/rendering/markup/xhtml/FeedbackBlockRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/FeedbackBlockRenderer.php index ff3677fc4..71157edc6 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/FeedbackBlockRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/FeedbackBlockRenderer.php @@ -56,7 +56,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-feedbackBlock'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/FeedbackElementRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/FeedbackElementRenderer.php index 6cef2fc31..8040bf71d 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/FeedbackElementRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/FeedbackElementRenderer.php @@ -44,7 +44,7 @@ abstract class FeedbackElementRenderer extends BodyElementRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-feedbackElement'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/FeedbackInlineRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/FeedbackInlineRenderer.php index 3cdb55de7..bbde73afa 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/FeedbackInlineRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/FeedbackInlineRenderer.php @@ -56,7 +56,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-feedbackInline'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/FigcaptionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/FigcaptionRenderer.php index ba6c1d67a..8592a9f9c 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/FigcaptionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/FigcaptionRenderer.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\runtime\rendering\markup\xhtml; use qtism\data\content\xhtml\html5\Figcaption; @@ -31,7 +29,7 @@ class FigcaptionRenderer extends Html5ElementRenderer /** * @param QtiComponent&Figcaption $component */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/FigureRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/FigureRenderer.php index 4403f3549..ae45855cb 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/FigureRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/FigureRenderer.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\runtime\rendering\markup\xhtml; use qtism\data\content\xhtml\html5\Figure; @@ -31,7 +29,7 @@ class FigureRenderer extends Html5ElementRenderer /** * @param QtiComponent&Figure $component */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/GapChoiceRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/GapChoiceRenderer.php index 5faa6d8de..416c7b982 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/GapChoiceRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/GapChoiceRenderer.php @@ -54,13 +54,13 @@ abstract class GapChoiceRenderer extends ChoiceRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-gapChoice'); - $fragment->firstChild->setAttribute('data-match-max', $component->getMatchMax()); - $fragment->firstChild->setAttribute('data-match-min', $component->getMatchMin()); + $fragment->firstChild->setAttribute('data-match-max', (string)$component->getMatchMax()); + $fragment->firstChild->setAttribute('data-match-min', (string)$component->getMatchMin()); if (count($component->getMatchGroup()) > 0) { $fragment->firstChild->setAttribute('data-match-group', implode(' ', $component->getMatchGroup()->getArrayCopy())); diff --git a/src/qtism/runtime/rendering/markup/xhtml/GapImgRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/GapImgRenderer.php index 4e42a65f3..e1194a8ef 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/GapImgRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/GapImgRenderer.php @@ -54,7 +54,7 @@ class GapImgRenderer extends GapChoiceRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-gapImg'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/GapMatchInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/GapMatchInteractionRenderer.php index 586e19928..f584b4100 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/GapMatchInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/GapMatchInteractionRenderer.php @@ -55,7 +55,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-blockInteraction'); @@ -69,7 +69,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendChildren($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/GapRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/GapRenderer.php index 5d4a88eac..f737253b2 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/GapRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/GapRenderer.php @@ -63,7 +63,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-gap'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/GapTextRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/GapTextRenderer.php index aadda9f38..c936df176 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/GapTextRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/GapTextRenderer.php @@ -51,7 +51,7 @@ class GapTextRenderer extends GapChoiceRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-gapText'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/GraphicAssociateInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/GraphicAssociateInteractionRenderer.php index 7c499e20d..df4ef5241 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/GraphicAssociateInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/GraphicAssociateInteractionRenderer.php @@ -41,7 +41,7 @@ class GraphicAssociateInteractionRenderer extends GraphicInteractionRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-graphicAssociateInteraction'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/GraphicGapMatchInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/GraphicGapMatchInteractionRenderer.php index 962decca4..e424c4d76 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/GraphicGapMatchInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/GraphicGapMatchInteractionRenderer.php @@ -41,7 +41,7 @@ class GraphicGapMatchInteractionRenderer extends GraphicInteractionRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-graphicGapMatchInteraction'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/GraphicInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/GraphicInteractionRenderer.php index 595b5f87f..fc8aef1c9 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/GraphicInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/GraphicInteractionRenderer.php @@ -50,7 +50,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-graphicInteraction'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/GraphicOrderInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/GraphicOrderInteractionRenderer.php index 4ed8f61e0..f12b13c09 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/GraphicOrderInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/GraphicOrderInteractionRenderer.php @@ -43,7 +43,7 @@ class GraphicOrderInteractionRenderer extends GraphicInteractionRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-graphicOrderInteraction'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/HotspotChoiceRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/HotspotChoiceRenderer.php index 01b835c2e..abc62ab6e 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/HotspotChoiceRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/HotspotChoiceRenderer.php @@ -63,7 +63,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-hotspotChoice'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/HotspotInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/HotspotInteractionRenderer.php index 7c85449c7..2aa15bfc6 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/HotspotInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/HotspotInteractionRenderer.php @@ -43,12 +43,12 @@ class HotspotInteractionRenderer extends GraphicInteractionRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-hotspotInteraction'); - $fragment->firstChild->setAttribute('data-max-choices', $component->getMaxChoices()); - $fragment->firstChild->setAttribute('data-min-choices', $component->getMinChoices()); + $fragment->firstChild->setAttribute('data-max-choices', (string)$component->getMaxChoices()); + $fragment->firstChild->setAttribute('data-min-choices', (string)$component->getMinChoices()); } } diff --git a/src/qtism/runtime/rendering/markup/xhtml/HotspotRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/HotspotRenderer.php index 2d8942e5a..9fdd2000e 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/HotspotRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/HotspotRenderer.php @@ -38,7 +38,7 @@ abstract class HotspotRenderer extends ChoiceRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-hotspot'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/HottextInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/HottextInteractionRenderer.php index 5a3e909cd..024a12739 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/HottextInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/HottextInteractionRenderer.php @@ -44,13 +44,13 @@ class HottextInteractionRenderer extends InteractionRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-blockInteraction'); $this->additionalClass('qti-hottextInteraction'); - $fragment->firstChild->setAttribute('data-max-choices', $component->getMaxChoices()); - $fragment->firstChild->setAttribute('data-min-choices', $component->getMinChoices()); + $fragment->firstChild->setAttribute('data-max-choices', (string)$component->getMaxChoices()); + $fragment->firstChild->setAttribute('data-min-choices', (string)$component->getMinChoices()); } } diff --git a/src/qtism/runtime/rendering/markup/xhtml/HottextRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/HottextRenderer.php index 0b5a935c6..596d0cb46 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/HottextRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/HottextRenderer.php @@ -61,7 +61,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-hottext'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/Html5ElementRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/Html5ElementRenderer.php index e345e0d5f..74c7bcf70 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/Html5ElementRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/Html5ElementRenderer.php @@ -38,7 +38,7 @@ class Html5ElementRenderer extends BodyElementRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/ImgRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/ImgRenderer.php index 23842e49d..a5c667589 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/ImgRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/ImgRenderer.php @@ -36,7 +36,7 @@ class ImgRenderer extends BodyElementRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $fragment->firstChild->setAttribute('src', $this->transformUri($component->getSrc(), $base)); diff --git a/src/qtism/runtime/rendering/markup/xhtml/InlineChoiceInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/InlineChoiceInteractionRenderer.php index 21bb5ef34..ca51ba098 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/InlineChoiceInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/InlineChoiceInteractionRenderer.php @@ -57,7 +57,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-inlineInteraction'); @@ -72,7 +72,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendChildren($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/InlineChoiceRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/InlineChoiceRenderer.php index f766f23d5..6957e4888 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/InlineChoiceRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/InlineChoiceRenderer.php @@ -62,7 +62,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/InteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/InteractionRenderer.php index ae0f8952b..5d0beb3f6 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/InteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/InteractionRenderer.php @@ -55,7 +55,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $fragment->firstChild->setAttribute('data-response-identifier', $component->getResponseIdentifier()); diff --git a/src/qtism/runtime/rendering/markup/xhtml/ItemBodyRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/ItemBodyRenderer.php index 8cca68092..8ae8b323c 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/ItemBodyRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/ItemBodyRenderer.php @@ -50,7 +50,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-itemBody'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/MatchInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/MatchInteractionRenderer.php index be399cd0f..eb3687067 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/MatchInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/MatchInteractionRenderer.php @@ -59,15 +59,15 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-blockInteraction'); $this->additionalClass('qti-matchInteraction'); $fragment->firstChild->setAttribute('data-shuffle', ($component->mustShuffle() === true) ? 'true' : 'false'); - $fragment->firstChild->setAttribute('data-max-associations', $component->getMaxAssociations()); - $fragment->firstChild->setAttribute('data-min-associations', $component->getMinAssociations()); + $fragment->firstChild->setAttribute('data-max-associations', (string)$component->getMaxAssociations()); + $fragment->firstChild->setAttribute('data-min-associations', (string)$component->getMinAssociations()); } /** @@ -75,7 +75,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendChildren($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/MathRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/MathRenderer.php index c350bb229..3afc8ab00 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/MathRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/MathRenderer.php @@ -57,7 +57,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * * @param bool $namespaceOutput */ - public function setNamespaceOutput($namespaceOutput) + public function setNamespaceOutput($namespaceOutput): void { $this->namespaceOutput = $namespaceOutput; } @@ -67,7 +67,7 @@ public function setNamespaceOutput($namespaceOutput) * * @return bool */ - public function mustNamespaceOutput() + public function mustNamespaceOutput(): bool { return $this->namespaceOutput; } @@ -78,7 +78,7 @@ public function mustNamespaceOutput() * @param string $base * @throws RenderingException */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { try { $dom = $component->getXml(); diff --git a/src/qtism/runtime/rendering/markup/xhtml/MediaInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/MediaInteractionRenderer.php index c31d6f5d8..cdff11135 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/MediaInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/MediaInteractionRenderer.php @@ -71,7 +71,7 @@ class MediaInteractionRenderer extends InteractionRenderer * * @param array $audioTypes An array of strings representing mime-types. */ - protected function setAudioTypes(array $audioTypes) + protected function setAudioTypes(array $audioTypes): void { $this->audioTypes = $audioTypes; } @@ -81,7 +81,7 @@ protected function setAudioTypes(array $audioTypes) * * @return array An array of strings representing mime-types. */ - protected function getAudioTypes() + protected function getAudioTypes(): array { return $this->audioTypes; } @@ -91,7 +91,7 @@ protected function getAudioTypes() * * @param array $videoTypes An array of strings representing mime-types. */ - protected function setVideoTypes(array $videoTypes) + protected function setVideoTypes(array $videoTypes): void { $this->videoTypes = $videoTypes; } @@ -101,7 +101,7 @@ protected function setVideoTypes(array $videoTypes) * * @return array An array of strings representing mime-types. */ - protected function getVideoTypes() + protected function getVideoTypes(): array { return $this->videoTypes; } @@ -111,7 +111,7 @@ protected function getVideoTypes() * * @param array $imageTypes An array of strings representing mime-types. */ - protected function setImageTypes(array $imageTypes) + protected function setImageTypes(array $imageTypes): void { $this->imageTypes = $imageTypes; } @@ -121,7 +121,7 @@ protected function setImageTypes(array $imageTypes) * * @return array An array of strings representing mime-types. */ - protected function getImageTypes() + protected function getImageTypes(): array { return $this->imageTypes; } @@ -145,15 +145,18 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-blockInteraction'); $this->additionalClass('qti-mediaInteraction'); - $fragment->firstChild->setAttribute('data-autostart', ($component->mustAutostart() === true) ? 'true' : 'false'); - $fragment->firstChild->setAttribute('data-min-plays', $component->getMinPlays()); - $fragment->firstChild->setAttribute('data-max-plays', $component->getMaxPlays()); + $fragment->firstChild->setAttribute( + 'data-autostart', + ($component->mustAutostart() === true) ? 'true' : 'false' + ); + $fragment->firstChild->setAttribute('data-min-plays', (string)$component->getMinPlays()); + $fragment->firstChild->setAttribute('data-max-plays', (string)$component->getMaxPlays()); $fragment->firstChild->setAttribute('data-loop', ($component->mustLoop() === true) ? 'true' : 'false'); } @@ -162,7 +165,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendChildren($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/ModalFeedbackRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/ModalFeedbackRenderer.php index d5e1bb8fd..824bcdc11 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/ModalFeedbackRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/ModalFeedbackRenderer.php @@ -57,7 +57,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-modalFeedback'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/ObjectRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/ObjectRenderer.php index ff9979187..0be5a795b 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/ObjectRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/ObjectRenderer.php @@ -36,7 +36,7 @@ class ObjectRenderer extends BodyElementRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $fragment->firstChild->setAttribute('data', $this->transformUri($component->getData(), $base)); @@ -56,7 +56,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendChildren($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/OrderInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/OrderInteractionRenderer.php index 8ced68ce3..7d8479520 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/OrderInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/OrderInteractionRenderer.php @@ -58,7 +58,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-orderInteraction'); @@ -82,7 +82,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendChildren($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/ParamRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/ParamRenderer.php index 284be1022..e157c6630 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/ParamRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/ParamRenderer.php @@ -37,7 +37,7 @@ class ParamRenderer extends AbstractXhtmlRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $fragment->firstChild->setAttribute('name', $component->getName()); diff --git a/src/qtism/runtime/rendering/markup/xhtml/PositionObjectInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/PositionObjectInteractionRenderer.php index 2ada9e290..0f0de3c30 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/PositionObjectInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/PositionObjectInteractionRenderer.php @@ -56,15 +56,15 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-positionObjectInteraction'); - $fragment->firstChild->setAttribute('data-max-choices', $component->getMaxChoices()); + $fragment->firstChild->setAttribute('data-max-choices', (string)$component->getMaxChoices()); if ($component->hasMinChoices() === true) { - $fragment->firstChild->setAttribute('data-min-choices', $component->getMinChoices()); + $fragment->firstChild->setAttribute('data-min-choices', (string)$component->getMinChoices()); } if ($component->hasCenterPoint() === true) { diff --git a/src/qtism/runtime/rendering/markup/xhtml/PositionObjectStageRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/PositionObjectStageRenderer.php index f1f026111..7d71cd51d 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/PositionObjectStageRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/PositionObjectStageRenderer.php @@ -49,7 +49,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-positionObjectStage'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/PrintedVariableRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/PrintedVariableRenderer.php index dd6629c41..2d0867d6e 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/PrintedVariableRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/PrintedVariableRenderer.php @@ -61,7 +61,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-printedVariable'); @@ -72,20 +72,23 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $fragment->firstChild->setAttribute('data-format', $component->getFormat()); } - $fragment->firstChild->setAttribute('data-power-form', ($component->mustPowerForm() === true) ? 'true' : 'false'); - $fragment->firstChild->setAttribute('data-base', $component->getBase()); + $fragment->firstChild->setAttribute( + 'data-power-form', + (string)($component->mustPowerForm() === true) ? 'true' : 'false' + ); + $fragment->firstChild->setAttribute('data-base', (string)$component->getBase()); if ($component->hasIndex() === true) { - $fragment->firstChild->setAttribute('data-index', $component->getIndex()); + $fragment->firstChild->setAttribute('data-index', (string)$component->getIndex()); } - $fragment->firstChild->setAttribute('data-delimiter', $component->getDelimiter()); + $fragment->firstChild->setAttribute('data-delimiter', (string)$component->getDelimiter()); if ($component->hasField() === true) { - $fragment->firstChild->setAttribute('data-field', $component->getField()); + $fragment->firstChild->setAttribute('data-field', (string)$component->getField()); } - $fragment->firstChild->setAttribute('data-mapping-indicator', $component->getMappingIndicator()); + $fragment->firstChild->setAttribute('data-mapping-indicator', (string)$component->getMappingIndicator()); } /** @@ -93,7 +96,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { $renderingEngine = $this->getRenderingEngine(); diff --git a/src/qtism/runtime/rendering/markup/xhtml/PromptRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/PromptRenderer.php index 8a59707df..86c617646 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/PromptRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/PromptRenderer.php @@ -50,7 +50,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-prompt'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/QRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/QRenderer.php index 4b62a6ab1..89743649c 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/QRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/QRenderer.php @@ -36,7 +36,7 @@ class QRenderer extends BodyElementRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/RbRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/RbRenderer.php index ed7bf2d0f..48ccc78ef 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/RbRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/RbRenderer.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\runtime\rendering\markup\xhtml; use qtism\data\content\xhtml\html5\Rb; @@ -31,7 +29,7 @@ class RbRenderer extends Html5ElementRenderer /** * @param QtiComponent&Rb $component */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/RpRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/RpRenderer.php index e32105115..36537efed 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/RpRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/RpRenderer.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\runtime\rendering\markup\xhtml; use qtism\data\content\xhtml\html5\Rp; @@ -31,7 +29,7 @@ class RpRenderer extends Html5ElementRenderer /** * @param QtiComponent&Rp $component */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/RtRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/RtRenderer.php index 9ceaa1156..04c7e11ac 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/RtRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/RtRenderer.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\runtime\rendering\markup\xhtml; use qtism\data\content\xhtml\html5\Rt; @@ -31,7 +29,7 @@ class RtRenderer extends Html5ElementRenderer /** * @param QtiComponent&Rt $component */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/RubricBlockRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/RubricBlockRenderer.php index ca7e26d7e..b97f3e9f5 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/RubricBlockRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/RubricBlockRenderer.php @@ -58,7 +58,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-rubricBlock'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/RubyRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/RubyRenderer.php index f480855c3..bebe6b4dc 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/RubyRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/RubyRenderer.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtism\runtime\rendering\markup\xhtml; use qtism\data\content\xhtml\html5\Ruby; @@ -31,7 +29,7 @@ class RubyRenderer extends Html5ElementRenderer /** * @param QtiComponent&Ruby $component */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/SelectPointInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/SelectPointInteractionRenderer.php index 9024691ce..86d1902af 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/SelectPointInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/SelectPointInteractionRenderer.php @@ -43,12 +43,12 @@ class SelectPointInteractionRenderer extends GraphicInteractionRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-selectPointInteraction'); - $fragment->firstChild->setAttribute('data-max-choices', $component->getMaxChoices()); - $fragment->firstChild->setAttribute('data-min-choices', $component->getMinChoices()); + $fragment->firstChild->setAttribute('data-max-choices', (string)$component->getMaxChoices()); + $fragment->firstChild->setAttribute('data-min-choices', (string)$component->getMinChoices()); } } diff --git a/src/qtism/runtime/rendering/markup/xhtml/SimpleAssociableChoiceRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/SimpleAssociableChoiceRenderer.php index 274e5ff98..76e035948 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/SimpleAssociableChoiceRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/SimpleAssociableChoiceRenderer.php @@ -64,13 +64,13 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-simpleAssociableChoice'); - $fragment->firstChild->setAttribute('data-match-max', $component->getMatchMax()); - $fragment->firstChild->setAttribute('data-match-min', $component->getMatchMin()); + $fragment->firstChild->setAttribute('data-match-max', (string)$component->getMatchMax()); + $fragment->firstChild->setAttribute('data-match-min', (string)$component->getMatchMin()); if (count($component->getMatchGroup()) > 0) { $fragment->firstChild->setAttribute('data-match-group', implode(' ', $component->getMatchGroup()->getArrayCopy())); diff --git a/src/qtism/runtime/rendering/markup/xhtml/SimpleChoiceRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/SimpleChoiceRenderer.php index cf8bad680..c4f4a09d7 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/SimpleChoiceRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/SimpleChoiceRenderer.php @@ -61,7 +61,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-simpleChoice'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/SimpleMatchSetRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/SimpleMatchSetRenderer.php index e20fc9799..31f24a524 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/SimpleMatchSetRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/SimpleMatchSetRenderer.php @@ -49,7 +49,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-simpleMatchSet'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/SliderInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/SliderInteractionRenderer.php index dd7db6604..ddf46a09b 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/SliderInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/SliderInteractionRenderer.php @@ -67,21 +67,27 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-blockInteraction'); $this->additionalClass('qti-sliderInteraction'); $this->additionalUserClass(($component->getOrientation() === Orientation::HORIZONTAL) ? 'qti-horizontal' : 'qti-vertical'); - $fragment->firstChild->setAttribute('data-lower-bound', $component->getLowerBound()); - $fragment->firstChild->setAttribute('data-upper-bound', $component->getUpperBound()); - $fragment->firstChild->setAttribute('data-step-label', ($component->mustStepLabel() === true) ? 'true' : 'false'); - $fragment->firstChild->setAttribute('data-orientation', ($component->getOrientation() === Orientation::VERTICAL) ? 'vertical' : 'horizontal'); + $fragment->firstChild->setAttribute('data-lower-bound', (string)$component->getLowerBound()); + $fragment->firstChild->setAttribute('data-upper-bound', (string)$component->getUpperBound()); + $fragment->firstChild->setAttribute( + 'data-step-label', + ($component->mustStepLabel() === true) ? 'true' : 'false' + ); + $fragment->firstChild->setAttribute( + 'data-orientation', + ($component->getOrientation() === Orientation::VERTICAL) ? 'vertical' : 'horizontal' + ); $fragment->firstChild->setAttribute('data-reverse', ($component->mustReverse() === true) ? 'true' : 'false'); if ($component->hasStep() === true) { - $fragment->firstChild->setAttribute('data-step', $component->getStep()); + $fragment->firstChild->setAttribute('data-step', (string)$component->getStep()); } } @@ -90,7 +96,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendChildren($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/SsmlSubRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/SsmlSubRenderer.php index 78945f618..2b3ad9d7c 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/SsmlSubRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/SsmlSubRenderer.php @@ -51,7 +51,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param string $base * @throws RenderingException */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { try { $dom = $component->getXml(); diff --git a/src/qtism/runtime/rendering/markup/xhtml/StringInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/StringInteractionRenderer.php index 5055db307..4cbcec81b 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/StringInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/StringInteractionRenderer.php @@ -46,27 +46,27 @@ abstract class StringInteractionRenderer extends InteractionRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-stringInteraction'); - $fragment->firstChild->setAttribute('data-base', $component->getBase()); + $fragment->firstChild->setAttribute('data-base', (string)$component->getBase()); if ($component->hasStringIdentifier() === true) { - $fragment->firstChild->setAttribute('data-string-identifier', $component->getStringIdentifier()); + $fragment->firstChild->setAttribute('data-string-identifier', (string)$component->getStringIdentifier()); } if ($component->hasExpectedLength() === true) { - $fragment->firstChild->setAttribute('data-expected-length', $component->getExpectedLength()); + $fragment->firstChild->setAttribute('data-expected-length', (string)$component->getExpectedLength()); } if ($component->hasPatternMask() === true) { - $fragment->firstChild->setAttribute('data-pattern-mask', $component->getPatternMask()); + $fragment->firstChild->setAttribute('data-pattern-mask', (string)$component->getPatternMask()); } if ($component->hasPlaceholderText() === true) { - $fragment->firstChild->setAttribute('data-placeholder-text', $component->getPlaceholderText()); + $fragment->firstChild->setAttribute('data-placeholder-text', (string)$component->getPlaceholderText()); } } } diff --git a/src/qtism/runtime/rendering/markup/xhtml/StylesheetRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/StylesheetRenderer.php index 88382951e..6c25029dc 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/StylesheetRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/StylesheetRenderer.php @@ -48,7 +48,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $fragment->firstChild->setAttribute('rel', 'stylesheet'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/TableCellRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/TableCellRenderer.php index 2920f7ac7..0c045234a 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/TableCellRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/TableCellRenderer.php @@ -37,7 +37,7 @@ class TableCellRenderer extends BodyElementRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); @@ -46,23 +46,26 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent } if ($component->hasScope() === true) { - $fragment->firstChild->setAttribute('scope', TableCellScope::getNameByConstant($component->getScope())); + $fragment->firstChild->setAttribute( + 'scope', + (string)TableCellScope::getNameByConstant($component->getScope()) + ); } if ($component->hasAbbr() === true) { - $fragment->firstChild->setAttribute('abbr', $component->getAbbr()); + $fragment->firstChild->setAttribute('abbr', (string)$component->getAbbr()); } if ($component->hasAxis() === true) { - $fragment->firstChild->setAttribute('axis', $component->getAxis()); + $fragment->firstChild->setAttribute('axis', (string)$component->getAxis()); } if ($component->hasRowspan() === true) { - $fragment->firstChild->setAttribute('rowspan', $component->getRowspan()); + $fragment->firstChild->setAttribute('rowspan', (string)$component->getRowspan()); } if ($component->hasColspan() === true) { - $fragment->firstChild->setAttribute('colspan', $component->getColspan()); + $fragment->firstChild->setAttribute('colspan', (string)$component->getColspan()); } } } diff --git a/src/qtism/runtime/rendering/markup/xhtml/TableRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/TableRenderer.php index 3569beca5..98bb3a01d 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/TableRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/TableRenderer.php @@ -36,7 +36,7 @@ class TableRenderer extends BodyElementRenderer * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); diff --git a/src/qtism/runtime/rendering/markup/xhtml/TextEntryInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/TextEntryInteractionRenderer.php index 41ac2e1e2..40e3f1f03 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/TextEntryInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/TextEntryInteractionRenderer.php @@ -59,7 +59,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-inlineInteraction'); diff --git a/src/qtism/runtime/rendering/markup/xhtml/TextRunRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/TextRunRenderer.php index 801c99cef..2e5813476 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/TextRunRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/TextRunRenderer.php @@ -47,7 +47,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendElement(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendElement(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { $fragment->appendChild($this->getRenderingEngine()->getDocument()->createTextNode($component->getContent())); } @@ -57,7 +57,7 @@ protected function appendElement(DOMDocumentFragment $fragment, QtiComponent $co * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { return; } diff --git a/src/qtism/runtime/rendering/markup/xhtml/UploadInteractionRenderer.php b/src/qtism/runtime/rendering/markup/xhtml/UploadInteractionRenderer.php index a3c157870..5b5b3e6ce 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/UploadInteractionRenderer.php +++ b/src/qtism/runtime/rendering/markup/xhtml/UploadInteractionRenderer.php @@ -57,7 +57,7 @@ public function __construct(AbstractMarkupRenderingEngine $renderingEngine = nul * @param QtiComponent $component * @param string $base */ - protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendAttributes($fragment, $component); $this->additionalClass('qti-blockInteraction'); @@ -73,7 +73,7 @@ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent * @param QtiComponent $component * @param string $base */ - protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') + protected function appendChildren(DOMDocumentFragment $fragment, QtiComponent $component, $base = ''): void { parent::appendChildren($fragment, $component); diff --git a/src/qtism/runtime/rendering/markup/xhtml/Utils.php b/src/qtism/runtime/rendering/markup/xhtml/Utils.php index 0be3d4ff6..f35d38ad1 100644 --- a/src/qtism/runtime/rendering/markup/xhtml/Utils.php +++ b/src/qtism/runtime/rendering/markup/xhtml/Utils.php @@ -32,9 +32,9 @@ */ class Utils { - const EXTRACT_IF = 0; + public const EXTRACT_IF = 0; - const EXTRACT_INCLUDE = 1; + public const EXTRACT_INCLUDE = 1; /** * Shuffle the elements related to $shufflables components within a given $node. @@ -42,7 +42,7 @@ class Utils * @param DOMNode $node The DOM Node where corresponding $shufflables must be shuffled. * @param ShufflableCollection $shufflables A collection of Shufflable objects. */ - public static function shuffle(DOMNode $node, ShufflableCollection $shufflables) + public static function shuffle(DOMNode $node, ShufflableCollection $shufflables): void { $shufflableIndexes = []; $elements = []; @@ -127,7 +127,7 @@ public static function shuffle(DOMNode $node, ShufflableCollection $shufflables) * @param string|array $class A class or an array of CSS classes. * @return bool */ - public static function hasClass(DOMElement $node, $class) + public static function hasClass(DOMElement $node, $class): bool { if (is_array($class) === false) { $class = [$class]; @@ -151,7 +151,7 @@ public static function hasClass(DOMElement $node, $class) * @param int $type * @return array An array of DOMComment objects. */ - public static function extractStatements(DOMElement $node, $type = self::EXTRACT_IF) + public static function extractStatements(DOMElement $node, $type = self::EXTRACT_IF): array { $statements = []; $extract = [ diff --git a/src/qtism/runtime/rendering/qtipl/AbstractQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/AbstractQtiPLRenderer.php index 8bd8e5a0f..e1a225027 100644 --- a/src/qtism/runtime/rendering/qtipl/AbstractQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/AbstractQtiPLRenderer.php @@ -41,7 +41,7 @@ abstract class AbstractQtiPLRenderer implements Renderable * * @return ConditionRenderingOptions */ - public function getCRO() + public function getCRO(): ConditionRenderingOptions { return $this->cro; } @@ -51,7 +51,7 @@ public function getCRO() * * @param ConditionRenderingOptions $cro */ - public function setCRO($cro) + public function setCRO($cro): void { $this->cro = $cro; } diff --git a/src/qtism/runtime/rendering/qtipl/ConditionRenderingOptions.php b/src/qtism/runtime/rendering/qtipl/ConditionRenderingOptions.php index 8030e1f8c..f8299518b 100644 --- a/src/qtism/runtime/rendering/qtipl/ConditionRenderingOptions.php +++ b/src/qtism/runtime/rendering/qtipl/ConditionRenderingOptions.php @@ -44,7 +44,7 @@ class ConditionRenderingOptions * @return ConditionRenderingOptions The format by default for the * ConditionRenderingOptions. */ - public static function getDefault() + public static function getDefault(): ConditionRenderingOptions { return new ConditionRenderingOptions(self::$defaultIdentation); } @@ -70,7 +70,7 @@ public function __construct($indentation) * @return int */ - public function getIndentation() + public function getIndentation(): int { return $this->indentation; } diff --git a/src/qtism/runtime/rendering/qtipl/QtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/QtiPLRenderer.php index 5515945f1..0a5389b99 100644 --- a/src/qtism/runtime/rendering/qtipl/QtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/QtiPLRenderer.php @@ -136,6 +136,7 @@ public function __construct(ConditionRenderingOptions $cro) * @return mixed The rendered component into another constitution. * @throws RenderingException */ + #[\ReturnTypeWillChange] public function render($something) { if (array_key_exists($something->getQtiClassName(), $this->registry)) { @@ -154,7 +155,7 @@ public function render($something) * @return string The default QtiPL rendering for an Operator * @throws RenderingException */ - public function getDefaultRendering($something) + public function getDefaultRendering($something): string { return $something->getQtiClassName() . $this->writeChildElements(); } @@ -162,7 +163,7 @@ public function getDefaultRendering($something) /** * @return string The element opening to where the child elements are written. */ - public function getOpenChildElement() + public function getOpenChildElement(): string { return $this->openChildElement; } @@ -170,7 +171,7 @@ public function getOpenChildElement() /** * @return string The element closing to where the child elements are written. */ - public function getCloseChildElement() + public function getCloseChildElement(): string { return $this->closeChildElement; } @@ -178,7 +179,7 @@ public function getCloseChildElement() /** * @return string The element opening to where the attributes are written. */ - public function getOpenAttributes() + public function getOpenAttributes(): string { return $this->openAttribute; } @@ -186,7 +187,7 @@ public function getOpenAttributes() /** * @return string The element closing to where the attributes are written. */ - public function getCloseAttributes() + public function getCloseAttributes(): string { return $this->closeAttribute; } @@ -196,7 +197,7 @@ public function getCloseAttributes() * @return string The child Element in the open and close child elements * @throws RenderingException */ - public function writeChildElement($childElement) + public function writeChildElement($childElement): string { return $this->getOpenChildElement() . $this->render($childElement) . $this->getCloseChildElement(); } @@ -206,7 +207,7 @@ public function writeChildElement($childElement) * @return string The child Elements in the open and close child elements * @throws RenderingException */ - public function writeChildElements($childElements = []) + public function writeChildElements($childElements = []): string { $childPL = []; @@ -221,7 +222,7 @@ public function writeChildElements($childElements = []) * @param array of string $childElements The child elements of the element to render. * @return string The child Elements in the open and close child elements */ - public function writeAttributes($attributes = []) + public function writeAttributes($attributes = []): string { if (count($attributes) > 0) { $attribPL = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/BaseValueQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/BaseValueQtiPLRenderer.php index 83d6f61aa..6af7ebd28 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/BaseValueQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/BaseValueQtiPLRenderer.php @@ -39,6 +39,7 @@ class BaseValueQtiPLRenderer extends AbstractQtiPLRenderer * @param mixed $something Something to render into another consitution. * @return mixed The rendered component into another constitution. */ + #[\ReturnTypeWillChange] public function render($something) { switch ($something->getBaseType()) { diff --git a/src/qtism/runtime/rendering/qtipl/expressions/CorrectQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/CorrectQtiPLRenderer.php index e8f91ca1a..3769f3a32 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/CorrectQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/CorrectQtiPLRenderer.php @@ -40,7 +40,7 @@ class CorrectQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/DefaultValQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/DefaultValQtiPLRenderer.php index 557ec0dc6..e45990886 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/DefaultValQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/DefaultValQtiPLRenderer.php @@ -40,7 +40,7 @@ class DefaultValQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/ItemSubsetQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/ItemSubsetQtiPLRenderer.php index 1b5bdcba1..f261eadbc 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/ItemSubsetQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/ItemSubsetQtiPLRenderer.php @@ -40,7 +40,7 @@ class ItemSubsetQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/MapResponsePointQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/MapResponsePointQtiPLRenderer.php index 0e9f21dda..212c5bf96 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/MapResponsePointQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/MapResponsePointQtiPLRenderer.php @@ -40,7 +40,7 @@ class MapResponsePointQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/MapResponseQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/MapResponseQtiPLRenderer.php index 30272c1a3..2829d221f 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/MapResponseQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/MapResponseQtiPLRenderer.php @@ -40,7 +40,7 @@ class MapResponseQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/MathConstantQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/MathConstantQtiPLRenderer.php index d2d704816..76ee027dc 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/MathConstantQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/MathConstantQtiPLRenderer.php @@ -41,7 +41,7 @@ class MathConstantQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/OutcomeMaximumQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/OutcomeMaximumQtiPLRenderer.php index e5ddf0b54..736ba0af5 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/OutcomeMaximumQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/OutcomeMaximumQtiPLRenderer.php @@ -40,7 +40,7 @@ class OutcomeMaximumQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/OutcomeMinimumQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/OutcomeMinimumQtiPLRenderer.php index 8af93f5ee..9591f870c 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/OutcomeMinimumQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/OutcomeMinimumQtiPLRenderer.php @@ -40,7 +40,7 @@ class OutcomeMinimumQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/RandomFloatQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/RandomFloatQtiPLRenderer.php index 5db53930c..636b2e5f5 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/RandomFloatQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/RandomFloatQtiPLRenderer.php @@ -40,7 +40,7 @@ class RandomFloatQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/RandomIntegerQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/RandomIntegerQtiPLRenderer.php index 5b2aab1d4..f56cf2929 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/RandomIntegerQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/RandomIntegerQtiPLRenderer.php @@ -40,7 +40,7 @@ class RandomIntegerQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/TestVariablesQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/TestVariablesQtiPLRenderer.php index 40b70ce53..ee956a6e1 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/TestVariablesQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/TestVariablesQtiPLRenderer.php @@ -41,7 +41,7 @@ class TestVariablesQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/VariableQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/VariableQtiPLRenderer.php index dd8418f18..ffc0fd0bf 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/VariableQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/VariableQtiPLRenderer.php @@ -40,7 +40,7 @@ class VariableQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/AnyNQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/AnyNQtiPLRenderer.php index 149a25cf3..d02a1db2a 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/AnyNQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/AnyNQtiPLRenderer.php @@ -40,7 +40,7 @@ class AnyNQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/CustomOperatorQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/CustomOperatorQtiPLRenderer.php index 9d73f87d1..ad1b5e13c 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/CustomOperatorQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/CustomOperatorQtiPLRenderer.php @@ -40,7 +40,7 @@ class CustomOperatorQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/EqualQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/EqualQtiPLRenderer.php index 9cd9040da..0282aa354 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/EqualQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/EqualQtiPLRenderer.php @@ -41,7 +41,7 @@ class EqualQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/EqualRoundedQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/EqualRoundedQtiPLRenderer.php index 15d7dc1e3..58f48f30d 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/EqualRoundedQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/EqualRoundedQtiPLRenderer.php @@ -41,7 +41,7 @@ class EqualRoundedQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/FieldValueQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/FieldValueQtiPLRenderer.php index b52e8af47..300c83fd8 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/FieldValueQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/FieldValueQtiPLRenderer.php @@ -40,7 +40,7 @@ class FieldValueQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/IndexQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/IndexQtiPLRenderer.php index cf6145810..55f5e6e57 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/IndexQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/IndexQtiPLRenderer.php @@ -40,7 +40,7 @@ class IndexQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/InsideQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/InsideQtiPLRenderer.php index 64bf3f557..c6557cd4d 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/InsideQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/InsideQtiPLRenderer.php @@ -41,7 +41,7 @@ class InsideQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/MathOperatorQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/MathOperatorQtiPLRenderer.php index 0242b9e27..a5922b6d2 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/MathOperatorQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/MathOperatorQtiPLRenderer.php @@ -41,7 +41,7 @@ class MathOperatorQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/NotQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/NotQtiPLRenderer.php index 606ea3bfa..dab400937 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/NotQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/NotQtiPLRenderer.php @@ -42,7 +42,7 @@ class NotQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $orenderer = new OperatorQtiPLRenderer($this->getCRO()); diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/OperatorQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/OperatorQtiPLRenderer.php index f4a836e77..26687163a 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/OperatorQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/OperatorQtiPLRenderer.php @@ -90,7 +90,7 @@ class OperatorQtiPLRenderer extends AbstractQtiPLRenderer * who can use their sign as an operator in QtiPL, and as value, the * string representation of the sign used as operator. */ - public function getSignAsOperatorMap() + public function getSignAsOperatorMap(): array { $map = []; $map['and'] = '&&'; @@ -118,7 +118,7 @@ public function getSignAsOperatorMap() * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { if ( !array_key_exists($something->getQtiClassName(), $this->getSignAsOperatorMap()) || @@ -137,7 +137,7 @@ public function render($something) * @return string The default QtiPL rendering for an Operator * @throws RenderingException */ - public function getDefaultRendering($something) + public function getDefaultRendering($something): string { $renderer = new QtiPLRenderer($this->getCRO()); return $something->getQtiClassName() . $renderer->writeChildElements($something->getExpressions()); @@ -152,7 +152,7 @@ public function getDefaultRendering($something) * 2 sub-expressions * @throws RenderingException */ - private function renderWithSignAsOperator($something) + private function renderWithSignAsOperator($something): string { $qtipl = ''; $renderer = new QtiPLRenderer($this->getCRO()); @@ -178,7 +178,7 @@ private function renderWithSignAsOperator($something) * * @return array An array of string values. */ - public static function getOperatorClassNames() + public static function getOperatorClassNames(): array { return self::$operatorClassNames; } diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/PatternMatchQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/PatternMatchQtiPLRenderer.php index 03bb948c0..d6b0f3423 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/PatternMatchQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/PatternMatchQtiPLRenderer.php @@ -40,7 +40,7 @@ class PatternMatchQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/RepeatQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/RepeatQtiPLRenderer.php index 6d06df095..f7667c6bb 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/RepeatQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/RepeatQtiPLRenderer.php @@ -40,7 +40,7 @@ class RepeatQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/RoundToQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/RoundToQtiPLRenderer.php index 612853370..2901a8155 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/RoundToQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/RoundToQtiPLRenderer.php @@ -41,7 +41,7 @@ class RoundToQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/StatsOperatorQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/StatsOperatorQtiPLRenderer.php index 7133cb784..ffdd4f5ab 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/StatsOperatorQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/StatsOperatorQtiPLRenderer.php @@ -41,7 +41,7 @@ class StatsOperatorQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/StringMatchQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/StringMatchQtiPLRenderer.php index 20dc7885f..2d63db0c4 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/StringMatchQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/StringMatchQtiPLRenderer.php @@ -40,7 +40,7 @@ class StringMatchQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/expressions/operators/SubstringQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/expressions/operators/SubstringQtiPLRenderer.php index 6416f25a4..77063f43e 100644 --- a/src/qtism/runtime/rendering/qtipl/expressions/operators/SubstringQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/expressions/operators/SubstringQtiPLRenderer.php @@ -40,7 +40,7 @@ class SubstringQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/rules/BranchRuleQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/BranchRuleQtiPLRenderer.php index 973012638..705f7f02a 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/BranchRuleQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/BranchRuleQtiPLRenderer.php @@ -40,7 +40,7 @@ class BranchRuleQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/rules/LookupOutcomeValueQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/LookupOutcomeValueQtiPLRenderer.php index 16f959591..0fcb0ad35 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/LookupOutcomeValueQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/LookupOutcomeValueQtiPLRenderer.php @@ -40,7 +40,7 @@ class LookupOutcomeValueQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/rules/OutcomeConditionQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/OutcomeConditionQtiPLRenderer.php index 2121c6545..6bbc304b3 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/OutcomeConditionQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/OutcomeConditionQtiPLRenderer.php @@ -40,7 +40,7 @@ class OutcomeConditionQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $qtipl = $renderer->render($something->getOutcomeIf()); diff --git a/src/qtism/runtime/rendering/qtipl/rules/OutcomeElseIfQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/OutcomeElseIfQtiPLRenderer.php index bf075ce54..21599ec33 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/OutcomeElseIfQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/OutcomeElseIfQtiPLRenderer.php @@ -40,7 +40,7 @@ class OutcomeElseIfQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $qtipl = 'elseif (' . $renderer->render($something->getExpression()) . ") {\n"; diff --git a/src/qtism/runtime/rendering/qtipl/rules/OutcomeElseQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/OutcomeElseQtiPLRenderer.php index 4c2e25ca8..cf6a41656 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/OutcomeElseQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/OutcomeElseQtiPLRenderer.php @@ -40,7 +40,7 @@ class OutcomeElseQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $qtipl = " else {\n"; diff --git a/src/qtism/runtime/rendering/qtipl/rules/OutcomeIfQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/OutcomeIfQtiPLRenderer.php index d5d5f41aa..35dd19324 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/OutcomeIfQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/OutcomeIfQtiPLRenderer.php @@ -40,7 +40,7 @@ class OutcomeIfQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $qtipl = 'if ' . $renderer->writeChildElement($something->getExpression()) . " {\n"; diff --git a/src/qtism/runtime/rendering/qtipl/rules/ResponseConditionQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/ResponseConditionQtiPLRenderer.php index e9b130404..8472dbdf3 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/ResponseConditionQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/ResponseConditionQtiPLRenderer.php @@ -40,7 +40,7 @@ class ResponseConditionQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $qtipl = $renderer->render($something->getResponseIf()); diff --git a/src/qtism/runtime/rendering/qtipl/rules/ResponseElseIfQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/ResponseElseIfQtiPLRenderer.php index 84355b5a9..2a746314d 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/ResponseElseIfQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/ResponseElseIfQtiPLRenderer.php @@ -40,7 +40,7 @@ class ResponseElseIfQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $qtipl = 'elseif (' . $renderer->render($something->getExpression()) . ") {\n"; diff --git a/src/qtism/runtime/rendering/qtipl/rules/ResponseElseQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/ResponseElseQtiPLRenderer.php index 2f98f9279..d938ff5ee 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/ResponseElseQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/ResponseElseQtiPLRenderer.php @@ -40,7 +40,7 @@ class ResponseElseQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $qtipl = " else {\n"; diff --git a/src/qtism/runtime/rendering/qtipl/rules/ResponseIfQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/ResponseIfQtiPLRenderer.php index 21f75c00f..dc2ffbb1b 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/ResponseIfQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/ResponseIfQtiPLRenderer.php @@ -40,7 +40,7 @@ class ResponseIfQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $qtipl = 'if ' . $renderer->writeChildElement($something->getExpression()) . " {\n"; diff --git a/src/qtism/runtime/rendering/qtipl/rules/RuleQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/RuleQtiPLRenderer.php index 23f4cc639..3101ccee6 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/RuleQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/RuleQtiPLRenderer.php @@ -40,7 +40,7 @@ class RuleQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); return $something->getQtiClassName() . $renderer->writeChildElement($something->getExpression()); diff --git a/src/qtism/runtime/rendering/qtipl/rules/SetCorrectResponseQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/SetCorrectResponseQtiPLRenderer.php index 1d2b8f6d2..c9b1a81c7 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/SetCorrectResponseQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/SetCorrectResponseQtiPLRenderer.php @@ -40,7 +40,7 @@ class SetCorrectResponseQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/rules/SetDefaultValueQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/SetDefaultValueQtiPLRenderer.php index d73f01fc0..71a727518 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/SetDefaultValueQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/SetDefaultValueQtiPLRenderer.php @@ -40,7 +40,7 @@ class SetDefaultValueQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/rules/SetOutcomeValueQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/SetOutcomeValueQtiPLRenderer.php index 0296c18cc..43c6b44dc 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/SetOutcomeValueQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/SetOutcomeValueQtiPLRenderer.php @@ -40,7 +40,7 @@ class SetOutcomeValueQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/rules/SetTemplateValueQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/SetTemplateValueQtiPLRenderer.php index 4c03b3f33..d93d8ef04 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/SetTemplateValueQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/SetTemplateValueQtiPLRenderer.php @@ -40,7 +40,7 @@ class SetTemplateValueQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $attributes = []; diff --git a/src/qtism/runtime/rendering/qtipl/rules/TemplateConditionQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/TemplateConditionQtiPLRenderer.php index 7869c81fa..f972bea83 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/TemplateConditionQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/TemplateConditionQtiPLRenderer.php @@ -40,7 +40,7 @@ class TemplateConditionQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $qtipl = $renderer->render($something->getTemplateIf()); diff --git a/src/qtism/runtime/rendering/qtipl/rules/TemplateElseIfQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/TemplateElseIfQtiPLRenderer.php index 614d4207f..382b0b657 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/TemplateElseIfQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/TemplateElseIfQtiPLRenderer.php @@ -40,7 +40,7 @@ class TemplateElseIfQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $qtipl = 'elseif (' . $renderer->render($something->getExpression()) . ") {\n"; diff --git a/src/qtism/runtime/rendering/qtipl/rules/TemplateElseQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/TemplateElseQtiPLRenderer.php index d961ffefb..2695259af 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/TemplateElseQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/TemplateElseQtiPLRenderer.php @@ -40,7 +40,7 @@ class TemplateElseQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $qtipl = " else {\n"; diff --git a/src/qtism/runtime/rendering/qtipl/rules/TemplateIfQtiPLRenderer.php b/src/qtism/runtime/rendering/qtipl/rules/TemplateIfQtiPLRenderer.php index 4dde7d4d1..eaa028933 100644 --- a/src/qtism/runtime/rendering/qtipl/rules/TemplateIfQtiPLRenderer.php +++ b/src/qtism/runtime/rendering/qtipl/rules/TemplateIfQtiPLRenderer.php @@ -40,7 +40,7 @@ class TemplateIfQtiPLRenderer extends AbstractQtiPLRenderer * @return mixed The rendered component into another constitution. * @throws RenderingException If something goes wrong while rendering the component. */ - public function render($something) + public function render($something): string { $renderer = new QtiPLRenderer($this->getCRO()); $qtipl = 'if ' . $renderer->writeChildElement($something->getExpression()) . " {\n"; diff --git a/src/qtism/runtime/results/AbstractResultBuilder.php b/src/qtism/runtime/results/AbstractResultBuilder.php index 46517164d..a37b85417 100644 --- a/src/qtism/runtime/results/AbstractResultBuilder.php +++ b/src/qtism/runtime/results/AbstractResultBuilder.php @@ -65,7 +65,7 @@ public function __construct(State $state) * * @return ItemVariableCollection */ - protected function buildVariables() + protected function buildVariables(): ItemVariableCollection { $itemVariables = new ItemVariableCollection(); @@ -108,12 +108,13 @@ protected function buildVariables() * * @return VariableCollection */ - abstract protected function getAllVariables(); + abstract protected function getAllVariables(): VariableCollection; /** * Trigger the build. * * @return mixed */ + #[\ReturnTypeWillChange] abstract public function buildResult(); } diff --git a/src/qtism/runtime/results/AssessmentResultBuilder.php b/src/qtism/runtime/results/AssessmentResultBuilder.php index a9eff82fb..2082cc34d 100644 --- a/src/qtism/runtime/results/AssessmentResultBuilder.php +++ b/src/qtism/runtime/results/AssessmentResultBuilder.php @@ -49,7 +49,7 @@ class AssessmentResultBuilder extends AbstractResultBuilder * @return AssessmentResult * @throws Exception */ - public function buildResult() + public function buildResult(): AssessmentResult { /** @var AssessmentTestSession $state */ $state = $this->state; @@ -90,7 +90,7 @@ public function buildResult() * * @return VariableCollection */ - protected function getAllVariables() + protected function getAllVariables(): VariableCollection { return $this->state->getAllVariables(); } diff --git a/src/qtism/runtime/results/ItemResultBuilder.php b/src/qtism/runtime/results/ItemResultBuilder.php index 81d506435..9d3f2606c 100644 --- a/src/qtism/runtime/results/ItemResultBuilder.php +++ b/src/qtism/runtime/results/ItemResultBuilder.php @@ -45,7 +45,7 @@ class ItemResultBuilder extends AbstractResultBuilder * @return ItemResult * @throws Exception */ - public function buildResult() + public function buildResult(): ItemResult { /** @var AssessmentItemSession $state */ $state = $this->state; @@ -72,7 +72,7 @@ public function buildResult() * * @return VariableCollection */ - protected function getAllVariables() + protected function getAllVariables(): VariableCollection { return $this->state->getAllVariables(); } diff --git a/src/qtism/runtime/rules/AbstractConditionProcessor.php b/src/qtism/runtime/rules/AbstractConditionProcessor.php index 431c78199..f93d1a543 100644 --- a/src/qtism/runtime/rules/AbstractConditionProcessor.php +++ b/src/qtism/runtime/rules/AbstractConditionProcessor.php @@ -68,14 +68,14 @@ public function __construct(QtiComponent $rule) * * @return string the QTI nature of the condition type to take care of. */ - abstract public function getQtiNature(); + abstract public function getQtiNature(): string; /** * Set the trail stack. * * @param array $trail An array of trailed QtiComponent objects. */ - public function setTrail(array &$trail) + public function setTrail(array &$trail): void { $this->trail = $trail; } @@ -85,7 +85,7 @@ public function setTrail(array &$trail) * * @return array An array of trailed Rule objects. */ - public function &getTrail() + public function &getTrail(): array { return $this->trail; } @@ -95,7 +95,7 @@ public function &getTrail() * * @param QtiComponentCollection|QtiComponent $components A collection of Rule objects. */ - public function pushTrail($components) + public function pushTrail($components): void { $trail = &$this->getTrail(); @@ -116,7 +116,7 @@ public function pushTrail($components) * * @return QtiComponent A Rule object. */ - public function popTrail() + public function popTrail(): QtiComponent { $trail = &$this->getTrail(); @@ -128,7 +128,7 @@ public function popTrail() * * @param RuleProcessorFactory $ruleProcessorFactory A RuleProcessorFactory object. */ - public function setRuleProcessorFactory(RuleProcessorFactory $ruleProcessorFactory) + public function setRuleProcessorFactory(RuleProcessorFactory $ruleProcessorFactory): void { $this->ruleProcessorFactory = $ruleProcessorFactory; } @@ -138,7 +138,7 @@ public function setRuleProcessorFactory(RuleProcessorFactory $ruleProcessorFacto * * @return RuleProcessorFactory A RuleProcessorFactory object. */ - public function getRuleProcessorFactory() + public function getRuleProcessorFactory(): RuleProcessorFactory { return $this->ruleProcessorFactory; } @@ -148,7 +148,7 @@ public function getRuleProcessorFactory() * * @throws RuleProcessingException */ - public function process() + public function process(): void { $state = $this->getState(); $this->pushTrail($this->getRule()); diff --git a/src/qtism/runtime/rules/ExitResponseProcessor.php b/src/qtism/runtime/rules/ExitResponseProcessor.php index e74ca70db..629706183 100644 --- a/src/qtism/runtime/rules/ExitResponseProcessor.php +++ b/src/qtism/runtime/rules/ExitResponseProcessor.php @@ -40,7 +40,7 @@ class ExitResponseProcessor extends RuleProcessor * * @throws RuleProcessingException with code = RuleProcessingException::EXIT_RESPONSE In any case. */ - public function process() + public function process(): void { $msg = 'Termination of Response Processing.'; throw new RuleProcessingException($msg, $this, RuleProcessingException::EXIT_RESPONSE); @@ -49,7 +49,7 @@ public function process() /** * @return string */ - protected function getRuleType() + protected function getRuleType(): string { return ExitResponse::class; } diff --git a/src/qtism/runtime/rules/ExitTemplateProcessor.php b/src/qtism/runtime/rules/ExitTemplateProcessor.php index ceeb7eefa..456153879 100644 --- a/src/qtism/runtime/rules/ExitTemplateProcessor.php +++ b/src/qtism/runtime/rules/ExitTemplateProcessor.php @@ -39,7 +39,7 @@ class ExitTemplateProcessor extends RuleProcessor * * @throws RuleProcessingException with code = RuleProcessingException::EXIT_TEMPLATE In any case. */ - public function process() + public function process(): void { $msg = 'Termination of Template Processing.'; throw new RuleProcessingException($msg, $this, RuleProcessingException::EXIT_TEMPLATE); @@ -48,7 +48,7 @@ public function process() /** * @return string */ - protected function getRuleType() + protected function getRuleType(): string { return ExitTemplate::class; } diff --git a/src/qtism/runtime/rules/ExitTestProcessor.php b/src/qtism/runtime/rules/ExitTestProcessor.php index 242be98dd..0348b7001 100644 --- a/src/qtism/runtime/rules/ExitTestProcessor.php +++ b/src/qtism/runtime/rules/ExitTestProcessor.php @@ -39,7 +39,7 @@ class ExitTestProcessor extends RuleProcessor * * @throws RuleProcessingException with code = RuleProcessingException::EXIT_TEST In any case. */ - public function process() + public function process(): void { $msg = 'Termination of Test.'; throw new RuleProcessingException($msg, $this, RuleProcessingException::EXIT_TEST); @@ -48,7 +48,7 @@ public function process() /** * @return string */ - protected function getRuleType() + protected function getRuleType(): string { return ExitTest::class; } diff --git a/src/qtism/runtime/rules/LookupOutcomeValueProcessor.php b/src/qtism/runtime/rules/LookupOutcomeValueProcessor.php index 37f957533..c85c582bf 100644 --- a/src/qtism/runtime/rules/LookupOutcomeValueProcessor.php +++ b/src/qtism/runtime/rules/LookupOutcomeValueProcessor.php @@ -59,7 +59,7 @@ class LookupOutcomeValueProcessor extends RuleProcessor * * @throws RuleProcessingException If one of the error described above arise. */ - public function process() + public function process(): void { $state = $this->getState(); $rule = $this->getRule(); @@ -146,7 +146,7 @@ public function process() /** * @return string */ - protected function getRuleType() + protected function getRuleType(): string { return LookupOutcomeValue::class; } diff --git a/src/qtism/runtime/rules/OutcomeConditionProcessor.php b/src/qtism/runtime/rules/OutcomeConditionProcessor.php index 6dbce770c..4b42e1721 100644 --- a/src/qtism/runtime/rules/OutcomeConditionProcessor.php +++ b/src/qtism/runtime/rules/OutcomeConditionProcessor.php @@ -42,7 +42,7 @@ class OutcomeConditionProcessor extends AbstractConditionProcessor /** * @return string */ - public function getQtiNature() + public function getQtiNature(): string { return 'outcome'; } @@ -50,7 +50,7 @@ public function getQtiNature() /** * @return string */ - protected function getRuleType() + protected function getRuleType(): string { return OutcomeCondition::class; } diff --git a/src/qtism/runtime/rules/ResponseConditionProcessor.php b/src/qtism/runtime/rules/ResponseConditionProcessor.php index b21cb18f9..40dc941cb 100644 --- a/src/qtism/runtime/rules/ResponseConditionProcessor.php +++ b/src/qtism/runtime/rules/ResponseConditionProcessor.php @@ -42,7 +42,7 @@ class ResponseConditionProcessor extends AbstractConditionProcessor /** * @return string */ - public function getQtiNature() + public function getQtiNature(): string { return 'response'; } @@ -50,7 +50,7 @@ public function getQtiNature() /** * @return string */ - protected function getRuleType() + protected function getRuleType(): string { return ResponseCondition::class; } diff --git a/src/qtism/runtime/rules/RuleEngine.php b/src/qtism/runtime/rules/RuleEngine.php index c088cc2e7..9aa4a84ae 100644 --- a/src/qtism/runtime/rules/RuleEngine.php +++ b/src/qtism/runtime/rules/RuleEngine.php @@ -62,7 +62,7 @@ public function __construct(QtiComponent $rule, State $context = null) * @param QtiComponent $rule A Rule object to be executed. * @throws InvalidArgumentException If $rule is not a Rule object. */ - public function setComponent(QtiComponent $rule) + public function setComponent(QtiComponent $rule): void { if ($rule instanceof Rule) { parent::setComponent($rule); @@ -77,7 +77,7 @@ public function setComponent(QtiComponent $rule) * * @param RuleProcessorFactory $ruleProcessorFactory A RuleProcessorFactory object. */ - protected function setRuleProcessorFactory(RuleProcessorFactory $ruleProcessorFactory) + protected function setRuleProcessorFactory(RuleProcessorFactory $ruleProcessorFactory): void { $this->ruleProcessorFactory = $ruleProcessorFactory; } @@ -87,7 +87,7 @@ protected function setRuleProcessorFactory(RuleProcessorFactory $ruleProcessorFa * * @return RuleProcessorFactory A RuleProcessorFactory object. */ - protected function getRuleProcessorFactory() + protected function getRuleProcessorFactory(): RuleProcessorFactory { return $this->ruleProcessorFactory; } @@ -97,7 +97,7 @@ protected function getRuleProcessorFactory() * * @throws RuleProcessingException */ - public function process() + public function process(): void { $rule = $this->getComponent(); $context = $this->getContext(); diff --git a/src/qtism/runtime/rules/RuleProcessingException.php b/src/qtism/runtime/rules/RuleProcessingException.php index 00d739975..72c9e9996 100644 --- a/src/qtism/runtime/rules/RuleProcessingException.php +++ b/src/qtism/runtime/rules/RuleProcessingException.php @@ -38,7 +38,7 @@ class RuleProcessingException extends ProcessingException * * @var int */ - const EXIT_RESPONSE = 10; + public const EXIT_RESPONSE = 10; /** * The error code to use when the exitTest rule is invoked @@ -46,7 +46,7 @@ class RuleProcessingException extends ProcessingException * * @var int */ - const EXIT_TEST = 11; + public const EXIT_TEST = 11; /** * The error code to use when the exitTemplate rule is invoked @@ -54,7 +54,7 @@ class RuleProcessingException extends ProcessingException * * @var int */ - const EXIT_TEMPLATE = 12; + public const EXIT_TEMPLATE = 12; /** * The error code to use when a templateConstraint rule returned @@ -62,7 +62,7 @@ class RuleProcessingException extends ProcessingException * * @var int */ - const TEMPLATE_CONSTRAINT_UNSATISFIED = 13; + public const TEMPLATE_CONSTRAINT_UNSATISFIED = 13; /** * Set the source of the error. @@ -70,7 +70,7 @@ class RuleProcessingException extends ProcessingException * @param Processable $source The source of the error. * @throws InvalidArgumentException If $source is not an ExpressionProcessor object. */ - public function setSource(Processable $source) + public function setSource(Processable $source): void { if ($source instanceof RuleProcessor) { parent::setSource($source); diff --git a/src/qtism/runtime/rules/RuleProcessor.php b/src/qtism/runtime/rules/RuleProcessor.php index 04e4e6f5a..4790fb335 100644 --- a/src/qtism/runtime/rules/RuleProcessor.php +++ b/src/qtism/runtime/rules/RuleProcessor.php @@ -72,7 +72,7 @@ public function __construct(Rule $rule) * @param Rule $rule * @throws InvalidArgumentException If $rule is not compliant with the rule processor implementation. */ - public function setRule(Rule $rule) + public function setRule(Rule $rule): void { $expectedType = $this->getRuleType(); @@ -95,7 +95,7 @@ public function setRule(Rule $rule) * * @return Rule */ - public function getRule() + public function getRule(): Rule { return $this->rule; } @@ -105,7 +105,7 @@ public function getRule() * * @param State $state A State object. */ - public function setState(State $state) + public function setState(State $state): void { $this->state = $state; } @@ -115,7 +115,7 @@ public function setState(State $state) * * @return State */ - public function getState() + public function getState(): State { return $this->state; } @@ -126,5 +126,5 @@ public function getState() * * @return string A Fully Qualified PHP Class Name (FQCN). */ - abstract protected function getRuleType(); + abstract protected function getRuleType(): string; } diff --git a/src/qtism/runtime/rules/RuleProcessorFactory.php b/src/qtism/runtime/rules/RuleProcessorFactory.php index aa7f8955b..458965891 100644 --- a/src/qtism/runtime/rules/RuleProcessorFactory.php +++ b/src/qtism/runtime/rules/RuleProcessorFactory.php @@ -49,7 +49,7 @@ public function __construct() * @return Processable The related RuleProcessor object. * @throws RuntimeException If no RuleProcessor can be found for the given $rule. */ - public function createProcessor(QtiComponent $rule) + public function createProcessor(QtiComponent $rule): Processable { $qtiClassName = ucfirst($rule->getQtiClassName()); $nsPackage = 'qtism\\runtime\\rules\\'; diff --git a/src/qtism/runtime/rules/SetCorrectResponseProcessor.php b/src/qtism/runtime/rules/SetCorrectResponseProcessor.php index 3a940876e..d8e91c68a 100644 --- a/src/qtism/runtime/rules/SetCorrectResponseProcessor.php +++ b/src/qtism/runtime/rules/SetCorrectResponseProcessor.php @@ -50,7 +50,7 @@ class SetCorrectResponseProcessor extends RuleProcessor * * @throws RuleProcessingException */ - public function process() + public function process(): void { $rule = $this->getRule(); $state = $this->getState(); @@ -85,7 +85,7 @@ public function process() /** * @return string */ - protected function getRuleType() + protected function getRuleType(): string { return SetCorrectResponse::class; } diff --git a/src/qtism/runtime/rules/SetDefaultValueProcessor.php b/src/qtism/runtime/rules/SetDefaultValueProcessor.php index bf27ad79a..793cd24bc 100644 --- a/src/qtism/runtime/rules/SetDefaultValueProcessor.php +++ b/src/qtism/runtime/rules/SetDefaultValueProcessor.php @@ -51,7 +51,7 @@ class SetDefaultValueProcessor extends RuleProcessor * * @throws RuleProcessingException */ - public function process() + public function process(): void { $rule = $this->getRule(); $state = $this->getState(); @@ -86,7 +86,7 @@ public function process() /** * @return string */ - protected function getRuleType() + protected function getRuleType(): string { return SetDefaultValue::class; } diff --git a/src/qtism/runtime/rules/SetOutcomeValueProcessor.php b/src/qtism/runtime/rules/SetOutcomeValueProcessor.php index 13daed1ff..25ef8c123 100644 --- a/src/qtism/runtime/rules/SetOutcomeValueProcessor.php +++ b/src/qtism/runtime/rules/SetOutcomeValueProcessor.php @@ -23,8 +23,8 @@ namespace qtism\runtime\rules; -use qtism\runtime\common\OutcomeVariable; use qtism\data\rules\SetOutcomeValue; +use qtism\runtime\common\OutcomeVariable; /** * From IMS QTI: @@ -44,15 +44,15 @@ class SetOutcomeValueProcessor extends SetValueProcessor /** * @return string */ - protected function getRuleType() + protected function getRuleType(): string { return SetOutcomeValue::class; } /** - * @return mixed|string + * @inheritDoc */ - protected function getVariableType() + protected function getVariableType(): string { return OutcomeVariable::class; } diff --git a/src/qtism/runtime/rules/SetTemplateValueProcessor.php b/src/qtism/runtime/rules/SetTemplateValueProcessor.php index dbad335da..f9e72d471 100644 --- a/src/qtism/runtime/rules/SetTemplateValueProcessor.php +++ b/src/qtism/runtime/rules/SetTemplateValueProcessor.php @@ -23,8 +23,8 @@ namespace qtism\runtime\rules; -use qtism\runtime\common\TemplateVariable; use qtism\data\rules\SetTemplateValue; +use qtism\runtime\common\TemplateVariable; /** * Class SetTemplateValueProcessor @@ -34,15 +34,15 @@ class SetTemplateValueProcessor extends SetValueProcessor /** * @return string */ - protected function getRuleType() + protected function getRuleType(): string { return SetTemplateValue::class; } /** - * @return mixed|string + * @inheritDoc */ - protected function getVariableType() + protected function getVariableType(): string { return TemplateVariable::class; } diff --git a/src/qtism/runtime/rules/SetValueProcessor.php b/src/qtism/runtime/rules/SetValueProcessor.php index 2ede63474..223504431 100644 --- a/src/qtism/runtime/rules/SetValueProcessor.php +++ b/src/qtism/runtime/rules/SetValueProcessor.php @@ -49,7 +49,7 @@ abstract class SetValueProcessor extends RuleProcessor * * @throws RuleProcessingException If one of the error described above arise. */ - public function process() + public function process(): void { $state = $this->getState(); $rule = $this->getRule(); @@ -103,7 +103,7 @@ public function process() } /** - * @return mixed + * @return string */ - abstract protected function getVariableType(); + abstract protected function getVariableType(): string; } diff --git a/src/qtism/runtime/rules/TemplateConditionProcessor.php b/src/qtism/runtime/rules/TemplateConditionProcessor.php index 75ac20ee2..0ef930170 100644 --- a/src/qtism/runtime/rules/TemplateConditionProcessor.php +++ b/src/qtism/runtime/rules/TemplateConditionProcessor.php @@ -41,7 +41,7 @@ class TemplateConditionProcessor extends AbstractConditionProcessor /** * @return string */ - public function getQtiNature() + public function getQtiNature(): string { return 'template'; } @@ -49,7 +49,7 @@ public function getQtiNature() /** * @return string */ - protected function getRuleType() + protected function getRuleType(): string { return TemplateCondition::class; } diff --git a/src/qtism/runtime/rules/TemplateConstraintProcessor.php b/src/qtism/runtime/rules/TemplateConstraintProcessor.php index dfd3a8186..2938d4c92 100644 --- a/src/qtism/runtime/rules/TemplateConstraintProcessor.php +++ b/src/qtism/runtime/rules/TemplateConstraintProcessor.php @@ -60,7 +60,7 @@ class TemplateConstraintProcessor extends RuleProcessor * * @throws RuleProcessingException with code = RuleProcessingException::TEMPLATE_CONSTRAINT_UNSATISFIED. */ - public function process() + public function process(): void { $state = $this->getState(); $rule = $this->getRule(); @@ -78,7 +78,7 @@ public function process() /** * @return string */ - protected function getRuleType() + protected function getRuleType(): string { return TemplateConstraint::class; } diff --git a/src/qtism/runtime/storage/binary/AbstractQtiBinaryStorage.php b/src/qtism/runtime/storage/binary/AbstractQtiBinaryStorage.php index d17ebaea0..ae39da704 100644 --- a/src/qtism/runtime/storage/binary/AbstractQtiBinaryStorage.php +++ b/src/qtism/runtime/storage/binary/AbstractQtiBinaryStorage.php @@ -87,7 +87,7 @@ public function __construct( * * @param BinaryAssessmentTestSeeker $seeker An AssessmentTestSeeker object. */ - protected function setSeeker(BinaryAssessmentTestSeeker $seeker) + protected function setSeeker(BinaryAssessmentTestSeeker $seeker): void { $this->seeker = $seeker; } @@ -97,7 +97,7 @@ protected function setSeeker(BinaryAssessmentTestSeeker $seeker) * * @return BinaryAssessmentTestSeeker An AssessmentTestSeeker object. */ - protected function getSeeker() + protected function getSeeker(): BinaryAssessmentTestSeeker { return $this->seeker; } @@ -110,7 +110,7 @@ protected function getSeeker() * @return AssessmentTestSession An AssessmentTestSession object. * @throws StorageException */ - public function instantiate($config = 0, $sessionId = '') + public function instantiate($config = 0, $sessionId = ''): AssessmentTestSession { // If not provided, generate a session ID. if (empty($sessionId)) { @@ -134,7 +134,7 @@ public function instantiate($config = 0, $sessionId = '') * @param AssessmentTestSession $assessmentTestSession * @throws StorageException */ - public function persist(AssessmentTestSession $assessmentTestSession) + public function persist(AssessmentTestSession $assessmentTestSession): void { try { $stream = new MemoryStream(); @@ -245,7 +245,7 @@ public function persist(AssessmentTestSession $assessmentTestSession) * @return AssessmentTestSession An AssessmentTestSession object. * @throws StorageException If the AssessmentTestSession could not be retrieved from persistent binary storage. */ - public function retrieve($sessionId) + public function retrieve($sessionId): AssessmentTestSession { try { $stream = $this->getRetrievalStream($sessionId); @@ -359,7 +359,7 @@ public function retrieve($sessionId) * @return MemoryStream A MemoryStream object. * @throws RuntimeException If an error occurs. */ - abstract protected function getRetrievalStream($sessionId); + abstract protected function getRetrievalStream($sessionId): MemoryStream; /** * Persist A MemoryStream that contains the binary data representing $assessmentTestSession in an appropriate location. @@ -377,5 +377,5 @@ abstract protected function persistStream(AssessmentTestSession $assessmentTestS * @param IStream $stream * @return BinaryStreamAccess */ - abstract protected function createBinaryStreamAccess(IStream $stream); + abstract protected function createBinaryStreamAccess(IStream $stream): BinaryStreamAccess; } diff --git a/src/qtism/runtime/storage/binary/LocalQtiBinaryStorage.php b/src/qtism/runtime/storage/binary/LocalQtiBinaryStorage.php index 1811e5db0..c815412d7 100644 --- a/src/qtism/runtime/storage/binary/LocalQtiBinaryStorage.php +++ b/src/qtism/runtime/storage/binary/LocalQtiBinaryStorage.php @@ -70,7 +70,7 @@ public function __construct(AbstractSessionManager $manager, AssessmentTest $tes * * @param string $path */ - public function setPath($path) + public function setPath($path): void { $this->path = $path; } @@ -80,7 +80,7 @@ public function setPath($path) * * @return string */ - public function getPath() + public function getPath(): string { return $this->path; } @@ -93,7 +93,7 @@ public function getPath() * @param MemoryStream $stream The MemoryStream to be stored in the temporary directory of the host file system. * @throws RuntimeException If the binary stream cannot be persisted. */ - protected function persistStream(AssessmentTestSession $assessmentTestSession, MemoryStream $stream) + protected function persistStream(AssessmentTestSession $assessmentTestSession, MemoryStream $stream): void { $sessionId = $assessmentTestSession->getSessionId(); @@ -114,7 +114,7 @@ protected function persistStream(AssessmentTestSession $assessmentTestSession, M * @return MemoryStream A MemoryStream object. * @throws RuntimeException If the binary stream cannot be persisted. */ - protected function getRetrievalStream($sessionId) + protected function getRetrievalStream($sessionId): MemoryStream { $path = $this->getPath() . DIRECTORY_SEPARATOR . md5($sessionId) . '.bin'; @@ -133,7 +133,7 @@ protected function getRetrievalStream($sessionId) * @return BinaryStreamAccess|QtiBinaryStreamAccess * @throws StreamAccessException */ - protected function createBinaryStreamAccess(IStream $stream) + protected function createBinaryStreamAccess(IStream $stream): BinaryStreamAccess { return new QtiBinaryStreamAccess($stream, new FileSystemFileManager(), new VariableFactory()); } @@ -142,7 +142,7 @@ protected function createBinaryStreamAccess(IStream $stream) * @param string $sessionId * @return bool */ - public function exists($sessionId) + public function exists($sessionId): bool { $path = $this->getPath() . DIRECTORY_SEPARATOR . md5($sessionId) . '.bin'; return @is_readable($path); @@ -153,7 +153,7 @@ public function exists($sessionId) * @return bool * @throws StorageException */ - public function delete(AssessmentTestSession $assessmentTestSession) + public function delete(AssessmentTestSession $assessmentTestSession): bool { $fileManager = $this->getManager()->getFileManager(); foreach ($assessmentTestSession->getFiles() as $file) { diff --git a/src/qtism/runtime/storage/binary/QtiBinaryStreamAccess.php b/src/qtism/runtime/storage/binary/QtiBinaryStreamAccess.php index d6f58d017..bd85e6c21 100644 --- a/src/qtism/runtime/storage/binary/QtiBinaryStreamAccess.php +++ b/src/qtism/runtime/storage/binary/QtiBinaryStreamAccess.php @@ -126,7 +126,7 @@ public function __construct( * * @param FileManager $fileManager A FileManager object. */ - protected function setFileManager(FileManager $fileManager) + protected function setFileManager(FileManager $fileManager): void { $this->fileManager = $fileManager; } @@ -136,7 +136,7 @@ protected function setFileManager(FileManager $fileManager) * * @return FileManager */ - protected function getFileManager() + protected function getFileManager(): FileManager { return $this->fileManager; } @@ -149,7 +149,7 @@ protected function getFileManager() * @param int The kind of value to be read (self::RW_VALUE | self::RW_DEFAULTVALUE | self::RW_CORRECTRESPONSE) * @throws BinaryStreamAccessException If an error occurs at the binary level. */ - public function readVariableValue(Variable $variable, $valueType = self::RW_VALUE) + public function readVariableValue(Variable $variable, $valueType = self::RW_VALUE): void { switch ($valueType) { case self::RW_DEFAULTVALUE: @@ -224,7 +224,7 @@ public function readVariableValue(Variable $variable, $valueType = self::RW_VALU * @param int $valueType * @throws QtiBinaryStreamAccessException */ - public function writeVariableValue(Variable $variable, $valueType = self::RW_VALUE) + public function writeVariableValue(Variable $variable, $valueType = self::RW_VALUE): void { switch ($valueType) { case self::RW_DEFAULTVALUE: @@ -305,7 +305,7 @@ public function writeVariableValue(Variable $variable, $valueType = self::RW_VAL * @return array An array where the value at index 0 is the key string and index 1 is the value. * @throws QtiBinaryStreamAccessException */ - public function readRecordField($isNull = false) + public function readRecordField($isNull = false): array { try { $key = $this->readString(); @@ -333,7 +333,7 @@ public function readRecordField($isNull = false) * @param bool $isNull * @throws QtiBinaryStreamAccessException */ - public function writeRecordField(array $recordField, $isNull = false) + public function writeRecordField(array $recordField, $isNull = false): void { try { $this->writeBoolean($isNull); @@ -361,7 +361,7 @@ public function writeRecordField(array $recordField, $isNull = false) * @return string An identifier. * @throws QtiBinaryStreamAccessException */ - public function readIdentifier() + public function readIdentifier(): string { try { return $this->readString(); @@ -377,7 +377,7 @@ public function readIdentifier() * @param string $identifier A QTI Identifier. * @throws QtiBinaryStreamAccessException */ - public function writeIdentifier($identifier) + public function writeIdentifier($identifier): void { try { $this->writeString($identifier); @@ -393,7 +393,7 @@ public function writeIdentifier($identifier) * @return QtiPoint A QtiPoint object. * @throws QtiBinaryStreamAccessException */ - public function readPoint() + public function readPoint(): QtiPoint { try { return new QtiPoint($this->readShort(), $this->readShort()); @@ -409,7 +409,7 @@ public function readPoint() * @param QtiPoint $point A QtiPoint object. * @throws QtiBinaryStreamAccessException */ - public function writePoint(QtiPoint $point) + public function writePoint(QtiPoint $point): void { try { $this->writeShort($point->getX()); @@ -426,7 +426,7 @@ public function writePoint(QtiPoint $point) * @return QtiPair A QtiPair object. * @throws QtiBinaryStreamAccessException */ - public function readPair() + public function readPair(): QtiPair { try { return new QtiPair($this->readString(), $this->readString()); @@ -442,7 +442,7 @@ public function readPair() * @param QtiPair $pair A Pair object. * @throws QtiBinaryStreamAccessException */ - public function writePair(QtiPair $pair) + public function writePair(QtiPair $pair): void { try { $this->writeString($pair->getFirst()); @@ -459,7 +459,7 @@ public function writePair(QtiPair $pair) * @return QtiDirectedPair A DirectedPair object. * @throws QtiBinaryStreamAccessException */ - public function readDirectedPair() + public function readDirectedPair(): QtiDirectedPair { try { return new QtiDirectedPair($this->readString(), $this->readString()); @@ -475,7 +475,7 @@ public function readDirectedPair() * @param QtiDirectedPair $directedPair A DirectedPair object. * @throws QtiBinaryStreamAccessException */ - public function writeDirectedPair(QtiDirectedPair $directedPair) + public function writeDirectedPair(QtiDirectedPair $directedPair): void { try { $this->writeString($directedPair->getFirst()); @@ -492,7 +492,7 @@ public function writeDirectedPair(QtiDirectedPair $directedPair) * @return ShufflingGroup * @throws QtiBinaryStreamAccessException */ - public function readShufflingGroup() + public function readShufflingGroup(): ShufflingGroup { try { $identifiers = new IdentifierCollection(); @@ -526,7 +526,7 @@ public function readShufflingGroup() * @param ShufflingGroup $shufflingGroup * @throws QtiBinaryStreamAccessException */ - public function writeShufflingGroup(ShufflingGroup $shufflingGroup) + public function writeShufflingGroup(ShufflingGroup $shufflingGroup): void { try { $identifiers = $shufflingGroup->getIdentifiers(); @@ -552,7 +552,7 @@ public function writeShufflingGroup(ShufflingGroup $shufflingGroup) * @return Shuffling * @throws QtiBinaryStreamAccessException */ - public function readShufflingState() + public function readShufflingState(): Shuffling { try { $responseIdentifier = $this->readIdentifier(); @@ -577,7 +577,7 @@ public function readShufflingState() * @param Shuffling $shufflingState * @throws QtiBinaryStreamAccessException */ - public function writeShufflingState(Shuffling $shufflingState) + public function writeShufflingState(Shuffling $shufflingState): void { try { $this->writeIdentifier($shufflingState->getResponseIdentifier()); @@ -599,7 +599,7 @@ public function writeShufflingState(Shuffling $shufflingState) * @return QtiDuration A QtiDuration object. * @throws QtiBinaryStreamAccessException */ - public function readDuration() + public function readDuration(): QtiDuration { try { return new QtiDuration($this->readString()); @@ -615,7 +615,7 @@ public function readDuration() * @param QtiDuration $duration A QtiDuration object. * @throws QtiBinaryStreamAccessException */ - public function writeDuration(QtiDuration $duration) + public function writeDuration(QtiDuration $duration): void { try { $this->writeString($duration->__toString()); @@ -631,7 +631,7 @@ public function writeDuration(QtiDuration $duration) * @return string A URI. * @throws QtiBinaryStreamAccessException */ - public function readUri() + public function readUri(): string { try { return $this->readString(); @@ -647,7 +647,7 @@ public function readUri() * @param string $uri A URI. * @throws QtiBinaryStreamAccessException */ - public function writeUri($uri) + public function writeUri($uri): void { try { $this->writeString($uri); @@ -681,7 +681,7 @@ public function readIntOrIdentifier() * @param int|string $intOrIdentifier An integer or a string value. * @throws QtiBinaryStreamAccessException */ - public function writeIntOrIdentifier($intOrIdentifier) + public function writeIntOrIdentifier($intOrIdentifier): void { try { if (is_int($intOrIdentifier)) { @@ -718,7 +718,7 @@ public function readAssessmentItemSession( AbstractSessionManager $manager, AssessmentTestSeeker $seeker, QtiBinaryVersion $version - ) { + ): AssessmentItemSession { try { $itemRefPosition = $this->readShort(); /** @var IAssessmentItem $assessmentItemRef */ @@ -832,7 +832,7 @@ public function readAssessmentItemSession( * @param AssessmentItemSession $session An AssessmentItemSession object. * @throws QtiBinaryStreamAccessException */ - public function writeAssessmentItemSession(AssessmentTestSeeker $seeker, AssessmentItemSession $session) + public function writeAssessmentItemSession(AssessmentTestSeeker $seeker, AssessmentItemSession $session): void { try { $this->writeShort($seeker->seekPosition($session->getAssessmentItem())); @@ -949,7 +949,7 @@ public function writeAssessmentItemSession(AssessmentTestSeeker $seeker, Assessm * @return RouteItem * @throws QtiBinaryStreamAccessException */ - public function readRouteItem(AssessmentTestSeeker $seeker) + public function readRouteItem(AssessmentTestSeeker $seeker): RouteItem { try { $occurrence = $this->readTinyInt(); @@ -1002,7 +1002,7 @@ public function readRouteItem(AssessmentTestSeeker $seeker) * @param RouteItem $routeItem A RouteItem object. * @throws QtiBinaryStreamAccessException */ - public function writeRouteItem(AssessmentTestSeeker $seeker, RouteItem $routeItem) + public function writeRouteItem(AssessmentTestSeeker $seeker, RouteItem $routeItem): void { try { $this->writeTinyInt($routeItem->getOccurence()); @@ -1046,7 +1046,7 @@ public function writeRouteItem(AssessmentTestSeeker $seeker, RouteItem $routeIte * @return PendingResponses A PendingResponses object. * @throws QtiBinaryStreamAccessException */ - public function readPendingResponses(AssessmentTestSeeker $seeker) + public function readPendingResponses(AssessmentTestSeeker $seeker): PendingResponses { try { // Read the state. @@ -1096,7 +1096,7 @@ public function readPendingResponses(AssessmentTestSeeker $seeker) * @param PendingResponses $pendingResponses The read PendingResponses object. * @throws QtiBinaryStreamAccessException */ - public function writePendingResponses(AssessmentTestSeeker $seeker, PendingResponses $pendingResponses) + public function writePendingResponses(AssessmentTestSeeker $seeker, PendingResponses $pendingResponses): void { try { $state = $pendingResponses->getState(); @@ -1154,7 +1154,7 @@ public function writePendingResponses(AssessmentTestSeeker $seeker, PendingRespo * @throws BinaryStreamAccessException * @throws QtiBinaryStreamAccessException */ - public function writeFile(QtiFile $file) + public function writeFile(QtiFile $file): void { $toPersist = $file instanceof FileHash ? json_encode($file) @@ -1175,7 +1175,7 @@ public function writeFile(QtiFile $file) * @throws QtiBinaryStreamAccessException * @throws FileManagerException */ - public function readFile() + public function readFile(): QtiFile { try { $id = $this->readString(); @@ -1200,7 +1200,7 @@ public function readFile() * @return array An array of integer values representing flow positions. * @throws QtiBinaryStreamAccessException */ - public function readPath() + public function readPath(): array { try { $pathCount = $this->readShort(); @@ -1223,7 +1223,7 @@ public function readPath() * @param array $path An array of integer values representing flow positions. * @throws QtiBinaryStreamAccessException */ - public function writePath(array $path) + public function writePath(array $path): void { try { $this->writeShort(count($path)); diff --git a/src/qtism/runtime/storage/binary/QtiBinaryStreamAccessException.php b/src/qtism/runtime/storage/binary/QtiBinaryStreamAccessException.php index 638c9169e..807213710 100644 --- a/src/qtism/runtime/storage/binary/QtiBinaryStreamAccessException.php +++ b/src/qtism/runtime/storage/binary/QtiBinaryStreamAccessException.php @@ -35,110 +35,110 @@ class QtiBinaryStreamAccessException extends BinaryStreamAccessException * * @var int */ - const VARIABLE = 10; + public const VARIABLE = 10; /** * An error occurred while reading/writing a Record Field. * * @var int */ - const RECORDFIELD = 11; + public const RECORDFIELD = 11; /** * An error occurred while reading/writing a QTI identifier. * * @var int */ - const IDENTIFIER = 12; + public const IDENTIFIER = 12; /** * An error occurred while reading/writing a QTI point. * * @var int */ - const POINT = 13; + public const POINT = 13; /** * An error occurred while reading/writing a QTI pair. * * @var int */ - const PAIR = 14; + public const PAIR = 14; /** * An error occurred while reading/writing a QTI directedPair. * * @var int */ - const DIRECTEDPAIR = 15; + public const DIRECTEDPAIR = 15; /** * An error occurred while reading/writing a QTI duration. * * @var int */ - const DURATION = 16; + public const DURATION = 16; /** * An error occurred while reading/writing a URI. * * @var int */ - const URI = 17; + public const URI = 17; /** * An error occurred while reading/writing File's binary data. * * @var int */ - const FILE = 18; + public const FILE = 18; /** * An error occurred while reading/writing an intOrIdentifier. * * @var int */ - const INTORIDENTIFIER = 19; + public const INTORIDENTIFIER = 19; /** * An error occurred while reading/writing an assessment item session. * * @var int */ - const ITEM_SESSION = 20; + public const ITEM_SESSION = 20; /** * An error occurred while reading/writing a route item. * * @var int */ - const ROUTE_ITEM = 21; + public const ROUTE_ITEM = 21; /** * An error occurred while reading/writing pending responses. * * @var int */ - const PENDING_RESPONSES = 22; + public const PENDING_RESPONSES = 22; /** * An error occurred while reading/writing path. * * @var int */ - const PATH = 23; + public const PATH = 23; /** * An error occurred while reading/writing shuffling states. * * @var int */ - const SHUFFLING_STATE = 24; + public const SHUFFLING_STATE = 24; /** * An error occurred while reading/writing a shuffling group. * * @var int */ - const SHUFFLING_GROUP = 25; + public const SHUFFLING_GROUP = 25; } diff --git a/src/qtism/runtime/storage/binary/QtiBinaryVersion.php b/src/qtism/runtime/storage/binary/QtiBinaryVersion.php index 01fa14b17..66e968efc 100644 --- a/src/qtism/runtime/storage/binary/QtiBinaryVersion.php +++ b/src/qtism/runtime/storage/binary/QtiBinaryVersion.php @@ -21,8 +21,6 @@ * @license GPLv2 */ -declare(strict_types=1); - namespace qtism\runtime\storage\binary; use qtism\common\storage\BinaryStreamAccessException; @@ -67,7 +65,7 @@ class QtiBinaryVersion * @param QtiBinaryStreamAccess $access * @throws BinaryStreamAccessException */ - public function persist(QtiBinaryStreamAccess $access) + public function persist(QtiBinaryStreamAccess $access): void { $access->writeTinyInt(self::CURRENT_VERSION); $access->writeString(self::CURRENT_BRANCH); @@ -79,7 +77,7 @@ public function persist(QtiBinaryStreamAccess $access) * @param QtiBinaryStreamAccess $access * @throws BinaryStreamAccessException */ - public function retrieve(QtiBinaryStreamAccess $access) + public function retrieve(QtiBinaryStreamAccess $access): void { $this->version = $access->readTinyInt(); diff --git a/src/qtism/runtime/storage/common/AbstractStorage.php b/src/qtism/runtime/storage/common/AbstractStorage.php index b9af1bd80..29c8f9a58 100644 --- a/src/qtism/runtime/storage/common/AbstractStorage.php +++ b/src/qtism/runtime/storage/common/AbstractStorage.php @@ -70,7 +70,7 @@ public function __construct(AbstractSessionManager $manager, AssessmentTest $tes * * @param AbstractSessionManager $manager */ - protected function setManager(AbstractSessionManager $manager) + protected function setManager(AbstractSessionManager $manager): void { $this->manager = $manager; } @@ -80,7 +80,7 @@ protected function setManager(AbstractSessionManager $manager) * * @return AbstractSessionManager */ - protected function getManager() + protected function getManager(): AbstractSessionManager { return $this->manager; } @@ -92,7 +92,7 @@ protected function getManager() * * @param AssessmentTest $test */ - protected function setAssessmentTest(AssessmentTest $test) + protected function setAssessmentTest(AssessmentTest $test): void { $this->assessmentTest = $test; } @@ -152,7 +152,7 @@ abstract public function retrieve($sessionId); * @return bool * @throws StorageException If an error occurs while determining whether the AssessmentTestSession object exists in the storage. */ - abstract public function exists($sessionId); + abstract public function exists($sessionId): bool; /** * Delete an AssessmentTestSession object from persistence. @@ -172,5 +172,5 @@ abstract public function exists($sessionId); * @return bool * @throws StorageException If an error occurs while deleting the AssessmentTestSession object. */ - abstract public function delete(AssessmentTestSession $assessmentTestSession); + abstract public function delete(AssessmentTestSession $assessmentTestSession): bool; } diff --git a/src/qtism/runtime/storage/common/AssessmentTestSeeker.php b/src/qtism/runtime/storage/common/AssessmentTestSeeker.php index c3b7c08e3..0ff69e990 100644 --- a/src/qtism/runtime/storage/common/AssessmentTestSeeker.php +++ b/src/qtism/runtime/storage/common/AssessmentTestSeeker.php @@ -76,7 +76,7 @@ public function __construct(AssessmentTest $test, array $classes) * * @param array $classCounter An array where keys are QTI class names and values are the count of explored components for this class name. */ - protected function setClassCounter(array $classCounter) + protected function setClassCounter(array $classCounter): void { $this->classCounter = $classCounter; } @@ -86,7 +86,7 @@ protected function setClassCounter(array $classCounter) * * @return array An array where keys are QTI class names and values are the count of explored components for this class name. */ - protected function &getClassCounter() + protected function &getClassCounter(): array { return $this->classCounter; } @@ -96,7 +96,7 @@ protected function &getClassCounter() * * @param QtiComponentIterator $iterator */ - protected function setIterator(QtiComponentIterator $iterator) + protected function setIterator(QtiComponentIterator $iterator): void { $this->iterator = $iterator; } @@ -106,7 +106,7 @@ protected function setIterator(QtiComponentIterator $iterator) * * @return QtiComponentIterator */ - protected function getIterator() + protected function getIterator(): QtiComponentIterator { return $this->iterator; } @@ -118,7 +118,7 @@ protected function getIterator() * * @param array $componentStore */ - protected function setComponentStore(array $componentStore) + protected function setComponentStore(array $componentStore): void { $this->componentStore = $componentStore; } @@ -130,7 +130,7 @@ protected function setComponentStore(array $componentStore) * * @return array */ - protected function &getComponentStore() + protected function &getComponentStore(): array { return $this->componentsStore; } @@ -141,7 +141,7 @@ protected function &getComponentStore() * @param QtiComponent $component A QTI Component. * @return int The position in the AssessmentTest tree the component was found. */ - protected function addToComponentStore(QtiComponent $component) + protected function addToComponentStore(QtiComponent $component): int { $class = $component->getQtiClassName(); @@ -202,7 +202,7 @@ protected function getPositionFromComponentStore(QtiComponent $component) * @return QtiComponent The QtiComponent object that corresponds to $class and $position. * @throws OutOfBoundsException If no such QtiComponent could be found in the AssessmentTest tree. */ - public function seekComponent($class, $position) + public function seekComponent($class, $position): QtiComponent { if (($component = $this->getComponentFromComponentStore($class, $position)) !== false) { // Already explored! @@ -233,7 +233,7 @@ public function seekComponent($class, $position) * @return int The position of $component in the AssessmentTest tree. * @throws OutOfBoundsException If no such $component could be found in the AssessmentTest tree. */ - public function seekPosition(QtiComponent $component) + public function seekPosition(QtiComponent $component): int { if (($position = $this->getPositionFromComponentStore($component)) !== false) { // Already explored. @@ -263,7 +263,7 @@ public function seekPosition(QtiComponent $component) * * @param QtiComponent $component A QtiComponent object. */ - protected function incrementClassCount(QtiComponent $component) + protected function incrementClassCount(QtiComponent $component): void { $class = $component->getQtiClassName(); @@ -280,7 +280,7 @@ protected function incrementClassCount(QtiComponent $component) * @param string $class A QTI class name. * @return int The number of explored components that belong to the $class. */ - protected function getClassCount($class) + protected function getClassCount($class): int { $count = 0; @@ -297,7 +297,7 @@ protected function getClassCount($class) * * @return AssessmentTest An AssessmentTest object. */ - public function getAssessmentTest() + public function getAssessmentTest(): AssessmentTest { return $this->getIterator()->getRootComponent(); } diff --git a/src/qtism/runtime/storage/common/StorageException.php b/src/qtism/runtime/storage/common/StorageException.php index c5741ba5b..52b97ed5a 100644 --- a/src/qtism/runtime/storage/common/StorageException.php +++ b/src/qtism/runtime/storage/common/StorageException.php @@ -39,7 +39,7 @@ class StorageException extends Exception implements QtiSdkPackageContentExceptio * * @var int */ - const UNKNOWN = 0; + public const UNKNOWN = 0; /** * Error code to be used when an error occurs while @@ -47,7 +47,7 @@ class StorageException extends Exception implements QtiSdkPackageContentExceptio * * @var int */ - const INSTANTIATION = 1; + public const INSTANTIATION = 1; /** * Error code to use when an error occurs while @@ -55,7 +55,7 @@ class StorageException extends Exception implements QtiSdkPackageContentExceptio * * @var int */ - const PERSISTENCE = 2; + public const PERSISTENCE = 2; /** * Error code to use when an error occurs while @@ -63,12 +63,12 @@ class StorageException extends Exception implements QtiSdkPackageContentExceptio * * @var int */ - const RETRIEVAL = 3; + public const RETRIEVAL = 3; /** * Error code to use when an error occurs while deleting an AssessmentTestSession. * * @var int */ - const DELETION = 4; + public const DELETION = 4; } diff --git a/src/qtism/runtime/tests/AbstractOrdering.php b/src/qtism/runtime/tests/AbstractOrdering.php index 503545e58..856baf688 100644 --- a/src/qtism/runtime/tests/AbstractOrdering.php +++ b/src/qtism/runtime/tests/AbstractOrdering.php @@ -97,7 +97,7 @@ public function __construct(AssessmentSection $assessmentSection, SelectableRout * * @return AssessmentSection An AssessmentSection object. */ - public function getAssessmentSection() + public function getAssessmentSection(): AssessmentSection { return $this->assessmentSection; } @@ -107,7 +107,7 @@ public function getAssessmentSection() * * @param AssessmentSection $assessmentSection An AssessmentSection object. */ - public function setAssessmentSection(AssessmentSection $assessmentSection) + public function setAssessmentSection(AssessmentSection $assessmentSection): void { $this->assessmentSection = $assessmentSection; } @@ -117,7 +117,7 @@ public function setAssessmentSection(AssessmentSection $assessmentSection) * * @return SelectableRouteCollection A collection of Route objects. */ - public function getSelectableRoutes() + public function getSelectableRoutes(): SelectableRouteCollection { return $this->selectableRoutes; } @@ -127,7 +127,7 @@ public function getSelectableRoutes() * * @param SelectableRouteCollection $selectableRoutes A collection of Route objects. */ - public function setSelectableRoutes(SelectableRouteCollection $selectableRoutes) + public function setSelectableRoutes(SelectableRouteCollection $selectableRoutes): void { $this->selectableRoutes = $selectableRoutes; } @@ -138,5 +138,5 @@ public function setSelectableRoutes(SelectableRouteCollection $selectableRoutes) * @return SelectableRouteCollection A collection of SelectableRoute object that were ordered accordingly. * @throws OrderingException If an error occurs while ordering the child elements of the target AssessmentSection. */ - abstract public function order(); + abstract public function order(): SelectableRouteCollection; } diff --git a/src/qtism/runtime/tests/AbstractSelection.php b/src/qtism/runtime/tests/AbstractSelection.php index 7866da2c8..85914ccf1 100644 --- a/src/qtism/runtime/tests/AbstractSelection.php +++ b/src/qtism/runtime/tests/AbstractSelection.php @@ -72,7 +72,7 @@ public function __construct(AssessmentSection $assessmentSection, SelectableRout * * @return AssessmentSection An AssessmentSection object. */ - public function getAssessmentSection() + public function getAssessmentSection(): AssessmentSection { return $this->assessmentSection; } @@ -82,7 +82,7 @@ public function getAssessmentSection() * * @param AssessmentSection $assessmentSection An AssessmentSection object. */ - public function setAssessmentSection(AssessmentSection $assessmentSection) + public function setAssessmentSection(AssessmentSection $assessmentSection): void { $this->assessmentSection = $assessmentSection; } @@ -92,7 +92,7 @@ public function setAssessmentSection(AssessmentSection $assessmentSection) * * @return SelectableRouteCollection A collection of Route objects. */ - public function getSelectableRoutes() + public function getSelectableRoutes(): SelectableRouteCollection { return $this->selectableRoutes; } @@ -102,7 +102,7 @@ public function getSelectableRoutes() * * @param SelectableRouteCollection $selectableRoutes */ - public function setSelectableRoutes(SelectableRouteCollection $selectableRoutes) + public function setSelectableRoutes(SelectableRouteCollection $selectableRoutes): void { $this->selectableRoutes = $selectableRoutes; } @@ -113,5 +113,5 @@ public function setSelectableRoutes(SelectableRouteCollection $selectableRoutes) * @return SelectableRouteCollection A collection of selected SelectableRoute object describing the selection. * @throws SelectionException */ - abstract public function select(); + abstract public function select(): SelectableRouteCollection; } diff --git a/src/qtism/runtime/tests/AbstractSessionManager.php b/src/qtism/runtime/tests/AbstractSessionManager.php index 0fde0b1a9..9fa7d5aa3 100644 --- a/src/qtism/runtime/tests/AbstractSessionManager.php +++ b/src/qtism/runtime/tests/AbstractSessionManager.php @@ -61,7 +61,7 @@ public function __construct(FileManager $fileManager) * * @param FileManager $fileManager */ - public function setFileManager(FileManager $fileManager) + public function setFileManager(FileManager $fileManager): void { $this->fileManager = $fileManager; } @@ -71,7 +71,7 @@ public function setFileManager(FileManager $fileManager) * * @return FileManager */ - public function getFileManager() + public function getFileManager(): FileManager { return $this->fileManager; } @@ -85,7 +85,7 @@ public function getFileManager() * * @return AssessmentTestSession An AssessmentTestSession object. */ - public function createAssessmentTestSession(AssessmentTest $test, Route $route = null, $config = 0) + public function createAssessmentTestSession(AssessmentTest $test, Route $route = null, $config = 0): AssessmentTestSession { return $this->instantiateAssessmentTestSession($test, $this->getRoute($test, $route), $config); } @@ -99,7 +99,7 @@ public function createAssessmentTestSession(AssessmentTest $test, Route $route = * * @return AssessmentItemSession */ - public function createAssessmentItemSession(IAssessmentItem $assessmentItem, $navigationMode = NavigationMode::LINEAR, $submissionMode = SubmissionMode::INDIVIDUAL) + public function createAssessmentItemSession(IAssessmentItem $assessmentItem, $navigationMode = NavigationMode::LINEAR, $submissionMode = SubmissionMode::INDIVIDUAL): AssessmentItemSession { return $this->instantiateAssessmentItemSession($assessmentItem, $navigationMode, $submissionMode); } @@ -112,7 +112,7 @@ public function createAssessmentItemSession(IAssessmentItem $assessmentItem, $na * @param int $config (optional) The configuration of the AssessmentTestSession object. * @return AssessmentTestSession A freshly instantiated AssessmentTestSession. */ - abstract protected function instantiateAssessmentTestSession(AssessmentTest $test, Route $route, $config = 0); + abstract protected function instantiateAssessmentTestSession(AssessmentTest $test, Route $route, $config = 0): AssessmentTestSession; /** * Contains the logic of instantiating the appropriate AssessmentItemSession implementation. @@ -122,7 +122,7 @@ abstract protected function instantiateAssessmentTestSession(AssessmentTest $tes * @param int $submissionMode A value from the SubmissionMode enumeration. * @return AssessmentItemSession A freshly instantiated AssessmentItemSession. */ - abstract protected function instantiateAssessmentItemSession(IAssessmentItem $assessmentItem, $navigationMode, $submissionMode); + abstract protected function instantiateAssessmentItemSession(IAssessmentItem $assessmentItem, $navigationMode, $submissionMode): AssessmentItemSession; /** * Contains the Route create logic depending on whether or not @@ -132,7 +132,7 @@ abstract protected function instantiateAssessmentItemSession(IAssessmentItem $as * @param Route $route * @return Route */ - protected function getRoute(AssessmentTest $test, Route $route = null) + protected function getRoute(AssessmentTest $test, Route $route = null): Route { return $route ?? $this->createRoute($test); } @@ -144,7 +144,7 @@ protected function getRoute(AssessmentTest $test, Route $route = null) * @param AssessmentTest $test * @return Route A newly instantiated Route object. */ - protected function createRoute(AssessmentTest $test) + protected function createRoute(AssessmentTest $test): Route { $routeStack = []; diff --git a/src/qtism/runtime/tests/AssessmentItemSession.php b/src/qtism/runtime/tests/AssessmentItemSession.php index 9aebb43a4..cd04cfb88 100644 --- a/src/qtism/runtime/tests/AssessmentItemSession.php +++ b/src/qtism/runtime/tests/AssessmentItemSession.php @@ -40,8 +40,6 @@ use qtism\data\NavigationMode; use qtism\data\processing\ResponseProcessing; use qtism\data\ShowHide; -use qtism\data\state\OutcomeDeclaration; -use qtism\data\state\OutcomeDeclarationCollection; use qtism\data\state\ShufflingCollection; use qtism\data\storage\php\PhpStorageException; use qtism\data\SubmissionMode; @@ -141,28 +139,28 @@ class AssessmentItemSession extends State * * @var string */ - const COMPLETION_STATUS_INCOMPLETE = 'incomplete'; + public const COMPLETION_STATUS_INCOMPLETE = 'incomplete'; /** * The item completion status 'not_attempted'. * * @var string */ - const COMPLETION_STATUS_NOT_ATTEMPTED = 'not_attempted'; + public const COMPLETION_STATUS_NOT_ATTEMPTED = 'not_attempted'; /** * The item completion status 'unknown'. * * @var string */ - const COMPLETION_STATUS_UNKNOWN = 'unknown'; + public const COMPLETION_STATUS_UNKNOWN = 'unknown'; /** * The item completion status 'completed'. * * @var string */ - const COMPLETION_STATUS_COMPLETED = 'completed'; + public const COMPLETION_STATUS_COMPLETED = 'completed'; /** * A timing reference used to compute the duration of the session. @@ -305,7 +303,7 @@ public function __construct(IAssessmentItem $assessmentItem, $navigationMode = N * @param int $state A value from the AssessmentItemSessionState enumeration. * @see \qtism\runtime\tests\AssessmentItemSessionState The AssessmentItemSessionState enumeration. */ - public function setState($state) + public function setState($state): void { $this->state = $state; } @@ -318,7 +316,7 @@ public function setState($state) * @return int A value from the AssessmentItemSessionState enumeration. * @see \qtism\runtime\tests\AssessmentItemSessionState The AssessmentItemSessionState enumeration. */ - public function getState() + public function getState(): int { return $this->state; } @@ -331,7 +329,7 @@ public function getState() * * @param ItemSessionControl $itemSessionControl An ItemSessionControl object. */ - public function setItemSessionControl(ItemSessionControl $itemSessionControl) + public function setItemSessionControl(ItemSessionControl $itemSessionControl): void { $this->itemSessionControl = $itemSessionControl; } @@ -341,7 +339,7 @@ public function setItemSessionControl(ItemSessionControl $itemSessionControl) * * @return ItemSessionControl An ItemSessionControl object. */ - public function getItemSessionControl() + public function getItemSessionControl(): ItemSessionControl { return $this->itemSessionControl; } @@ -351,7 +349,7 @@ public function getItemSessionControl() * * @param TimeLimits $timeLimits A TimeLimits object or null if no time limits must be applied. */ - public function setTimeLimits(TimeLimits $timeLimits = null) + public function setTimeLimits(TimeLimits $timeLimits = null): void { $this->timeLimits = $timeLimits; } @@ -361,7 +359,7 @@ public function setTimeLimits(TimeLimits $timeLimits = null) * * @return TimeLimits A TimLimits object or null if no time limits must be applied. */ - public function getTimeLimits() + public function getTimeLimits(): ?TimeLimits { return $this->timeLimits; } @@ -373,7 +371,7 @@ public function getTimeLimits() * * @param DateTime $timeReference A DateTime object. */ - public function setTimeReference(DateTime $timeReference) + public function setTimeReference(DateTime $timeReference): void { $this->timeReference = $timeReference; } @@ -385,7 +383,7 @@ public function setTimeReference(DateTime $timeReference) * * @return DateTime A DateTime object. */ - public function getTimeReference() + public function getTimeReference(): ?DateTime { return $this->timeReference; } @@ -395,7 +393,7 @@ public function getTimeReference() * * @return bool */ - public function hasTimeReference() + public function hasTimeReference(): bool { return $this->timeReference !== null; } @@ -405,7 +403,7 @@ public function hasTimeReference() * * @return bool */ - public function hasTimeLimits() + public function hasTimeLimits(): bool { return $this->getTimeLimits() !== null; } @@ -416,7 +414,7 @@ public function hasTimeLimits() * @param int $navigationMode A value from the NavigationMode enumeration. * @see \qtism\data\NavigationMode The NavigationMode enumeration. */ - public function setNavigationMode($navigationMode) + public function setNavigationMode($navigationMode): void { $this->navigationMode = $navigationMode; } @@ -427,7 +425,7 @@ public function setNavigationMode($navigationMode) * @return int A value from the NavigationMode enumeration. * @see \qtism\data\NavigationMode The NavigationMode enumeration. */ - public function getNavigationMode() + public function getNavigationMode(): int { return $this->navigationMode; } @@ -438,7 +436,7 @@ public function getNavigationMode() * @param int $submissionMode A value from the SubmissionMode enumeration. * @see \qtism\data\SubmissionMode The SubmissionMode enumeration. */ - public function setSubmissionMode($submissionMode) + public function setSubmissionMode($submissionMode): void { $this->submissionMode = $submissionMode; } @@ -449,7 +447,7 @@ public function setSubmissionMode($submissionMode) * @return int A value from the SubmissionMode enumeration. * @see \qtism\data\SubmissionMode The SubmissionMode enumeration. */ - public function getSubmissionMode() + public function getSubmissionMode(): int { return $this->submissionMode; } @@ -462,7 +460,7 @@ public function getSubmissionMode() * @return bool * @see \qtism\data\NavigationMode The NavigationMode enumeration. */ - public function isNavigationLinear() + public function isNavigationLinear(): bool { return $this->getNavigationMode() === NavigationMode::LINEAR; } @@ -475,7 +473,7 @@ public function isNavigationLinear() * @return bool * @see \qtism\data\NavigationMode The NavigationMode enumeration. */ - public function isNavigationNonLinear() + public function isNavigationNonLinear(): bool { return $this->getNavigationMode() === NavigationMode::NONLINEAR; } @@ -485,7 +483,7 @@ public function isNavigationNonLinear() * * @param IAssessmentItem $assessmentItem An IAssessmentItem object. */ - public function setAssessmentItem(IAssessmentItem $assessmentItem) + public function setAssessmentItem(IAssessmentItem $assessmentItem): void { $this->assessmentItem = $assessmentItem; } @@ -495,7 +493,7 @@ public function setAssessmentItem(IAssessmentItem $assessmentItem) * * @return IAssessmentItem An IAssessmentItem object. */ - public function getAssessmentItem() + public function getAssessmentItem(): IAssessmentItem { return $this->assessmentItem; } @@ -506,7 +504,7 @@ public function getAssessmentItem() * @param bool $attempting * @throws InvalidArgumentException If $attempting is not a boolean value. */ - public function setAttempting($attempting) + public function setAttempting($attempting): void { $this->attempting = $attempting; } @@ -520,7 +518,7 @@ public function setAttempting($attempting) * * @return bool */ - public function isAttempting() + public function isAttempting(): bool { return $this->attempting; } @@ -530,7 +528,7 @@ public function isAttempting() * * @param ShufflingCollection $shufflingStates */ - public function setShufflingStates(ShufflingCollection $shufflingStates) + public function setShufflingStates(ShufflingCollection $shufflingStates): void { $this->shufflingStates = $shufflingStates; } @@ -540,7 +538,7 @@ public function setShufflingStates(ShufflingCollection $shufflingStates) * * @return ShufflingCollection $shufflingStates */ - public function getShufflingStates() + public function getShufflingStates(): ShufflingCollection { return $this->shufflingStates; } @@ -550,7 +548,7 @@ public function getShufflingStates() * * @param bool $autoTemplateProcessing */ - public function setAutoTemplateProcessing($autoTemplateProcessing) + public function setAutoTemplateProcessing($autoTemplateProcessing): void { $this->autoTemplateProcessing = $autoTemplateProcessing; } @@ -560,7 +558,7 @@ public function setAutoTemplateProcessing($autoTemplateProcessing) * * @return bool */ - public function mustAutoTemplateProcessing() + public function mustAutoTemplateProcessing(): bool { return $this->autoTemplateProcessing; } @@ -580,7 +578,7 @@ public function mustAutoTemplateProcessing() * @param DateTime $time The current time that will be taken into account for all next interactions with the object. * @see \qtism\runtime\tests\AssessmentItemSession::endItemSession() The endItemSession() method. */ - public function setTime(DateTime $time) + public function setTime(DateTime $time): void { // Force time to be UTC. $time = Time::toUtc($time); @@ -621,7 +619,7 @@ public function setTime(DateTime $time) * * @see http://www.imsglobal.org/question/qtiv2p1/imsqti_infov2p1.html#section10055 The IMS QTI 2.1 Item Session Lifecycle. */ - public function beginItemSession() + public function beginItemSession(): void { // We initialize the item session and its variables. $data = &$this->getDataPlaceHolder(); @@ -668,7 +666,7 @@ public function beginItemSession() * @throws AssessmentItemSessionException If the maximum number of attempts or the maximum time limit in force is reached. * @see http://www.imsglobal.org/question/qtiv2p1/imsqti_infov2p1.html#section10055 The IMS QTI 2.1 Item Session Lifecycle. */ - public function beginAttempt() + public function beginAttempt(): void { $maxAttempts = $this->itemSessionControl->getMaxAttempts(); $numAttempts = $this['numAttempts']->getValue(); @@ -769,7 +767,7 @@ public function beginAttempt() * @throws AssessmentItemSessionException If the time limits in force are not respected, an error occurs during response processing, a state violation occurs. * @throws PhpStorageException */ - public function endAttempt(State $responses = null, $responseProcessing = true, $forceLateSubmission = false) + public function endAttempt(State $responses = null, $responseProcessing = true, $forceLateSubmission = false): void { // Flag to indicate if time is exceed or not. $maxTimeExceeded = false; @@ -873,7 +871,7 @@ public function endAttempt(State $responses = null, $responseProcessing = true, * * @param State $responses */ - protected function mergeResponses(State $responses) + protected function mergeResponses(State $responses): void { foreach ($responses as $identifier => $value) { $this[$identifier] = $value->getValue(); @@ -893,7 +891,7 @@ protected function mergeResponses(State $responses) * @param State $responses (optional) A State object containing the responses to be stored in the item session at suspend time. * @throws AssessmentItemSessionException With code STATE_VIOLATION if the state of the session is not INTERACTING nor MODAL_FEEDBACK prior to suspension. */ - public function suspend(State $responses = null) + public function suspend(State $responses = null): void { $state = $this->getState(); @@ -934,7 +932,7 @@ public function suspend(State $responses = null) * * @throws AssessmentItemSessionException With code STATE_VIOLATION if the state of the session is not SUSPENDED. */ - public function beginCandidateSession() + public function beginCandidateSession(): void { $state = $this->getState(); @@ -957,7 +955,7 @@ public function beginCandidateSession() * @throws AssessmentItemSessionException If a state violation occurs. * @throws PhpStorageException */ - public function endCandidateSession() + public function endCandidateSession(): void { $state = $this->getState(); @@ -994,7 +992,7 @@ public function getRemainingTime() * * The 'completionStatus' built-in outcome variable and the state of the item session goes to CLOSED. */ - public function endItemSession() + public function endItemSession(): void { // If the candidate was interacting, suspend before // to get a correct state flow. @@ -1014,7 +1012,7 @@ public function endItemSession() * * @return int The number of remaining items. -1 means unlimited. */ - public function getRemainingAttempts() + public function getRemainingAttempts(): int { $itemRef = $this->getAssessmentItem(); @@ -1049,7 +1047,7 @@ public function getRemainingAttempts() * * @return bool */ - public function isCorrect() + public function isCorrect(): bool { if ($this->getState() === AssessmentItemSessionState::NOT_SELECTED) { // The session cannot be considered as correct if not yet selected @@ -1082,7 +1080,7 @@ public function isCorrect() * * @return bool */ - public function isPresented() + public function isPresented(): bool { return $this['numAttempts']->getValue() > 0; } @@ -1092,7 +1090,7 @@ public function isPresented() * * @return bool */ - public function isSelected() + public function isSelected(): bool { return true; } @@ -1105,7 +1103,7 @@ public function isSelected() * @param bool $partially (optional) Whether to consider partially responded sessions as responded. * @return bool */ - public function isResponded($partially = true) + public function isResponded($partially = true): bool { if ($this->isPresented() === false) { return false; @@ -1133,7 +1131,7 @@ public function isResponded($partially = true) * * @return bool */ - public function isAttemptable() + public function isAttemptable(): bool { return $this->getRemainingAttempts() !== 0; } @@ -1143,7 +1141,7 @@ public function isAttemptable() * * @return bool */ - public function isAttempted() + public function isAttempted(): bool { return $this['numAttempts']->getValue() > 0; } @@ -1154,7 +1152,7 @@ public function isAttempted() * * @return bool */ - protected function isMaxTimeReached() + protected function isMaxTimeReached(): bool { $reached = false; @@ -1171,7 +1169,7 @@ protected function isMaxTimeReached() * @param bool $builtIn Whether to include the built-in ResponseVariables ('duration' and 'numAttempts'). * @return State A State object composed exclusively with ResponseVariable objects. */ - public function getResponseVariables($builtIn = true) + public function getResponseVariables($builtIn = true): State { $state = new State(); $data = $this->getDataPlaceHolder(); @@ -1191,7 +1189,7 @@ public function getResponseVariables($builtIn = true) * @param bool $builtIn Whether to include the built-in OutcomeVariable 'completionStatus'. * @return State A State object composed exclusively with OutcomeVariable objects. */ - public function getOutcomeVariables($builtIn = true) + public function getOutcomeVariables($builtIn = true): State { $state = new State(); $data = $this->getDataPlaceHolder(); @@ -1220,7 +1218,7 @@ public function getOutcomeVariables($builtIn = true) * @return string * @throws OutOfBoundsException If no identifier is found at [$shufflingStateIndex,$choiceIndex]. */ - public function getShuffledChoiceIdentifierAt($shufflingStateIndex, $choiceIndex) + public function getShuffledChoiceIdentifierAt($shufflingStateIndex, $choiceIndex): string { $shufflings = $this->getShufflingStates(); if (isset($shufflings[$shufflingStateIndex]) === false) { @@ -1237,7 +1235,7 @@ public function getShuffledChoiceIdentifierAt($shufflingStateIndex, $choiceIndex * @param ResponseProcessing $responseProcessing * @return ResponseProcessingEngine */ - protected function createResponseProcessingEngine(ResponseProcessing $responseProcessing) + protected function createResponseProcessingEngine(ResponseProcessing $responseProcessing): ResponseProcessingEngine { return new ResponseProcessingEngine($responseProcessing, $this); } @@ -1253,7 +1251,7 @@ protected function createResponseProcessingEngine(ResponseProcessing $responsePr * * @return bool */ - private function mustModalFeedback() + private function mustModalFeedback(): bool { // From IMS QTI 2.1: // A value of maxAttempts greater than 1, by definition, indicates that any applicable feedback must be shown. @@ -1309,7 +1307,7 @@ private function mustModalFeedback() * @return bool Whether or not the template processing occurred. * @throws RuleProcessingException */ - public function templateProcessing() + public function templateProcessing(): bool { $assessmentItem = $this->getAssessmentItem(); if (($templateProcessing = $assessmentItem->getTemplateProcessing()) !== null) { @@ -1338,7 +1336,7 @@ public function templateProcessing() * @param State $responses * @throws AssessmentItemSessionException If itemSessionControl->allowSkipping is false and the item is being skipped. */ - private function checkAllowSkipping(State $responses) + private function checkAllowSkipping(State $responses): void { // In case there are no response variable at all, the item is "skippable" as there is no possibility to provide an answer. if ($this->getSubmissionMode() === SubmissionMode::INDIVIDUAL && $this->getItemSessionControl()->doesAllowSkipping() === false && count($this->getResponseVariables(false)) > 0) { @@ -1374,7 +1372,7 @@ private function checkAllowSkipping(State $responses) * @param State $responses * @throws AssessmentItemSessionException In case of a Response Validity Constraint is not respected. */ - public function checkResponseValidityConstraints(State $responses) + public function checkResponseValidityConstraints(State $responses): void { if ($this->getSubmissionMode() === SubmissionMode::INDIVIDUAL && $this->getItemSessionControl()->mustValidateResponses() === true) { $session = clone $this; diff --git a/src/qtism/runtime/tests/AssessmentItemSessionCollection.php b/src/qtism/runtime/tests/AssessmentItemSessionCollection.php index a049c8f5e..e4e4c5af2 100644 --- a/src/qtism/runtime/tests/AssessmentItemSessionCollection.php +++ b/src/qtism/runtime/tests/AssessmentItemSessionCollection.php @@ -35,7 +35,7 @@ class AssessmentItemSessionCollection extends AbstractCollection /** * @param mixed $value */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof AssessmentItemSession) { $msg = 'The AssessmentItemSessionCollection class only accepts to store AssessmentItemSession objects.'; diff --git a/src/qtism/runtime/tests/AssessmentItemSessionException.php b/src/qtism/runtime/tests/AssessmentItemSessionException.php index a8255aa2a..28c9365c8 100644 --- a/src/qtism/runtime/tests/AssessmentItemSessionException.php +++ b/src/qtism/runtime/tests/AssessmentItemSessionException.php @@ -39,7 +39,7 @@ class AssessmentItemSessionException extends Exception * * @var int */ - const UNKNOWN = 0; + public const UNKNOWN = 0; /** * Error code to use when timelimits are in force and the @@ -47,7 +47,7 @@ class AssessmentItemSessionException extends Exception * * @var int */ - const DURATION_OVERFLOW = 1; + public const DURATION_OVERFLOW = 1; /** * Error code to use when timelimits are in force and @@ -55,7 +55,7 @@ class AssessmentItemSessionException extends Exception * * @var int */ - const DURATION_UNDERFLOW = 2; + public const DURATION_UNDERFLOW = 2; /** * Error code to use when the maximum amount attempts for a non-adaptive @@ -63,7 +63,7 @@ class AssessmentItemSessionException extends Exception * * @var int */ - const ATTEMPTS_OVERFLOW = 3; + public const ATTEMPTS_OVERFLOW = 3; /** * Error code to use when a runtime error that could not be corrected @@ -71,7 +71,7 @@ class AssessmentItemSessionException extends Exception * * @var int */ - const RUNTIME_ERROR = 4; + public const RUNTIME_ERROR = 4; /** * Error code to return when itemSessionControl.validateResponses is in force @@ -79,7 +79,7 @@ class AssessmentItemSessionException extends Exception * * @var int */ - const INVALID_RESPONSE = 5; + public const INVALID_RESPONSE = 5; /** * Error code to use when itemSessionControl.allowSkipping is not in force @@ -87,14 +87,14 @@ class AssessmentItemSessionException extends Exception * * @var int */ - const SKIPPING_FORBIDDEN = 6; + public const SKIPPING_FORBIDDEN = 6; /** * Error code to use when a sequence of states is violated. * * @var int */ - const STATE_VIOLATION = 7; + public const STATE_VIOLATION = 7; /** * The AssessmentItemSession object which threw the error. @@ -122,7 +122,7 @@ public function __construct($message, AssessmentItemSession $source, $code = Ass * * @param AssessmentItemSession $source An AssessmentItemSession object. */ - public function setSource(AssessmentItemSession $source) + public function setSource(AssessmentItemSession $source): void { $this->source = $source; } @@ -132,7 +132,7 @@ public function setSource(AssessmentItemSession $source) * * @return AssessmentItemSession An AssessmentItemSession object. */ - public function getSource() + public function getSource(): AssessmentItemSession { return $this->source; } diff --git a/src/qtism/runtime/tests/AssessmentItemSessionState.php b/src/qtism/runtime/tests/AssessmentItemSessionState.php index 4431a5555..e2a5ae4c4 100644 --- a/src/qtism/runtime/tests/AssessmentItemSessionState.php +++ b/src/qtism/runtime/tests/AssessmentItemSessionState.php @@ -29,16 +29,16 @@ */ class AssessmentItemSessionState extends AssessmentTestSessionState { - const NOT_SELECTED = 255; + public const NOT_SELECTED = 255; - const SOLUTION = 5; + public const SOLUTION = 5; - const REVIEW = 6; + public const REVIEW = 6; /** * @return array */ - public static function asArray() + public static function asArray(): array { return array_merge( AssessmentTestSessionState::asArray(), @@ -56,7 +56,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'notselected': return self::NOT_SELECTED; break; diff --git a/src/qtism/runtime/tests/AssessmentItemSessionStore.php b/src/qtism/runtime/tests/AssessmentItemSessionStore.php index f4ad77d27..802a7bc35 100644 --- a/src/qtism/runtime/tests/AssessmentItemSessionStore.php +++ b/src/qtism/runtime/tests/AssessmentItemSessionStore.php @@ -57,7 +57,7 @@ public function __construct() * * @param SplObjectStorage $shelves An SplObjectStorage object that will store AssessmentItemSessionCollection objects. */ - protected function setShelves(SplObjectStorage $shelves) + protected function setShelves(SplObjectStorage $shelves): void { $this->shelves = $shelves; } @@ -68,7 +68,7 @@ protected function setShelves(SplObjectStorage $shelves) * * @return SplObjectStorage An SplObjectStorage object that will store AssessmentItemSessionCollection objects. */ - protected function getShelves() + protected function getShelves(): SplObjectStorage { return $this->shelves; } @@ -79,7 +79,7 @@ protected function getShelves() * @param AssessmentItemSession $assessmentItemSession * @param int $occurence The occurence number of the session. */ - public function addAssessmentItemSession(AssessmentItemSession $assessmentItemSession, $occurence = 0) + public function addAssessmentItemSession(AssessmentItemSession $assessmentItemSession, $occurence = 0): void { $assessmentItemRef = $assessmentItemSession->getAssessmentItem(); @@ -98,8 +98,10 @@ public function addAssessmentItemSession(AssessmentItemSession $assessmentItemSe * @return AssessmentItemSession An AssessmentItemSession object. * @throws OutOfBoundsException If there is no AssessmentItemSession for the given $assessmentItemRef and $occurence. */ - public function getAssessmentItemSession(AssessmentItemRef $assessmentItemRef, $occurence = 0) - { + public function getAssessmentItemSession( + AssessmentItemRef $assessmentItemRef, + $occurence = 0 + ): AssessmentItemSession { if (isset($this->shelves[$assessmentItemRef]) && isset($this->shelves[$assessmentItemRef][$occurence]) === true) { return $this->shelves[$assessmentItemRef][$occurence]; } else { @@ -116,7 +118,7 @@ public function getAssessmentItemSession(AssessmentItemRef $assessmentItemRef, $ * @param int $occurence An occurence number. * @return bool */ - public function hasAssessmentItemSession(AssessmentItemRef $assessmentItemRef, $occurence = 0) + public function hasAssessmentItemSession(AssessmentItemRef $assessmentItemRef, $occurence = 0): bool { try { // Circumvent SplObjectStorage bug (prior PHP 7.0.8) @@ -133,7 +135,7 @@ public function hasAssessmentItemSession(AssessmentItemRef $assessmentItemRef, $ * @return AssessmentItemSessionCollection A collection of AssessmentItemSession objects related to $assessmentItemRef. * @throws OutOfBoundsException If no item sessions related to $assessmentItemRef are found. */ - public function getAssessmentItemSessions(AssessmentItemRef $assessmentItemRef) + public function getAssessmentItemSessions(AssessmentItemRef $assessmentItemRef): AssessmentItemSessionCollection { if (isset($this->shelves[$assessmentItemRef]) === true) { return $this->shelves[$assessmentItemRef]; @@ -153,7 +155,7 @@ public function getAssessmentItemSessions(AssessmentItemRef $assessmentItemRef) * @param AssessmentItemRef $assessmentItemRef An AssessmentItemRef object. * @return bool */ - public function hasMultipleOccurences(AssessmentItemRef $assessmentItemRef) + public function hasMultipleOccurences(AssessmentItemRef $assessmentItemRef): bool { return isset($this->shelves[$assessmentItemRef]) && count($this->shelves[$assessmentItemRef]) > 1; } @@ -163,7 +165,7 @@ public function hasMultipleOccurences(AssessmentItemRef $assessmentItemRef) * * @return AssessmentItemSessionCollection A collection of AssessmentItemSession objects. */ - public function getAllAssessmentItemSessions() + public function getAllAssessmentItemSessions(): AssessmentItemSessionCollection { $collection = new AssessmentItemSessionCollection(); diff --git a/src/qtism/runtime/tests/AssessmentTestPlace.php b/src/qtism/runtime/tests/AssessmentTestPlace.php index 4cfdcc1e9..cebddd685 100644 --- a/src/qtism/runtime/tests/AssessmentTestPlace.php +++ b/src/qtism/runtime/tests/AssessmentTestPlace.php @@ -36,33 +36,33 @@ class AssessmentTestPlace implements Enumeration * * @var int */ - const TEST_PART = 1; + public const TEST_PART = 1; /** * Represents the concept of AssessmentSection in an AssessmentTest. * * @var int */ - const ASSESSMENT_SECTION = 2; + public const ASSESSMENT_SECTION = 2; /** * Represents the concept of AssessmentItem in an AssessmentTest. * * @var int */ - const ASSESSMENT_ITEM = 4; + public const ASSESSMENT_ITEM = 4; /** * Represents the concept of AssessmentTest (in an AssessmentTest). * * @var int */ - const ASSESSMENT_TEST = 8; + public const ASSESSMENT_TEST = 8; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'TEST_PART' => self::TEST_PART, @@ -78,7 +78,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'testpart': return self::TEST_PART; break; diff --git a/src/qtism/runtime/tests/AssessmentTestSession.php b/src/qtism/runtime/tests/AssessmentTestSession.php index 897bddbe3..7ec149553 100644 --- a/src/qtism/runtime/tests/AssessmentTestSession.php +++ b/src/qtism/runtime/tests/AssessmentTestSession.php @@ -68,21 +68,21 @@ */ class AssessmentTestSession extends State { - const ROUTECOUNT_ALL = 0; + public const ROUTECOUNT_ALL = 0; - const ROUTECOUNT_EXCLUDENORESPONSE = 1; + public const ROUTECOUNT_EXCLUDENORESPONSE = 1; - const ROUTECOUNT_FLOW = 2; + public const ROUTECOUNT_FLOW = 2; - const FORCE_BRANCHING = 1; + public const FORCE_BRANCHING = 1; - const FORCE_PRECONDITIONS = 2; + public const FORCE_PRECONDITIONS = 2; - const PATH_TRACKING = 4; + public const PATH_TRACKING = 4; - const ALWAYS_ALLOW_JUMPS = 8; + public const ALWAYS_ALLOW_JUMPS = 8; - const INITIALIZE_ALL_ITEMS = 16; + public const INITIALIZE_ALL_ITEMS = 16; /** * A unique ID for this AssessmentTestSession. @@ -257,7 +257,7 @@ public function __construct(AssessmentTest $assessmentTest, AbstractSessionManag * @throws AssessmentItemSessionException * @throws PhpStorageException */ - public function setTime(DateTime $time) + public function setTime(DateTime $time): void { // Force $time to be UTC. $time = Time::toUtc($time); @@ -338,7 +338,7 @@ public function setTime(DateTime $time) * * @return DateTime */ - public function getTimeReference() + public function getTimeReference(): ?DateTime { return $this->timeReference; } @@ -348,7 +348,7 @@ public function getTimeReference() * * @param DateTime $timeReference */ - public function setTimeReference(DateTime $timeReference = null) + public function setTimeReference(DateTime $timeReference = null): void { $this->timeReference = $timeReference; } @@ -359,7 +359,7 @@ public function setTimeReference(DateTime $timeReference = null) * * @return bool */ - public function hasTimeReference() + public function hasTimeReference(): bool { return $this->timeReference !== null; } @@ -370,7 +370,7 @@ public function hasTimeReference() * @param string $sessionId A unique ID. * @throws InvalidArgumentException If $sessionId is not a string or is empty. */ - public function setSessionId($sessionId) + public function setSessionId($sessionId): void { if (is_string($sessionId)) { if (empty($sessionId) === false) { @@ -390,7 +390,7 @@ public function setSessionId($sessionId) * * @return string A unique ID. */ - public function getSessionId() + public function getSessionId(): string { return $this->sessionId; } @@ -400,7 +400,7 @@ public function getSessionId() * * @return AssessmentTest An AssessmentTest object. */ - public function getAssessmentTest() + public function getAssessmentTest(): AssessmentTest { return $this->assessmentTest; } @@ -410,7 +410,7 @@ public function getAssessmentTest() * * @param AssessmentTest $assessmentTest */ - protected function setAssessmentTest(AssessmentTest $assessmentTest) + protected function setAssessmentTest(AssessmentTest $assessmentTest): void { $this->assessmentTest = $assessmentTest; } @@ -420,7 +420,7 @@ protected function setAssessmentTest(AssessmentTest $assessmentTest) * * @return AssessmentItemRefCollection A Collection of AssessmentItemRef objects. */ - protected function getAssessmentItemRefs() + protected function getAssessmentItemRefs(): AssessmentItemRefCollection { return $this->getRoute()->getAssessmentItemRefs(); } @@ -430,7 +430,7 @@ protected function getAssessmentItemRefs() * * @return Route A Route object. */ - public function getRoute() + public function getRoute(): Route { return $this->route; } @@ -440,7 +440,7 @@ public function getRoute() * * @param Route $route A route object. */ - public function setRoute(Route $route) + public function setRoute(Route $route): void { $this->route = $route; } @@ -450,7 +450,7 @@ public function setRoute(Route $route) * * @return int A value from the AssessmentTestSessionState enumeration. */ - public function getState() + public function getState(): int { return $this->state; } @@ -460,7 +460,7 @@ public function getState() * * @param int $state A value from the AssessmentTestSessionState enumeration. */ - public function setState($state) + public function setState($state): void { if (in_array($state, AssessmentTestSessionState::asArray(), true)) { $this->state = $state; @@ -475,7 +475,7 @@ public function setState($state) * * @return AssessmentItemSessionStore */ - public function getAssessmentItemSessionStore() + public function getAssessmentItemSessionStore(): AssessmentItemSessionStore { return $this->assessmentItemSessionStore; } @@ -485,7 +485,7 @@ public function getAssessmentItemSessionStore() * * @param AssessmentItemSessionStore $assessmentItemSessionStore */ - public function setAssessmentItemSessionStore(AssessmentItemSessionStore $assessmentItemSessionStore) + public function setAssessmentItemSessionStore(AssessmentItemSessionStore $assessmentItemSessionStore): void { $this->assessmentItemSessionStore = $assessmentItemSessionStore; } @@ -496,7 +496,7 @@ public function setAssessmentItemSessionStore(AssessmentItemSessionStore $assess * * @return PendingResponsesCollection A collection of PendingResponses objects. */ - public function getPendingResponses() + public function getPendingResponses(): PendingResponsesCollection { return $this->getPendingResponseStore()->getAllPendingResponses(); } @@ -507,7 +507,7 @@ public function getPendingResponses() * * @return PendingResponseStore A PendingResponseStore object. */ - public function getPendingResponseStore() + public function getPendingResponseStore(): PendingResponseStore { return $this->pendingResponseStore; } @@ -518,7 +518,7 @@ public function getPendingResponseStore() * * @param PendingResponseStore $pendingResponseStore */ - public function setPendingResponseStore(PendingResponseStore $pendingResponseStore) + public function setPendingResponseStore(PendingResponseStore $pendingResponseStore): void { $this->pendingResponseStore = $pendingResponseStore; } @@ -529,7 +529,7 @@ public function setPendingResponseStore(PendingResponseStore $pendingResponseSto * @param PendingResponses $pendingResponses * @throws AssessmentTestSessionException If the current submission mode is not simultaneous. */ - protected function addPendingResponses(PendingResponses $pendingResponses) + protected function addPendingResponses(PendingResponses $pendingResponses): void { if ($this->getCurrentSubmissionMode() === SubmissionMode::SIMULTANEOUS) { $this->getPendingResponseStore()->addPendingResponses($pendingResponses); @@ -545,7 +545,7 @@ protected function addPendingResponses(PendingResponses $pendingResponses) * @param int $testResultsSubmission * @see TestResultsSubmission The TestResultsSubmission enumeration. */ - public function setTestResultsSubmission($testResultsSubmission) + public function setTestResultsSubmission($testResultsSubmission): void { $this->testResultsSubmission = $testResultsSubmission; } @@ -556,7 +556,7 @@ public function setTestResultsSubmission($testResultsSubmission) * @return int * @see TestResultsSubmission The TestResultsSubmission enumeration. */ - public function getTestResultsSubmission() + public function getTestResultsSubmission(): int { return $this->testResultsSubmission; } @@ -566,7 +566,7 @@ public function getTestResultsSubmission() * * @param DurationStore $durationStore */ - public function setDurationStore(DurationStore $durationStore) + public function setDurationStore(DurationStore $durationStore): void { $this->durationStore = $durationStore; } @@ -576,7 +576,7 @@ public function setDurationStore(DurationStore $durationStore) * * @return DurationStore */ - public function getDurationStore() + public function getDurationStore(): DurationStore { return $this->durationStore; } @@ -586,7 +586,7 @@ public function getDurationStore() * * @param AbstractSessionManager $sessionManager */ - public function setSessionManager(AbstractSessionManager $sessionManager) + public function setSessionManager(AbstractSessionManager $sessionManager): void { $this->sessionManager = $sessionManager; } @@ -596,7 +596,7 @@ public function setSessionManager(AbstractSessionManager $sessionManager) * * @return AbstractSessionManager */ - protected function getSessionManager() + protected function getSessionManager(): AbstractSessionManager { return $this->sessionManager; } @@ -606,7 +606,7 @@ protected function getSessionManager() * * @param array $adaptivity */ - protected function setAdaptivity(array $adaptivity) + protected function setAdaptivity(array $adaptivity): void { $this->adaptivity = $adaptivity; } @@ -617,7 +617,7 @@ protected function setAdaptivity(array $adaptivity) * @param string $testPartIdentifier * @return bool */ - private function isAdaptive($testPartIdentifier = '') + private function isAdaptive($testPartIdentifier = ''): bool { return (empty($testPartIdentifier)) ? in_array(true, $this->adaptivity, true) : $this->adaptivity[$testPartIdentifier]; } @@ -627,7 +627,7 @@ private function isAdaptive($testPartIdentifier = '') * * @param array $visitedTestPartIdentifiers An array of strings. */ - public function setVisitedTestPartIdentifiers(array $visitedTestPartIdentifiers) + public function setVisitedTestPartIdentifiers(array $visitedTestPartIdentifiers): void { $this->visitedTestPartIdentifiers = $visitedTestPartIdentifiers; } @@ -637,7 +637,7 @@ public function setVisitedTestPartIdentifiers(array $visitedTestPartIdentifiers) * * @return array An array of strings. */ - public function getVisitedTestPartIdentifiers() + public function getVisitedTestPartIdentifiers(): array { return $this->visitedTestPartIdentifiers; } @@ -649,7 +649,7 @@ public function getVisitedTestPartIdentifiers() * * @return bool */ - public function mustForceBranching() + public function mustForceBranching(): bool { return (bool)($this->getConfig() & self::FORCE_BRANCHING); } @@ -661,7 +661,7 @@ public function mustForceBranching() * * @return bool */ - public function mustForcePreconditions() + public function mustForcePreconditions(): bool { return (bool)($this->getConfig() & self::FORCE_PRECONDITIONS); } @@ -672,7 +672,7 @@ public function mustForcePreconditions() * * @return bool */ - public function mustTrackPath() + public function mustTrackPath(): bool { return (bool)($this->getConfig() & self::PATH_TRACKING); } @@ -684,7 +684,7 @@ public function mustTrackPath() * * @param bool $alwaysAllowJumps */ - public function setAlwaysAllowJumps($alwaysAllowJumps) + public function setAlwaysAllowJumps($alwaysAllowJumps): void { $this->alwaysAllowJumps = $alwaysAllowJumps; } @@ -696,7 +696,7 @@ public function setAlwaysAllowJumps($alwaysAllowJumps) * * @return bool */ - public function mustAlwaysAllowJumps() + public function mustAlwaysAllowJumps(): bool { return $this->alwaysAllowJumps || (bool)($this->getConfig() & self::ALWAYS_ALLOW_JUMPS); } @@ -708,7 +708,7 @@ public function mustAlwaysAllowJumps() * * @return bool */ - public function mustInitializeAllItems() + public function mustInitializeAllItems(): bool { return (bool)($this->getConfig() & self::INITIALIZE_ALL_ITEMS); } @@ -721,7 +721,7 @@ public function mustInitializeAllItems() * * @param array $path */ - public function setPath(array $path) + public function setPath(array $path): void { $this->path = $path; } @@ -734,7 +734,7 @@ public function setPath(array $path) * * @return array */ - public function getPath() + public function getPath(): array { return $this->path; } @@ -744,7 +744,7 @@ public function getPath() * * @param int $config */ - public function setConfig($config) + public function setConfig($config): void { $this->config = $config; } @@ -754,7 +754,7 @@ public function setConfig($config) * * @return int */ - public function getConfig() + public function getConfig(): int { return $this->config; } @@ -763,7 +763,7 @@ public function getConfig() * Begins the test session. Calling this method will make the state * change into AssessmentTestSessionState::INTERACTING. */ - public function beginTestSession() + public function beginTestSession(): void { // Initialize test-level durations. $this->initializeTestDurations(); @@ -785,7 +785,7 @@ public function beginTestSession() * @throws AssessmentItemSessionException * @throws PhpStorageException */ - public function endTestSession() + public function endTestSession(): void { if ($this->isRunning() === false) { $msg = 'Cannot end the test session while the state of the test session is INITIAL or CLOSED.'; @@ -821,7 +821,7 @@ public function endTestSession() * * @throws AssessmentTestSessionException */ - public function beginAttempt($allowLateSubmission = false) + public function beginAttempt($allowLateSubmission = false): void { if ($this->isRunning() === false) { $msg = 'Cannot begin an attempt for the current item while the state of the test session is INITIAL or CLOSED.'; @@ -870,7 +870,7 @@ public function beginAttempt($allowLateSubmission = false) * @param bool $allowLateSubmission If set to true, maximum time limits will not be taken into account. * @throws AssessmentTestSessionException */ - public function endAttempt(State $responses, $allowLateSubmission = false) + public function endAttempt(State $responses, $allowLateSubmission = false): void { if ($this->isRunning() === false) { $msg = 'Cannot end an attempt for the current item while the state of the test session is INITIAL or CLOSED.'; @@ -929,7 +929,7 @@ public function endAttempt(State $responses, $allowLateSubmission = false) * @throws AssessmentTestSessionException If the test session is not running or an issue occurs during the transition e.g. branching, preConditions, ... * @throws PhpStorageException */ - public function moveNext() + public function moveNext(): void { if ($this->isRunning() === false) { $msg = 'Cannot move to the next item while the test session state is INITIAL or CLOSED.'; @@ -973,7 +973,7 @@ public function moveNext() * @throws AssessmentTestSessionException If the test session is not running or an issue occurs during the transition e.g. branching, preConditions, ... * @throws PhpStorageException */ - public function moveBack() + public function moveBack(): void { if ($this->isRunning() === false) { $msg = 'Cannot move to the previous item while the test session state is INITIAL or CLOSED.'; @@ -1010,7 +1010,7 @@ public function moveBack() * @throws AssessmentTestSessionException If $position is out of the Route bounds or the jump is not allowed because of time constraints. * @throws PhpStorageException */ - public function jumpTo($position) + public function jumpTo($position): void { // Can we jump? $navigationMode = $this->getCurrentNavigationMode(); @@ -1065,8 +1065,9 @@ public function jumpTo($position) * * if the current item of the selection is Q23, the return value is 0. * * if the current item of the selection is Q01.3, the return value is 2. * - * @return int the occurence number of the current AssessmentItemRef in the route or false if the test session is not running. + * @return int|false the occurence number of the current AssessmentItemRef in the route or false if the test session is not running. */ + #[\ReturnTypeWillChange] public function getCurrentAssessmentItemRefOccurence() { if ($this->isRunning() === true) { @@ -1093,8 +1094,9 @@ public function getCurrentAssessmentSection() /** * Get the current TestPart. * - * @return TestPart A TestPart object or false if the test session is not running. + * @return TestPart|false A TestPart object or false if the test session is not running. */ + #[\ReturnTypeWillChange] public function getCurrentTestPart() { if ($this->isRunning() === true) { @@ -1109,6 +1111,7 @@ public function getCurrentTestPart() * * @return AssessmentItemRef|false An AssessmentItemRef object or false if the test session is not running. */ + #[\ReturnTypeWillChange] public function getCurrentAssessmentItemRef() { if ($this->isRunning() === true) { @@ -1169,7 +1172,7 @@ public function getCurrentRemainingAttempts() * @return bool * @throws AssessmentTestSessionException If the test session is not running. */ - public function isCurrentAssessmentItemAdaptive() + public function isCurrentAssessmentItemAdaptive(): bool { if ($this->isRunning() === false) { $msg = 'Cannot know if the current item is adaptive while the state of the test session is INITIAL or CLOSED.'; @@ -1185,7 +1188,7 @@ public function isCurrentAssessmentItemAdaptive() * * @return bool Whether the test session is running. */ - public function isRunning() + public function isRunning(): bool { return $this->getState() !== AssessmentTestSessionState::INITIAL && $this->getState() !== AssessmentTestSessionState::CLOSED; } @@ -1250,7 +1253,7 @@ public function isCurrentAssessmentItemInteracting() * @param IdentifierCollection $excludeCategories The optional item categories to be excluded from the subset. * @return AssessmentItemRefCollection A collection of AssessmentItemRef objects that match all the given criteria. */ - public function getItemSubset($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null) + public function getItemSubset($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null): AssessmentItemRefCollection { return $this->getRoute()->getAssessmentItemRefsSubset($sectionIdentifier, $includeCategories, $excludeCategories); } @@ -1268,7 +1271,7 @@ public function getItemSubset($sectionIdentifier = '', IdentifierCollection $inc * @param int $mode AssessmentTestSession::ROUTECOUNT_ALL | AssessmentTestSession::ROUTECOUNT_EXCLUDENORESPONSE | AssessmentTestSession::ROUTECOUNT_FLOW * @return int */ - public function getRouteCount($mode = self::ROUTECOUNT_ALL) + public function getRouteCount($mode = self::ROUTECOUNT_ALL): int { if ($mode === self::ROUTECOUNT_ALL) { return $this->getRoute()->count(); @@ -1300,7 +1303,7 @@ public function getRouteCount($mode = self::ROUTECOUNT_ALL) * * @param SplObjectStorage $lastOccurenceUpdate A map. */ - public function setLastOccurenceUpdate(SplObjectStorage $lastOccurenceUpdate) + public function setLastOccurenceUpdate(SplObjectStorage $lastOccurenceUpdate): void { $this->lastOccurenceUpdate = $lastOccurenceUpdate; } @@ -1312,7 +1315,7 @@ public function setLastOccurenceUpdate(SplObjectStorage $lastOccurenceUpdate) * @param int $occurence An occurence number * @return bool */ - public function isLastOccurenceUpdate(AssessmentItemRef $assessmentItemRef, $occurence) + public function isLastOccurenceUpdate(AssessmentItemRef $assessmentItemRef, $occurence): bool { if (($lastUpdate = $this->whichLastOccurenceUpdate($assessmentItemRef)) !== false) { if ($occurence === $lastUpdate) { @@ -1359,7 +1362,7 @@ public function whichLastOccurenceUpdate($assessmentItemRef) * @return bool * @throws AssessmentTestSessionException */ - public function canMoveBackward() + public function canMoveBackward(): bool { if ($this->getRoute()->getPosition() === 0) { return false; @@ -1386,7 +1389,7 @@ public function canMoveBackward() * @param string $identifier * @return JumpCollection A collection of Jump objects. */ - public function getPossibleJumps($place = AssessmentTestPlace::ASSESSMENT_TEST, $identifier = '') + public function getPossibleJumps($place = AssessmentTestPlace::ASSESSMENT_TEST, $identifier = ''): JumpCollection { $jumps = new JumpCollection(); @@ -1438,7 +1441,7 @@ public function getPossibleJumps($place = AssessmentTestPlace::ASSESSMENT_TEST, * @param int $places A composition of values (use | operator) from the AssessmentTestPlace enumeration. If the null value is given, all places will be taken into account. * @return TimeConstraintCollection A collection of TimeConstraint objects. */ - public function getTimeConstraints($places = null) + public function getTimeConstraints($places = null): TimeConstraintCollection { if ($places === null) { // Get the constraints from all places in the Assessment Test. @@ -1554,7 +1557,7 @@ public function getCurrentAssessmentItemSession() * @param string $identifier An optional assessmentSection identifier. * @return int */ - public function numberResponded($identifier = '') + public function numberResponded($identifier = ''): int { $numberResponded = 0; @@ -1579,7 +1582,7 @@ public function numberResponded($identifier = '') * @param string $identifier An optional assessmentSection identifier. * @return int */ - public function numberCorrect($identifier = '') + public function numberCorrect($identifier = ''): int { $numberCorrect = 0; @@ -1604,7 +1607,7 @@ public function numberCorrect($identifier = '') * @param string $identifier An optional assessmentSection identifier. * @return int */ - public function numberIncorrect($identifier = '') + public function numberIncorrect($identifier = ''): int { $numberIncorrect = 0; @@ -1629,7 +1632,7 @@ public function numberIncorrect($identifier = '') * @param string $identifier An optional assessmentSection identifier. * @return int */ - public function numberPresented($identifier = '') + public function numberPresented($identifier = ''): int { $numberPresented = 0; @@ -1654,7 +1657,7 @@ public function numberPresented($identifier = '') * @param string $identifier An optional assessmentSection identifier. * @return int */ - public function numberSelected($identifier = '') + public function numberSelected($identifier = ''): int { $numberSelected = 0; @@ -1683,7 +1686,7 @@ public function numberSelected($identifier = '') * * @return int The number of completed items. */ - public function numberCompleted() + public function numberCompleted(): int { $numberCompleted = 0; $route = $this->getRoute(); @@ -1779,7 +1782,7 @@ public function getWeight($identifier) * @param Variable $variable A Variable object to add to the current context. * @throws OutOfRangeException If the identifier of the given $variable is not a simple variable identifier (no prefix, no sequence number). */ - public function setVariable(Variable $variable) + public function setVariable(Variable $variable): void { try { $v = new VariableIdentifier($variable->getIdentifier()); @@ -1805,7 +1808,7 @@ public function setVariable(Variable $variable) * @param string $variableIdentifier * @return Variable A Variable object or null if no Variable object could be found for $variableIdentifier. */ - public function getVariable($variableIdentifier) + public function getVariable($variableIdentifier): ?Variable { $v = new VariableIdentifier($variableIdentifier); @@ -1844,6 +1847,7 @@ public function getVariable($variableIdentifier) * @return mixed A QTI Runtime compliant value or NULL if no such value can be retrieved for $offset. * @throws OutOfRangeException If $offset is not a string or $offset is not a valid variable identifier. */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { try { @@ -1925,7 +1929,7 @@ public function offsetGet($offset) * @throws OutOfRangeException If $offset is not a string or an invalid variable identifier. * @throws OutOfBoundsException If the variable with identifier $offset cannot be found. */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (gettype($offset) !== 'string') { $msg = 'An AssessmentTestSession object must be addressed by string.'; @@ -1985,7 +1989,7 @@ public function offsetSet($offset, $value) * @throws OutOfRangeException If $offset is not a simple variable identifier. * @throws OutOfBoundsException If $offset does not refer to an existing variable in the global scope. */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { $data = &$this->getDataPlaceHolder(); @@ -2018,7 +2022,7 @@ public function offsetUnset($offset) * @return bool Whether the variable identified by $offset exists in the current context. * @throws OutOfRangeException If $offset is not a simple variable identifier (no prefix, no sequence number). */ - public function offsetExists($offset) + public function offsetExists($offset): bool { try { $v = new VariableIdentifier($offset); @@ -2078,7 +2082,7 @@ public function getCandidateState() * @param int $submissionMode * @return AssessmentItemSession */ - protected function createAssessmentItemSession(IAssessmentItem $assessmentItem, $navigationMode, $submissionMode) + protected function createAssessmentItemSession(IAssessmentItem $assessmentItem, $navigationMode, $submissionMode): AssessmentItemSession { return $this->getSessionManager()->createAssessmentItemSession($assessmentItem, $navigationMode, $submissionMode, false); } @@ -2089,7 +2093,7 @@ protected function createAssessmentItemSession(IAssessmentItem $assessmentItem, * @param AssessmentItemSession $session * @throws ExpressionProcessingException|OperatorProcessingException If something wrong happens when initializing templateDefaults. */ - protected function applyTemplateDefaults(AssessmentItemSession $session) + protected function applyTemplateDefaults(AssessmentItemSession $session): void { $templateDefaults = $session->getAssessmentItem()->getTemplateDefaults(); @@ -2117,7 +2121,7 @@ protected function applyTemplateDefaults(AssessmentItemSession $session) /** * Initialize test-level durations. */ - protected function initializeTestDurations() + protected function initializeTestDurations(): void { $route = $this->getRoute(); $oldPosition = $route->getPosition(); @@ -2150,7 +2154,7 @@ protected function initializeTestDurations() * * The test is adaptive: an AssessmentItemSession will be instantiated for the current route item only. * * The test is not adaptive: all route items are scanned. If an AssessmentItemSession does not exist for a route item, it is instantiated. */ - protected function selectEligibleItems() + protected function selectEligibleItems(): void { $route = $this->getRoute(); @@ -2214,7 +2218,7 @@ protected function selectEligibleItems() * @param int $occurence * @throws LogicException If the AssessmentItemRef object bound to $session is unknown by the AssessmentTestSession. */ - protected function addItemSession(AssessmentItemSession $session, $occurence = 0) + protected function addItemSession(AssessmentItemSession $session, $occurence = 0): void { $assessmentItemRefs = $this->getAssessmentItemRefs(); $sessionAssessmentItemRefIdentifier = $session->getAssessmentItem()->getIdentifier(); @@ -2270,7 +2274,7 @@ protected function getCurrentRouteItem() * @throws OutOfBoundsException If the current position in the route is 0. * @throws AssessmentTestSessionException If the AssessmentTestSession is not running. */ - protected function getPreviousRouteItem() + protected function getPreviousRouteItem(): RouteItem { if ($this->isRunning() === false) { $msg = 'Cannot know what is the previous route item while the state of the test session is INITIAL or CLOSED'; @@ -2295,7 +2299,7 @@ protected function getPreviousRouteItem() * @param AssessmentItemSession $assessmentItemSession The lastly updated AssessmentItemSession. * @param int $occurence The occurence number of the item bound to $assessmentItemSession. */ - protected function submitItemResults(AssessmentItemSession $assessmentItemSession, $occurence = 0) + protected function submitItemResults(AssessmentItemSession $assessmentItemSession, $occurence = 0): void { return; } @@ -2307,7 +2311,7 @@ protected function submitItemResults(AssessmentItemSession $assessmentItemSessio * This method is triggered once at the end of the AssessmentTestSession. * */ - protected function submitTestResults() + protected function submitTestResults(): void { return; } @@ -2320,7 +2324,7 @@ protected function submitTestResults() * @throws AssessmentTestSessionException If an error occurs while processing the pending responses or sending results. * @throws PhpStorageException */ - protected function defferedResponseSubmission() + protected function defferedResponseSubmission(): PendingResponsesCollection { $itemSessionStore = $this->getAssessmentItemSessionStore(); $pendingResponses = $this->getPendingResponses(); @@ -2367,7 +2371,7 @@ protected function defferedResponseSubmission() * @param AssessmentItemSession $assessmentItemSession * @return ResponseProcessingEngine */ - protected function createResponseProcessingEngine(ResponseProcessing $responseProcessing, AssessmentItemSession $assessmentItemSession) + protected function createResponseProcessingEngine(ResponseProcessing $responseProcessing, AssessmentItemSession $assessmentItemSession): ResponseProcessingEngine { return new ResponseProcessingEngine($responseProcessing, $assessmentItemSession); } @@ -2384,7 +2388,7 @@ protected function createResponseProcessingEngine(ResponseProcessing $responsePr * @throws AssessmentItemSessionException * @throws PhpStorageException */ - protected function nextRouteItem($ignoreBranchings = false, $ignorePreConditions = false) + protected function nextRouteItem($ignoreBranchings = false, $ignorePreConditions = false): void { if ($this->isRunning() === false) { $msg = 'Cannot move to the next position while the state of the test session is INITIAL or CLOSED.'; @@ -2470,7 +2474,7 @@ protected function nextRouteItem($ignoreBranchings = false, $ignorePreConditions * @throws AssessmentItemSessionException * @throws PhpStorageException */ - public function moveNextTestPart() + public function moveNextTestPart(): void { if ($this->isRunning() === false) { $msg = 'Cannot move to the next testPart while the state of the test session is INITIAL or CLOSED.'; @@ -2497,7 +2501,7 @@ public function moveNextTestPart() * * @throws AssessmentTestSessionException If the test is not running. */ - public function moveNextAssessmentSection() + public function moveNextAssessmentSection(): void { if ($this->isRunning() === false) { $msg = 'Cannot move to the next assessmentSection while the state of the test session is INITIAL or CLOSED.'; @@ -2521,7 +2525,7 @@ public function moveNextAssessmentSection() * * @throws AssessmentTestSessionException If the test is not running or if trying to go to the previous route item in LINEAR navigation mode or if the current route item is the very first one in the route sequence. */ - protected function previousRouteItem() + protected function previousRouteItem(): void { if ($this->isRunning() === false) { $msg = 'Cannot move backward in the route item sequence while the state of the test session is INITIAL or CLOSED.'; @@ -2545,7 +2549,7 @@ protected function previousRouteItem() * * @throws AssessmentTestSessionException If an error occurs at OutcomeProcessing time or at result submission time. */ - protected function outcomeProcessing() + protected function outcomeProcessing(): void { if ($this->getAssessmentTest()->hasOutcomeProcessing() === true) { // As per QTI Spec: @@ -2574,7 +2578,7 @@ protected function outcomeProcessing() * * @return SplObjectStorage A map. */ - protected function getLastOccurenceUpdate() + protected function getLastOccurenceUpdate(): SplObjectStorage { return $this->lastOccurenceUpdate; } @@ -2585,7 +2589,7 @@ protected function getLastOccurenceUpdate() * @param AssessmentItemRef $assessmentItemRef An AssessmentItemRef object. * @param int $occurence An occurence number for $assessmentItemRef. */ - protected function notifyLastOccurenceUpdate(AssessmentItemRef $assessmentItemRef, $occurence) + protected function notifyLastOccurenceUpdate(AssessmentItemRef $assessmentItemRef, $occurence): void { $lastOccurenceUpdate = $this->getLastOccurenceUpdate(); $lastOccurenceUpdate[$assessmentItemRef] = $occurence; @@ -2611,7 +2615,7 @@ protected function notifyLastOccurenceUpdate(AssessmentItemRef $assessmentItemRe * @throws AssessmentTestSessionException If one or more time limits in force are not respected. * @see http://www.imsglobal.org/question/qtiv2p1/imsqti_infov2p1.html#element10535 IMS QTI about TimeLimits. */ - protected function checkTimeLimits($includeMinTime = false, $includeAssessmentItem = false) + protected function checkTimeLimits($includeMinTime = false, $includeAssessmentItem = false): void { $places = AssessmentTestPlace::TEST_PART | AssessmentTestPlace::ASSESSMENT_TEST | AssessmentTestPlace::ASSESSMENT_SECTION; // Include assessmentItem only if formally asked by client-code. @@ -2684,7 +2688,7 @@ protected function checkTimeLimits($includeMinTime = false, $includeAssessmentIt * @throws UnexpectedValueException If the current item session cannot be retrieved. * @throws PhpStorageException */ - public function suspend() + public function suspend(): void { if ($this->isRunning() === false) { $msg = 'Cannot suspend the item session if the test session is not running.'; @@ -2709,7 +2713,7 @@ public function suspend() * @throws AssessmentTestSessionException With code STATE_VIOLATION if the test session is not running. * @throws UnexpectedValueException If the current item session cannot be retrieved. */ - protected function interactWithItemSession() + protected function interactWithItemSession(): void { if ($this->isRunning() === false) { $msg = 'Cannot set the item session in interacting state if test session is not running.'; @@ -2737,7 +2741,7 @@ protected function interactWithItemSession() * @param Exception $e * @return AssessmentTestSessionException */ - protected function transformException(Exception $e) + protected function transformException(Exception $e): AssessmentTestSessionException { if ($e instanceof AssessmentItemSessionException) { switch ($e->getCode()) { @@ -2803,7 +2807,7 @@ protected function transformException(Exception $e) * * @return string */ - protected function buildCurrentItemSessionIdentifier() + protected function buildCurrentItemSessionIdentifier(): string { $itemIdentifier = $this->getCurrentAssessmentItemRef()->getIdentifier(); $itemOccurence = $this->getCurrentAssessmentItemRefOccurence(); @@ -2817,7 +2821,7 @@ protected function buildCurrentItemSessionIdentifier() * @param bool $excludeItem Whether or not include item time limits. * @return bool */ - protected function timeLimitsInForce($excludeItem = false) + protected function timeLimitsInForce($excludeItem = false): bool { return count($this->getCurrentRouteItem()->getTimeLimits($excludeItem)) !== 0; } @@ -2827,7 +2831,7 @@ protected function timeLimitsInForce($excludeItem = false) * * @return bool */ - protected function mustShowTestFeedback() + protected function mustShowTestFeedback(): bool { $mustShowTestFeedback = false; $feedbackRefs = new TestFeedbackRefCollection(); @@ -2900,7 +2904,7 @@ protected function mustShowTestFeedback() * visited by the candidate. In addition, if the navigation mode is nonLinear, templateDefaults * and templateProcessing will be applied if necessary to the item sessions that belong to the testPart. */ - protected function testPartVisit() + protected function testPartVisit(): void { $route = $this->getRoute(); $initialRoutePosition = $route->getPosition(); @@ -2967,7 +2971,7 @@ protected function testPartVisit() * @param TestPart|string A TestPart object or a testPart identifier. * @return bool */ - public function isTestPartVisited($testPart) + public function isTestPartVisited($testPart): bool { $visited = false; $visitedTestPartIdentifiers = $this->getVisitedTestPartIdentifiers(); @@ -2991,7 +2995,7 @@ public function isTestPartVisited($testPart) * * @return array An array of QtiFile objects. */ - public function getFiles() + public function getFiles(): array { $values = []; @@ -3031,7 +3035,7 @@ public function getFiles() * * @return bool */ - public function isNextRouteItemPredictible() + public function isNextRouteItemPredictible(): bool { // Case 1. The session is not running. if ($this->isRunning() === false) { @@ -3060,7 +3064,7 @@ public function isNextRouteItemPredictible() /** * @param RouteItem $routeItem */ - protected function initializeAssessmentItemSession(RouteItem $routeItem) + protected function initializeAssessmentItemSession(RouteItem $routeItem): void { $itemRef = $routeItem->getAssessmentItemRef(); $occurence = $routeItem->getOccurence(); @@ -3104,7 +3108,7 @@ protected function initializeAssessmentItemSession(RouteItem $routeItem) * * @return bool */ - protected function mustApplyBranchRules() + protected function mustApplyBranchRules(): bool { return ($this->getCurrentNavigationMode() === NavigationMode::LINEAR || $this->mustForceBranching() === true); } @@ -3117,7 +3121,7 @@ protected function mustApplyBranchRules() * @param bool $nextRouteItem To be set to true in order to know whether or not to apply PreConditions for the next route item. * @return bool */ - protected function mustApplyPreConditions($nextRouteItem = false) + protected function mustApplyPreConditions($nextRouteItem = false): bool { $routeItem = ($nextRouteItem === false) ? $this->getCurrentRouteItem() : $this->getRoute()->getNext(); return ($routeItem->getTestPart()->getNavigationMode() === NavigationMode::LINEAR || $this->mustForcePreconditions() === true); diff --git a/src/qtism/runtime/tests/AssessmentTestSessionException.php b/src/qtism/runtime/tests/AssessmentTestSessionException.php index 493941f15..2cb3c4a3e 100644 --- a/src/qtism/runtime/tests/AssessmentTestSessionException.php +++ b/src/qtism/runtime/tests/AssessmentTestSessionException.php @@ -36,7 +36,7 @@ class AssessmentTestSessionException extends Exception * * @var int */ - const UNKNOWN = 0; + public const UNKNOWN = 0; /** * Code to use when a state violation occurs e.g. while trying @@ -44,7 +44,7 @@ class AssessmentTestSessionException extends Exception * * @var int */ - const STATE_VIOLATION = 1; + public const STATE_VIOLATION = 1; /** * Code to use when a navigation mode violation occurs e.g. while @@ -52,7 +52,7 @@ class AssessmentTestSessionException extends Exception * * @var int */ - const NAVIGATION_MODE_VIOLATION = 2; + public const NAVIGATION_MODE_VIOLATION = 2; /** * Code to use when an error occurs while running the outcome processing @@ -60,7 +60,7 @@ class AssessmentTestSessionException extends Exception * * @var int */ - const OUTCOME_PROCESSING_ERROR = 3; + public const OUTCOME_PROCESSING_ERROR = 3; /** * Code to use when an error occurs while running the response processing @@ -68,21 +68,21 @@ class AssessmentTestSessionException extends Exception * * @var int */ - const RESPONSE_PROCESSING_ERROR = 4; + public const RESPONSE_PROCESSING_ERROR = 4; /** * Code to use when an error occurs while transmitting item/test results. * * @var int */ - const RESULT_SUBMISSION_ERROR = 5; + public const RESULT_SUBMISSION_ERROR = 5; /** * Error code to use when a logic error is done. * * @var int */ - const LOGIC_ERROR = 6; + public const LOGIC_ERROR = 6; /** * Error code to use when a jump is performed outside the current @@ -90,7 +90,7 @@ class AssessmentTestSessionException extends Exception * * @var int */ - const FORBIDDEN_JUMP = 7; + public const FORBIDDEN_JUMP = 7; /** * Error code to use when the maximum duration of a testPart @@ -98,7 +98,7 @@ class AssessmentTestSessionException extends Exception * * @var int */ - const TEST_PART_DURATION_OVERFLOW = 8; + public const TEST_PART_DURATION_OVERFLOW = 8; /** * Error code to use when the maximum duration of an assessmentSection @@ -106,7 +106,7 @@ class AssessmentTestSessionException extends Exception * * @var int */ - const ASSESSMENT_SECTION_DURATION_OVERFLOW = 9; + public const ASSESSMENT_SECTION_DURATION_OVERFLOW = 9; /** * Error code to use when the minimum duration of a testPart is not @@ -114,7 +114,7 @@ class AssessmentTestSessionException extends Exception * * @var int */ - const TEST_PART_DURATION_UNDERFLOW = 10; + public const TEST_PART_DURATION_UNDERFLOW = 10; /** * Error code to use when the minimum duration of an assessmentSection is not @@ -122,35 +122,35 @@ class AssessmentTestSessionException extends Exception * * @var int */ - const ASSESSMENT_SECTION_DURATION_UNDERFLOW = 11; + public const ASSESSMENT_SECTION_DURATION_UNDERFLOW = 11; /** * Error code to use when the maximum duration of an assessmentItem is reached. * * @var int */ - const ASSESSMENT_ITEM_DURATION_OVERFLOW = 12; + public const ASSESSMENT_ITEM_DURATION_OVERFLOW = 12; /** * Error code to use when the minimum duration of an assessmentItem is not reached. * * @var int */ - const ASSESSMENT_ITEM_DURATION_UNDERFLOW = 13; + public const ASSESSMENT_ITEM_DURATION_UNDERFLOW = 13; /** * Error code to use when the maximum duration of an assessmentTest is reached. * * @var int */ - const ASSESSMENT_TEST_DURATION_OVERFLOW = 14; + public const ASSESSMENT_TEST_DURATION_OVERFLOW = 14; /** * Error code to use when the minimum duration of an assessmentTest is not reached. * * @var int */ - const ASSESSMENT_TEST_DURATION_UNDERFLOW = 15; + public const ASSESSMENT_TEST_DURATION_UNDERFLOW = 15; /** * Error code to use when the maximum number of attempts on the current assessment item @@ -158,7 +158,7 @@ class AssessmentTestSessionException extends Exception * * @var int */ - const ASSESSMENT_ITEM_ATTEMPTS_OVERFLOW = 16; + public const ASSESSMENT_ITEM_ATTEMPTS_OVERFLOW = 16; /** * Error code to use when an invalid response is submitted for the current @@ -166,7 +166,7 @@ class AssessmentTestSessionException extends Exception * * @var int */ - const ASSESSMENT_ITEM_INVALID_RESPONSE = 17; + public const ASSESSMENT_ITEM_INVALID_RESPONSE = 17; /** * Error code to use when trying to skip the current item while @@ -174,7 +174,7 @@ class AssessmentTestSessionException extends Exception * * @var int */ - const ASSESSMENT_ITEM_SKIPPING_FORBIDDEN = 18; + public const ASSESSMENT_ITEM_SKIPPING_FORBIDDEN = 18; /** * Create a nex AssessmentTestSessionException. diff --git a/src/qtism/runtime/tests/AssessmentTestSessionState.php b/src/qtism/runtime/tests/AssessmentTestSessionState.php index c157776db..5038c0ac3 100644 --- a/src/qtism/runtime/tests/AssessmentTestSessionState.php +++ b/src/qtism/runtime/tests/AssessmentTestSessionState.php @@ -31,20 +31,20 @@ */ class AssessmentTestSessionState implements Enumeration { - const INITIAL = 0; + public const INITIAL = 0; - const INTERACTING = 1; + public const INTERACTING = 1; - const MODAL_FEEDBACK = 2; + public const MODAL_FEEDBACK = 2; - const SUSPENDED = 3; + public const SUSPENDED = 3; - const CLOSED = 4; + public const CLOSED = 4; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'INITIAL' => self::INITIAL, @@ -61,7 +61,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'initial': return self::INITIAL; break; diff --git a/src/qtism/runtime/tests/BasicOrdering.php b/src/qtism/runtime/tests/BasicOrdering.php index 86ba7412e..70b44dcad 100644 --- a/src/qtism/runtime/tests/BasicOrdering.php +++ b/src/qtism/runtime/tests/BasicOrdering.php @@ -31,7 +31,7 @@ class BasicOrdering extends AbstractOrdering /** * @return SelectableRouteCollection */ - public function order() + public function order(): SelectableRouteCollection { if (($ordering = $this->getAssessmentSection()->getOrdering()) !== null && $ordering->getShuffle() === true) { // $orderedRoutes will contain the result of the ordering algorithm. diff --git a/src/qtism/runtime/tests/BasicSelection.php b/src/qtism/runtime/tests/BasicSelection.php index 9ceb8f284..0607cc58b 100644 --- a/src/qtism/runtime/tests/BasicSelection.php +++ b/src/qtism/runtime/tests/BasicSelection.php @@ -36,7 +36,7 @@ class BasicSelection extends AbstractSelection * * @return SelectableRouteCollection A collection of SelectableRoute object describing the performed selection. */ - public function select() + public function select(): SelectableRouteCollection { $assessmentSection = $this->getAssessmentSection(); $selection = $assessmentSection->getSelection(); diff --git a/src/qtism/runtime/tests/DurationStore.php b/src/qtism/runtime/tests/DurationStore.php index 9a68160b9..e82fbbaf1 100644 --- a/src/qtism/runtime/tests/DurationStore.php +++ b/src/qtism/runtime/tests/DurationStore.php @@ -44,7 +44,7 @@ class DurationStore extends State * @param mixed $value * @throws InvalidArgumentException If one or more of the conditions above are not respected. */ - protected function checkType($value) + protected function checkType($value): void { parent::checkType($value); diff --git a/src/qtism/runtime/tests/Jump.php b/src/qtism/runtime/tests/Jump.php index 80aa61eac..b4339c4ce 100644 --- a/src/qtism/runtime/tests/Jump.php +++ b/src/qtism/runtime/tests/Jump.php @@ -76,7 +76,7 @@ public function __construct($position, RouteItem $target, AssessmentItemSession * * @param int $position */ - protected function setPosition($position) + protected function setPosition($position): void { $this->position = $position; } @@ -87,7 +87,7 @@ protected function setPosition($position) * * @return int */ - public function getPosition() + public function getPosition(): int { return $this->position; } @@ -97,7 +97,7 @@ public function getPosition() * * @param RouteItem $target A RouteItem object. */ - protected function setTarget(RouteItem $target) + protected function setTarget(RouteItem $target): void { $this->target = $target; } @@ -107,7 +107,7 @@ protected function setTarget(RouteItem $target) * * @return RouteItem A RouteItem object. */ - public function getTarget() + public function getTarget(): RouteItem { return $this->target; } @@ -118,7 +118,7 @@ public function getTarget() * @param AssessmentItemSession $itemSession An AssessmentItemSession object. * @throws InvalidArgumentException If $itemSessionState is not a value from the AssessmentItemSessionState enumeration. */ - protected function setItemSession(AssessmentItemSession $itemSession) + protected function setItemSession(AssessmentItemSession $itemSession): void { $this->itemSession = $itemSession; } @@ -128,7 +128,7 @@ protected function setItemSession(AssessmentItemSession $itemSession) * * @return AssessmentItemSession An AssessmentItemSession object. */ - public function getItemSession() + public function getItemSession(): AssessmentItemSession { return $this->itemSession; } diff --git a/src/qtism/runtime/tests/JumpCollection.php b/src/qtism/runtime/tests/JumpCollection.php index 8022b7ad8..637be38ec 100644 --- a/src/qtism/runtime/tests/JumpCollection.php +++ b/src/qtism/runtime/tests/JumpCollection.php @@ -37,7 +37,7 @@ class JumpCollection extends AbstractCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a Jump object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof Jump) { $msg = 'JumpCollection objects only accept to store Jump objects.'; diff --git a/src/qtism/runtime/tests/OrderingException.php b/src/qtism/runtime/tests/OrderingException.php index f66593b6c..17136a4d1 100644 --- a/src/qtism/runtime/tests/OrderingException.php +++ b/src/qtism/runtime/tests/OrderingException.php @@ -37,7 +37,7 @@ class OrderingException extends Exception * * @var int */ - const UNKNOWN = 0; + public const UNKNOWN = 0; /** * Error code to use when the error comes @@ -45,7 +45,7 @@ class OrderingException extends Exception * * @var int */ - const LOGIC_ERROR = 1; + public const LOGIC_ERROR = 1; /** * Create a new OrderingException exception object. diff --git a/src/qtism/runtime/tests/PendingResponseStore.php b/src/qtism/runtime/tests/PendingResponseStore.php index d99b5ad7c..a10ae8be5 100644 --- a/src/qtism/runtime/tests/PendingResponseStore.php +++ b/src/qtism/runtime/tests/PendingResponseStore.php @@ -50,7 +50,7 @@ public function __construct() * * @return SplObjectStorage */ - protected function getAssessmentItemRefMap() + protected function getAssessmentItemRefMap(): SplObjectStorage { return $this->assessmentItemRefMap; } @@ -60,7 +60,7 @@ protected function getAssessmentItemRefMap() * * @param SplObjectStorage $assessmentItemRefMap */ - protected function setAssessmentItemRefMap(SplObjectStorage $assessmentItemRefMap) + protected function setAssessmentItemRefMap(SplObjectStorage $assessmentItemRefMap): void { $this->assessmentItemRefMap = $assessmentItemRefMap; } @@ -70,7 +70,7 @@ protected function setAssessmentItemRefMap(SplObjectStorage $assessmentItemRefMa * * @return PendingResponsesCollection A collection of PendingResponses objects held by the store. */ - public function getAllPendingResponses() + public function getAllPendingResponses(): PendingResponsesCollection { $collection = new PendingResponsesCollection(); $map = $this->getAssessmentItemRefMap(); @@ -88,7 +88,7 @@ public function getAllPendingResponses() * * @param PendingResponses $pendingResponses */ - public function addPendingResponses(PendingResponses $pendingResponses) + public function addPendingResponses(PendingResponses $pendingResponses): void { $map = $this->getAssessmentItemRefMap(); $itemRef = $pendingResponses->getAssessmentItemRef(); @@ -110,7 +110,7 @@ public function addPendingResponses(PendingResponses $pendingResponses) * @param int $occurence An occurence number. * @return bool */ - public function hasPendingResponses(AssessmentItemRef $assessmentItemRef, $occurence = 0) + public function hasPendingResponses(AssessmentItemRef $assessmentItemRef, $occurence = 0): bool { $map = $this->getAssessmentItemRefMap(); diff --git a/src/qtism/runtime/tests/PendingResponses.php b/src/qtism/runtime/tests/PendingResponses.php index 1d47b5e2c..91b38c48a 100644 --- a/src/qtism/runtime/tests/PendingResponses.php +++ b/src/qtism/runtime/tests/PendingResponses.php @@ -73,7 +73,7 @@ public function __construct(State $state, AssessmentItemRef $assessmentItemRef, * * @param State $state A State object. */ - public function setState(State $state) + public function setState(State $state): void { $this->state = $state; } @@ -83,7 +83,7 @@ public function setState(State $state) * * @return State A State object. */ - public function getState() + public function getState(): State { return $this->state; } @@ -93,7 +93,7 @@ public function getState() * * @param AssessmentItemRef $assessmentItemRef An AssessmentItemRef object. */ - public function setAssessmentItemRef(AssessmentItemRef $assessmentItemRef) + public function setAssessmentItemRef(AssessmentItemRef $assessmentItemRef): void { $this->assessmentItemRef = $assessmentItemRef; } @@ -103,7 +103,7 @@ public function setAssessmentItemRef(AssessmentItemRef $assessmentItemRef) * * @return AssessmentItemRef An AssessmentItemRef object. */ - public function getAssessmentItemRef() + public function getAssessmentItemRef(): AssessmentItemRef { return $this->assessmentItemRef; } @@ -114,7 +114,7 @@ public function getAssessmentItemRef() * @param int $occurence An occurence number as a positive integer. * @throws InvalidArgumentException If $occurence is not a postive integer. */ - public function setOccurence($occurence) + public function setOccurence($occurence): void { if (!is_int($occurence)) { $msg = "The 'occurence' argument must be an integer value, '" . gettype($occurence) . "' given."; @@ -129,7 +129,7 @@ public function setOccurence($occurence) * * @return int A postivie integer value. */ - public function getOccurence() + public function getOccurence(): int { return $this->occurence; } diff --git a/src/qtism/runtime/tests/PendingResponsesCollection.php b/src/qtism/runtime/tests/PendingResponsesCollection.php index 0d7fdd155..fb099466a 100644 --- a/src/qtism/runtime/tests/PendingResponsesCollection.php +++ b/src/qtism/runtime/tests/PendingResponsesCollection.php @@ -34,7 +34,7 @@ class PendingResponsesCollection extends AbstractCollection /** * @param mixed $value */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof PendingResponses) { $msg = 'PendingResponsesCollection objects only accept to store PendingResponses objects.'; diff --git a/src/qtism/runtime/tests/Route.php b/src/qtism/runtime/tests/Route.php index 2611a4a5c..0f7689129 100644 --- a/src/qtism/runtime/tests/Route.php +++ b/src/qtism/runtime/tests/Route.php @@ -161,7 +161,7 @@ public function __construct() * * @return int */ - public function getPosition() + public function getPosition(): int { return $this->position; } @@ -171,7 +171,7 @@ public function getPosition() * * @param int $position */ - public function setPosition($position) + public function setPosition($position): void { $this->position = $position; } @@ -182,7 +182,7 @@ public function setPosition($position) * * @return array */ - protected function &getRouteItems() + protected function &getRouteItems(): array { return $this->routeItems; } @@ -193,7 +193,7 @@ protected function &getRouteItems() * * @return AssessmentItemRefCollection A collection of AssessmentItemRef objects. */ - public function getAssessmentItemRefs() + public function getAssessmentItemRefs(): AssessmentItemRefCollection { return $this->assessmentItemRefs; } @@ -204,7 +204,7 @@ public function getAssessmentItemRefs() * * @param AssessmentItemRefCollection $assessmentItemRefs A collection of AssessmentItemRefObjects. */ - public function setAssessmentItemRefs(AssessmentItemRefCollection $assessmentItemRefs) + public function setAssessmentItemRefs(AssessmentItemRefCollection $assessmentItemRefs): void { $this->assessmentItemRefs = $assessmentItemRefs; } @@ -215,7 +215,7 @@ public function setAssessmentItemRefs(AssessmentItemRefCollection $assessmentIte * * @return array A map of AssessmentItemRefCollection objects, which contain AssessmentItemRef objects of the same category. */ - protected function getAssessmentItemRefCategoryMap() + protected function getAssessmentItemRefCategoryMap(): array { return $this->assessmentItemRefCategoryMap; } @@ -226,7 +226,7 @@ protected function getAssessmentItemRefCategoryMap() * * @param array $assessmentItemRefCategoryMap A map of AssessmentItemRefCollection objects, which contain AssessmentItemRef object of the same category. */ - protected function setAssessmentItemRefCategoryMap(array $assessmentItemRefCategoryMap) + protected function setAssessmentItemRefCategoryMap(array $assessmentItemRefCategoryMap): void { $this->assessmentItemRefCategoryMap = $assessmentItemRefCategoryMap; } @@ -237,7 +237,7 @@ protected function setAssessmentItemRefCategoryMap(array $assessmentItemRefCateg * * @return array A map of AssessmentItemRefCollection objects, which contain AssessmentItemRef objects of the same section. */ - protected function getAssessmentItemRefSectionMap() + protected function getAssessmentItemRefSectionMap(): array { return $this->assessmentItemRefSectionMap; } @@ -248,7 +248,7 @@ protected function getAssessmentItemRefSectionMap() * * @param array $assessmentItemRefSectionMap A map of AssessmentItemRefCollection objects, which contain AssessmentItemRef objects of the same section. */ - protected function setAssessmentItemRefSectionMap(array $assessmentItemRefSectionMap) + protected function setAssessmentItemRefSectionMap(array $assessmentItemRefSectionMap): void { $this->assessmentItemRefSectionMap = $assessmentItemRefSectionMap; } @@ -259,7 +259,7 @@ protected function setAssessmentItemRefSectionMap(array $assessmentItemRefSectio * * @return SplObjectStorage */ - protected function getAssessmentItemRefOccurenceMap() + protected function getAssessmentItemRefOccurenceMap(): SplObjectStorage { return $this->assessmentItemRefOccurenceCount; } @@ -270,7 +270,7 @@ protected function getAssessmentItemRefOccurenceMap() * * @param SplObjectStorage $assessmentItemRefOccurenceCount */ - protected function setAssessmentItemRefOccurenceMap(SplObjectStorage $assessmentItemRefOccurenceCount) + protected function setAssessmentItemRefOccurenceMap(SplObjectStorage $assessmentItemRefOccurenceCount): void { $this->assessmentItemRefOccurenceCount = $assessmentItemRefOccurenceCount; } @@ -280,7 +280,7 @@ protected function setAssessmentItemRefOccurenceMap(SplObjectStorage $assessment * * @param SplObjectStorage $testPartMap */ - protected function setTestPartMap(SplObjectStorage $testPartMap) + protected function setTestPartMap(SplObjectStorage $testPartMap): void { $this->testPartMap = $testPartMap; } @@ -290,7 +290,7 @@ protected function setTestPartMap(SplObjectStorage $testPartMap) * * @return SplObjectStorage */ - protected function getTestPartMap() + protected function getTestPartMap(): SplObjectStorage { return $this->testPartMap; } @@ -300,7 +300,7 @@ protected function getTestPartMap() * * @param array $testPartIdentifierMap */ - protected function setTestPartIdentifierMap(array $testPartIdentifierMap) + protected function setTestPartIdentifierMap(array $testPartIdentifierMap): void { $this->testPartIdentifierMap = $testPartIdentifierMap; } @@ -310,7 +310,7 @@ protected function setTestPartIdentifierMap(array $testPartIdentifierMap) * * @return array */ - protected function getTestPartIdentifierMap() + protected function getTestPartIdentifierMap(): array { return $this->testPartIdentifierMap; } @@ -320,7 +320,7 @@ protected function getTestPartIdentifierMap() * * @param SplObjectStorage $assessmentSectionMap */ - protected function setAssessmentSectionMap(SplObjectStorage $assessmentSectionMap) + protected function setAssessmentSectionMap(SplObjectStorage $assessmentSectionMap): void { $this->assessmentSectionMap = $assessmentSectionMap; } @@ -330,7 +330,7 @@ protected function setAssessmentSectionMap(SplObjectStorage $assessmentSectionMa * * @return SplObjectStorage */ - protected function getAssessmentSectionMap() + protected function getAssessmentSectionMap(): SplObjectStorage { return $this->assessmentSectionMap; } @@ -340,7 +340,7 @@ protected function getAssessmentSectionMap() * * @param array $assessmentSectionIdentifierMap */ - protected function setAssessmentSectionIdentifierMap(array $assessmentSectionIdentifierMap) + protected function setAssessmentSectionIdentifierMap(array $assessmentSectionIdentifierMap): void { $this->assessmentSectionIdentifierMap = $assessmentSectionIdentifierMap; } @@ -350,7 +350,7 @@ protected function setAssessmentSectionIdentifierMap(array $assessmentSectionIde * * @return array */ - protected function getAssessmentSectionIdentifierMap() + protected function getAssessmentSectionIdentifierMap(): array { return $this->assessmentSectionIdentifierMap; } @@ -360,7 +360,7 @@ protected function getAssessmentSectionIdentifierMap() * * @param SplObjectStorage $assessmentItemRefMap */ - protected function setAssessmentItemRefMap(SplObjectStorage $assessmentItemRefMap) + protected function setAssessmentItemRefMap(SplObjectStorage $assessmentItemRefMap): void { $this->assessmentItemRefMap = $assessmentItemRefMap; } @@ -370,7 +370,7 @@ protected function setAssessmentItemRefMap(SplObjectStorage $assessmentItemRefMa * * @return SplObjectStorage */ - protected function getAssessmentItemRefMap() + protected function getAssessmentItemRefMap(): SplObjectStorage { return $this->assessmentItemRefMap; } @@ -380,7 +380,7 @@ protected function getAssessmentItemRefMap() * * @param IdentifierCollection $categories A collection of QTI Identifiers. */ - protected function setCategories(IdentifierCollection $categories) + protected function setCategories(IdentifierCollection $categories): void { $this->categories = $categories; } @@ -390,7 +390,7 @@ protected function setCategories(IdentifierCollection $categories) * * @return IdentifierCollection A collection of QTI Identifiers. */ - public function getCategories() + public function getCategories(): IdentifierCollection { return $this->categories; } @@ -403,7 +403,7 @@ public function getCategories() * @param TestPart $testPart * @param AssessmentTest $assessmentTest */ - public function addRouteItem(AssessmentItemRef $assessmentItemRef, $assessmentSections, TestPart $testPart, AssessmentTest $assessmentTest) + public function addRouteItem(AssessmentItemRef $assessmentItemRef, $assessmentSections, TestPart $testPart, AssessmentTest $assessmentTest): void { // Push the routeItem in the track :) ! $routeItem = new RouteItem($assessmentItemRef, $assessmentSections, $testPart, $assessmentTest); @@ -417,14 +417,14 @@ public function addRouteItem(AssessmentItemRef $assessmentItemRef, $assessmentSe * * @param RouteItem $routeItem A RouteItemObject. */ - public function addRouteItemObject(RouteItem $routeItem) + public function addRouteItemObject(RouteItem $routeItem): void { $this->registerAssessmentItemRef($routeItem); $this->registerTestPart($routeItem); $this->registerAssessmentSection($routeItem); } - public function rewind() + public function rewind(): void { $this->setPosition(0); } @@ -434,7 +434,7 @@ public function rewind() * * @return RouteItem A RouteItem object. */ - public function current() + public function current(): RouteItem { $routeItems = &$this->getRouteItems(); $position = $this->getPosition(); @@ -450,7 +450,7 @@ public function current() * * @return int The returned key is the position of the current RouteItem object in the Route. */ - public function key() + public function key(): int { return $this->getPosition(); } @@ -459,7 +459,7 @@ public function key() * Set the Route as its previous position in the RouteItem sequence. If the current * RouteItem is the first one prior to call next(), the Route remains in the same position. */ - public function previous() + public function previous(): void { $position = $this->getPosition(); if ($position > 0) { @@ -471,7 +471,7 @@ public function previous() * Set the Route as its next position in the RouteItem sequence. If the current * RouteItem is the last one prior to call next(), the iterator becomes invalid. */ - public function next() + public function next(): void { $this->setPosition($this->getPosition() + 1); } @@ -481,7 +481,7 @@ public function next() * * @return bool */ - public function valid() + public function valid(): bool { $routeItems = &$this->getRouteItems(); @@ -493,7 +493,7 @@ public function valid() * * @return bool */ - public function isLast() + public function isLast(): bool { $nextPosition = $this->getPosition() + 1; $routeItems = &$this->getRouteItems(); @@ -506,7 +506,7 @@ public function isLast() * * @return bool */ - public function isFirst() + public function isFirst(): bool { return $this->getPosition() === 0; } @@ -517,7 +517,7 @@ public function isFirst() * * @return bool */ - public function isNavigationLinear() + public function isNavigationLinear(): bool { return $this->current()->getTestPart()->getNavigationMode() === NavigationMode::LINEAR; } @@ -528,7 +528,7 @@ public function isNavigationLinear() * * @return bool */ - public function isNavigationNonLinear() + public function isNavigationNonLinear(): bool { return !$this->isNavigationLinear(); } @@ -539,7 +539,7 @@ public function isNavigationNonLinear() * * @return bool */ - public function isSubmissionIndividual() + public function isSubmissionIndividual(): bool { return $this->current()->getTestPart()->getSubmissionMode() === SubmissionMode::INDIVIDUAL; } @@ -550,7 +550,7 @@ public function isSubmissionIndividual() * * @return bool */ - public function isSubmissionSimultaneous() + public function isSubmissionSimultaneous(): bool { return !$this->isSubmissionIndividual(); } @@ -561,7 +561,7 @@ public function isSubmissionSimultaneous() * * @param Route $route A Route object. */ - public function appendRoute(Route $route) + public function appendRoute(Route $route): void { foreach ($route as $routeItem) { // @todo find why it must be cloned, I can't remember. @@ -585,7 +585,7 @@ public function appendRoute(Route $route) * * @param RouteItem $routeItem */ - protected function registerAssessmentItemRef(RouteItem $routeItem) + protected function registerAssessmentItemRef(RouteItem $routeItem): void { array_push($this->routeItems, $routeItem); @@ -640,7 +640,7 @@ protected function registerAssessmentItemRef(RouteItem $routeItem) * * @param RouteItem $routeItem A RouteItem object. */ - protected function registerTestPart(RouteItem $routeItem) + protected function registerTestPart(RouteItem $routeItem): void { // Register the RouteItem in the testPartMap. $testPart = $routeItem->getTestPart(); @@ -669,7 +669,7 @@ protected function registerTestPart(RouteItem $routeItem) * * @param RouteItem $routeItem A RouteItem object. */ - protected function registerAssessmentSection(RouteItem $routeItem) + protected function registerAssessmentSection(RouteItem $routeItem): void { foreach ($routeItem->getAssessmentSections() as $assessmentSection) { if (isset($this->assessmentSectionMap[$assessmentSection]) === false) { @@ -698,7 +698,7 @@ protected function registerAssessmentSection(RouteItem $routeItem) * @param bool $withSequenceNumber Whether to return the sequence number in the identifier or not. * @return IdentifierCollection */ - public function getIdentifierSequence($withSequenceNumber = true) + public function getIdentifierSequence($withSequenceNumber = true): IdentifierCollection { $routeItems = &$this->getRouteItems(); $collection = new IdentifierCollection(); @@ -721,7 +721,7 @@ public function getIdentifierSequence($withSequenceNumber = true) * @param string|IdentifierCollection $category A category identifier. * @return AssessmentItemRefCollection An collection of AssessmentItemRefCollection that belong to $category. */ - public function getAssessmentItemRefsByCategory($category) + public function getAssessmentItemRefsByCategory($category): AssessmentItemRefCollection { $categoryMap = $this->getAssessmentItemRefCategoryMap(); $categories = (is_string($category)) ? [$category] : $category->getArrayCopy(); @@ -746,7 +746,7 @@ public function getAssessmentItemRefsByCategory($category) * @param string $sectionIdentifier A section identifier. * @return AssessmentItemRefCollection A Collection of AssessmentItemRef objects that belong to the section $sectionIdentifier. */ - public function getAssessmentItemRefsBySection($sectionIdentifier) + public function getAssessmentItemRefsBySection($sectionIdentifier): AssessmentItemRefCollection { $sectionMap = $this->getAssessmentItemRefSectionMap(); @@ -762,7 +762,7 @@ public function getAssessmentItemRefsBySection($sectionIdentifier) * @param IdentifierCollection $excludeCategories A collection of category identifiers to be excluded from the selection. * @return AssessmentItemRefCollection A collection of filtered AssessmentItemRef objects. */ - public function getAssessmentItemRefsSubset($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null) + public function getAssessmentItemRefsSubset($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null): AssessmentItemRefCollection { $bySection = (empty($sectionIdentifier)) ? $this->getAssessmentItemRefs() : $this->getAssessmentItemRefsBySection($sectionIdentifier); @@ -784,7 +784,7 @@ public function getAssessmentItemRefsSubset($sectionIdentifier = '', IdentifierC * @param AssessmentItemRef $assessmentItemRef An AssessmentItemRef object. * @return int The number of occurences found in the route for $assessmentItemRef. */ - public function getOccurenceCount(AssessmentItemRef $assessmentItemRef) + public function getOccurenceCount(AssessmentItemRef $assessmentItemRef): int { $occurenceMap = $this->getAssessmentItemRefOccurenceMap(); return $occurenceMap[$assessmentItemRef] ?? 0; @@ -795,7 +795,7 @@ public function getOccurenceCount(AssessmentItemRef $assessmentItemRef) * * @return int */ - public function count() + public function count(): int { return count($this->getRouteItems()); } @@ -809,7 +809,7 @@ public function count() * @return RouteItem The RouteItem found at $position. * @throws OutOfBoundsException If no RouteItem is found at $position. */ - public function getRouteItemAt($position) + public function getRouteItemAt($position): RouteItem { $routeItems = &$this->getRouteItems(); @@ -827,7 +827,7 @@ public function getRouteItemAt($position) * @return RouteItem The last RouteItem of the Route. * @throws OutOfBoundsException If the Route is empty. */ - public function getLastRouteItem() + public function getLastRouteItem(): RouteItem { $routeItems = &$this->getRouteItems(); $routeItemsCount = count($routeItems); @@ -846,7 +846,7 @@ public function getLastRouteItem() * @return RouteItem The first RouteItem of the Route. * @throws OutOfBoundsException If the Route is empty. */ - public function getFirstRouteItem() + public function getFirstRouteItem(): RouteItem { $routeItems = &$this->getRouteItems(); $routeItemsCount = count($routeItems); @@ -865,7 +865,7 @@ public function getFirstRouteItem() * @return bool * @throws OutOfBoundsException If the Route is empty. */ - public function isLastOfTestPart() + public function isLastOfTestPart(): bool { $count = $this->count(); if ($count === 0) { @@ -891,7 +891,7 @@ public function isLastOfTestPart() * @return bool * @throws OutOfBoundsException If the Route is empty. */ - public function isFirstOfTestPart() + public function isFirstOfTestPart(): bool { $count = $this->count(); if ($count === 0) { @@ -916,7 +916,7 @@ public function isFirstOfTestPart() * @return RouteItem The previous RouteItem in the Route. * @throws OutOfBoundsException If there is no previous RouteItem in the route. In other words, the current RouteItem in the route is the first one of the sequence. */ - public function getPrevious() + public function getPrevious(): RouteItem { $currentPosition = $this->getPosition(); if ($currentPosition === 0) { @@ -933,7 +933,7 @@ public function getPrevious() * @return RouteItem The previous RouteItem in the Route. * @throws OutOfBoundsException If there is no next RouteItem in the route. In other words, the current RouteItem in the route is the last one of the sequence. */ - public function getNext() + public function getNext(): RouteItem { if ($this->isLast() === true) { $msg = 'The current RouteItem is the last one in the route. There is no next RouteItem.'; @@ -951,7 +951,7 @@ public function getNext() * @return bool * @throws OutOfBoundsException If $position is out of the Route bounds. */ - public function isInTestPart($position, TestPart $testPart) + public function isInTestPart($position, TestPart $testPart): bool { try { $routeItem = $this->getRouteItemAt($position); @@ -969,7 +969,7 @@ public function isInTestPart($position, TestPart $testPart) * * @return RouteItemCollection A collection of RouteItem objects involved in the current TestPart. */ - public function getCurrentTestPartRouteItems() + public function getCurrentTestPartRouteItems(): RouteItemCollection { return $this->getRouteItemsByTestPart($this->current()->getTestPart()); } @@ -982,7 +982,7 @@ public function getCurrentTestPartRouteItems() * @throws OutOfBoundsException If $testPart is not referenced in the Route. * @throws OutOfRangeException If $testPart is not a string nor a TestPart object. */ - public function getRouteItemsByTestPart($testPart) + public function getRouteItemsByTestPart($testPart): RouteItemCollection { if (is_string($testPart)) { $map = $this->getTestPartIdentifierMap(); @@ -1016,7 +1016,7 @@ public function getRouteItemsByTestPart($testPart) * @throws OutOfBoundsException If $assessmentSection is not referenced in the Route. * @throws OutOfRangeException If $assessmentSection is not a string nor an AssessmentSection object. */ - public function getRouteItemsByAssessmentSection($assessmentSection) + public function getRouteItemsByAssessmentSection($assessmentSection): RouteItemCollection { if (is_string($assessmentSection)) { $map = $this->getAssessmentSectionIdentifierMap(); @@ -1051,7 +1051,7 @@ public function getRouteItemsByAssessmentSection($assessmentSection) * @throws OutOfRangeException If $assessmentItemRef is not a string nor an AssessmentItemRef object. * @throws OutOfBoundsException If $assessmentItemRef is not referenced in the Route. */ - public function getRouteItemsByAssessmentItemRef($assessmentItemRef) + public function getRouteItemsByAssessmentItemRef($assessmentItemRef): RouteItemCollection { if (is_string($assessmentItemRef)) { if (($ref = $this->assessmentItemRefs[$assessmentItemRef]) !== null) { @@ -1078,7 +1078,7 @@ public function getRouteItemsByAssessmentItemRef($assessmentItemRef) * * @return RouteItemCollection A collection of RouteItem objects. */ - public function getAllRouteItems() + public function getAllRouteItems(): RouteItemCollection { return new RouteItemCollection($this->getRouteItems()); } @@ -1097,7 +1097,7 @@ public function getAllRouteItems() * @throws OutOfBoundsException If an error occurs while branching e.g. the $identifier is not referenced in the route or the target is invalid. * @throws OutOfRangeException If $identifier is not a valid branching identifier. */ - public function branch($identifier) + public function branch($identifier): void { try { $identifier = new VariableIdentifier($identifier); @@ -1174,7 +1174,7 @@ public function branch($identifier) * @return int The position of the routeItem in the Route. The indexes begin at 0. * @throws OutOfBoundsException If no such $routeItem is referenced in the Route. */ - public function getRouteItemPosition(RouteItem $routeItem) + public function getRouteItemPosition(RouteItem $routeItem): int { if (($search = array_search($routeItem, $this->getRouteItems(), true)) !== false) { return $search; diff --git a/src/qtism/runtime/tests/RouteItem.php b/src/qtism/runtime/tests/RouteItem.php index efadd1956..444d19cbd 100644 --- a/src/qtism/runtime/tests/RouteItem.php +++ b/src/qtism/runtime/tests/RouteItem.php @@ -121,7 +121,7 @@ public function __construct(AssessmentItemRef $assessmentItemRef, $assessmentSec * * @param AssessmentTest $assessmentTest An AssessmentTest object. */ - public function setAssessmentTest(AssessmentTest $assessmentTest) + public function setAssessmentTest(AssessmentTest $assessmentTest): void { $this->assessmentTest = $assessmentTest; } @@ -131,7 +131,7 @@ public function setAssessmentTest(AssessmentTest $assessmentTest) * * @return AssessmentTest An AssessmentTest object. */ - public function getAssessmentTest() + public function getAssessmentTest(): AssessmentTest { return $this->assessmentTest; } @@ -141,7 +141,7 @@ public function getAssessmentTest() * * @param AssessmentItemRef $assessmentItemRef An AssessmentItemRef object. */ - public function setAssessmentItemRef(AssessmentItemRef $assessmentItemRef) + public function setAssessmentItemRef(AssessmentItemRef $assessmentItemRef): void { $this->assessmentItemRef = $assessmentItemRef; } @@ -151,7 +151,7 @@ public function setAssessmentItemRef(AssessmentItemRef $assessmentItemRef) * * @return AssessmentItemRef An AssessmentItemRef object. */ - public function getAssessmentItemRef() + public function getAssessmentItemRef(): AssessmentItemRef { return $this->assessmentItemRef; } @@ -161,7 +161,7 @@ public function getAssessmentItemRef() * * @param TestPart $testPart A TestPart object. */ - public function setTestPart(TestPart $testPart) + public function setTestPart(TestPart $testPart): void { $this->testPart = $testPart; } @@ -171,7 +171,7 @@ public function setTestPart(TestPart $testPart) * * @return TestPart A TestPart object. */ - public function getTestPart() + public function getTestPart(): TestPart { return $this->testPart; } @@ -181,7 +181,7 @@ public function getTestPart() * * @param AssessmentSection $assessmentSection An AssessmentSection object. */ - public function setAssessmentSection(AssessmentSection $assessmentSection) + public function setAssessmentSection(AssessmentSection $assessmentSection): void { $this->assessmentSections = new AssessmentSectionCollection([$assessmentSection]); } @@ -191,7 +191,7 @@ public function setAssessmentSection(AssessmentSection $assessmentSection) * * @param AssessmentSectionCollection $assessmentSections A collection of AssessmentSection objects. */ - public function setAssessmentSections(AssessmentSectionCollection $assessmentSections) + public function setAssessmentSections(AssessmentSectionCollection $assessmentSections): void { $this->assessmentSections = $assessmentSections; } @@ -201,7 +201,7 @@ public function setAssessmentSections(AssessmentSectionCollection $assessmentSec * * @param int $occurence An occurence number. */ - public function setOccurence($occurence) + public function setOccurence($occurence): void { $this->occurence = $occurence; } @@ -211,7 +211,7 @@ public function setOccurence($occurence) * * @return int An occurence number. */ - public function getOccurence() + public function getOccurence(): int { return $this->occurence; } @@ -221,7 +221,7 @@ public function getOccurence() * * @return BranchRuleCollection A collection of BranchRule objects. */ - public function getBranchRules() + public function getBranchRules(): BranchRuleCollection { return $this->branchRules; } @@ -231,7 +231,7 @@ public function getBranchRules() * * @param BranchRuleCollection $branchRules A collection of BranchRule objects. */ - public function setBranchRules(BranchRuleCollection $branchRules) + public function setBranchRules(BranchRuleCollection $branchRules): void { $this->branchRules = $branchRules; } @@ -241,7 +241,7 @@ public function setBranchRules(BranchRuleCollection $branchRules) * * @param BranchRule $branchRule A BranchRule object to be added. */ - public function addBranchRule(BranchRule $branchRule) + public function addBranchRule(BranchRule $branchRule): void { $this->branchRules->attach($branchRule); } @@ -251,7 +251,7 @@ public function addBranchRule(BranchRule $branchRule) * * @param BranchRuleCollection $branchRules A collection of BranchRule object. */ - public function addBranchRules(BranchRuleCollection $branchRules) + public function addBranchRules(BranchRuleCollection $branchRules): void { foreach ($branchRules as $branchRule) { $this->addBranchRule($branchRule); @@ -263,7 +263,7 @@ public function addBranchRules(BranchRuleCollection $branchRules) * * @return PreConditionCollection A collection of PreCondition objects. */ - public function getPreConditions() + public function getPreConditions(): PreConditionCollection { return $this->preConditions; } @@ -273,7 +273,7 @@ public function getPreConditions() * * @param PreConditionCollection $preConditions A collection of PreCondition objects. */ - public function setPreConditions(PreConditionCollection $preConditions) + public function setPreConditions(PreConditionCollection $preConditions): void { $this->preConditions = $preConditions; } @@ -283,7 +283,7 @@ public function setPreConditions(PreConditionCollection $preConditions) * * @param PreCondition $preCondition A PreCondition object to be added. */ - public function addPreCondition(PreCondition $preCondition) + public function addPreCondition(PreCondition $preCondition): void { $this->preConditions->attach($preCondition); } @@ -293,7 +293,7 @@ public function addPreCondition(PreCondition $preCondition) * * @param PreConditionCollection $preConditions A collection of PreCondition object. */ - public function addPreConditions(PreConditionCollection $preConditions) + public function addPreConditions(PreConditionCollection $preConditions): void { foreach ($preConditions as $preCondition) { $this->addPreCondition($preCondition); @@ -303,7 +303,7 @@ public function addPreConditions(PreConditionCollection $preConditions) /** * Increment the occurence number by 1. */ - public function incrementOccurenceNumber() + public function incrementOccurenceNumber(): void { $this->setOccurence($this->getOccurence() + 1); } @@ -315,7 +315,7 @@ public function incrementOccurenceNumber() * * @return AssessmentSection An AssessmentSection object. */ - public function getAssessmentSection() + public function getAssessmentSection(): AssessmentSection { $assessmentSections = $this->getAssessmentSections()->getArrayCopy(); @@ -327,7 +327,7 @@ public function getAssessmentSection() * * @return AssessmentSectionCollection An AssessmentSectionCollection object. */ - public function getAssessmentSections() + public function getAssessmentSections(): AssessmentSectionCollection { return $this->assessmentSections; } @@ -337,7 +337,7 @@ public function getAssessmentSections() * * @return RouteItemSessionControl|null The ItemSessionControl in force or null if the RouteItem is not under ItemSessionControl. */ - public function getItemSessionControl() + public function getItemSessionControl(): ?RouteItemSessionControl { if (($isc = $this->getAssessmentItemRef()->getItemSessionControl()) !== null) { return RouteItemSessionControl::createFromItemSessionControl($isc, $this->getAssessmentItemRef()); @@ -367,7 +367,7 @@ public function getItemSessionControl() * * @return RubricBlockCollection A collection of RubricBlock objects. */ - public function getRubricBlocks() + public function getRubricBlocks(): RubricBlockCollection { $rubrics = new RubricBlockCollection(); @@ -385,7 +385,7 @@ public function getRubricBlocks() * * @return RubricBlockRefCollection A collection of RubricBlockRef objects. */ - public function getRubricBlockRefs() + public function getRubricBlockRefs(): RubricBlockRefCollection { $rubrics = new RubricBlockRefCollection(); @@ -402,7 +402,7 @@ public function getRubricBlockRefs() * @param bool $excludeItem Whether or not include the TimeLimits in force for the assessment item of the RouteItem. * @return RouteTimeLimitsCollection */ - public function getTimeLimits($excludeItem = false) + public function getTimeLimits($excludeItem = false): RouteTimeLimitsCollection { $timeLimits = new RouteTimeLimitsCollection(); diff --git a/src/qtism/runtime/tests/RouteItemCollection.php b/src/qtism/runtime/tests/RouteItemCollection.php index 8381cb494..f1cacda6c 100644 --- a/src/qtism/runtime/tests/RouteItemCollection.php +++ b/src/qtism/runtime/tests/RouteItemCollection.php @@ -37,7 +37,7 @@ class RouteItemCollection extends AbstractCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of RouteItem. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof RouteItem) { $msg = 'RoutItemCollection objects only accept to store RouteItem objects.'; diff --git a/src/qtism/runtime/tests/RouteItemSessionControl.php b/src/qtism/runtime/tests/RouteItemSessionControl.php index 266025b1a..5fbf79a54 100644 --- a/src/qtism/runtime/tests/RouteItemSessionControl.php +++ b/src/qtism/runtime/tests/RouteItemSessionControl.php @@ -62,7 +62,7 @@ public function __construct(ItemSessionControl $itemSessionControl, QtiComponent * * @return QtiComponent A QtiComponent object. */ - public function getOwner() + public function getOwner(): QtiComponent { return $this->owner; } @@ -72,7 +72,7 @@ public function getOwner() * * @param QtiComponent $owner A QtiComponent object. */ - public function setOwner(QtiComponent $owner) + public function setOwner(QtiComponent $owner): void { $this->owner = $owner; } @@ -82,7 +82,7 @@ public function setOwner(QtiComponent $owner) * * @return ItemSessionControl */ - public function getItemSessionControl() + public function getItemSessionControl(): ItemSessionControl { return $this->itemSessionControl; } @@ -92,7 +92,7 @@ public function getItemSessionControl() * * @param ItemSessionControl $itemSessionControl */ - public function setItemSessionControl(ItemSessionControl $itemSessionControl) + public function setItemSessionControl(ItemSessionControl $itemSessionControl): void { $this->itemSessionControl = $itemSessionControl; } @@ -105,7 +105,7 @@ public function setItemSessionControl(ItemSessionControl $itemSessionControl) * @param QtiComponent $owner The owner of the ItemSessionControl object. * @return RouteItemSessionControl A new RouteItemSessionControl object. */ - public static function createFromItemSessionControl(ItemSessionControl $itemSessionControl, QtiComponent $owner) + public static function createFromItemSessionControl(ItemSessionControl $itemSessionControl, QtiComponent $owner): RouteItemSessionControl { return new static($itemSessionControl, $owner); } diff --git a/src/qtism/runtime/tests/RouteTimeLimits.php b/src/qtism/runtime/tests/RouteTimeLimits.php index c1cb8bb5b..c5f19e098 100644 --- a/src/qtism/runtime/tests/RouteTimeLimits.php +++ b/src/qtism/runtime/tests/RouteTimeLimits.php @@ -63,7 +63,7 @@ public function __construct(TimeLimits $timeLimits, QtiComponent $owner) * * @return QtiComponent A QtiComponent object. */ - public function getOwner() + public function getOwner(): QtiComponent { return $this->owner; } @@ -73,7 +73,7 @@ public function getOwner() * * @param QtiComponent $owner A QtiComponent object. */ - public function setOwner(QtiComponent $owner) + public function setOwner(QtiComponent $owner): void { $this->owner = $owner; } @@ -83,7 +83,7 @@ public function setOwner(QtiComponent $owner) * * @return TimeLimits */ - public function getTimeLimits() + public function getTimeLimits(): TimeLimits { return $this->timeLimits; } @@ -93,7 +93,7 @@ public function getTimeLimits() * * @param TimeLimits $timeLimits */ - public function setTimeLimits(TimeLimits $timeLimits) + public function setTimeLimits(TimeLimits $timeLimits): void { $this->timeLimits = $timeLimits; } @@ -106,7 +106,7 @@ public function setTimeLimits(TimeLimits $timeLimits) * @param QtiComponent $owner The owner component of $timeLimits. * @return RouteTimeLimits A new RouteTimeLimits object. */ - public static function createFromTimeLimits(TimeLimits $timeLimits, QtiComponent $owner) + public static function createFromTimeLimits(TimeLimits $timeLimits, QtiComponent $owner): self { return new static($timeLimits, $owner); } diff --git a/src/qtism/runtime/tests/RouteTimeLimitsCollection.php b/src/qtism/runtime/tests/RouteTimeLimitsCollection.php index 8692c9f4b..81e2917ae 100644 --- a/src/qtism/runtime/tests/RouteTimeLimitsCollection.php +++ b/src/qtism/runtime/tests/RouteTimeLimitsCollection.php @@ -37,7 +37,7 @@ class RouteTimeLimitsCollection extends AbstractCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of RouteTimeLimit. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof RouteTimeLimits) { $msg = 'A RouteTimeLimitsCollection only accepts RouteTimeLimits objects to be stored.'; diff --git a/src/qtism/runtime/tests/SelectableRoute.php b/src/qtism/runtime/tests/SelectableRoute.php index 7c21b81b9..279f8b026 100644 --- a/src/qtism/runtime/tests/SelectableRoute.php +++ b/src/qtism/runtime/tests/SelectableRoute.php @@ -79,7 +79,7 @@ public function __construct($fixed = false, $required = false, $visible = true, * * @return bool */ - public function isFixed() + public function isFixed(): bool { return $this->fixed; } @@ -89,7 +89,7 @@ public function isFixed() * * @return bool */ - public function isVisible() + public function isVisible(): bool { return $this->visible; } @@ -99,7 +99,7 @@ public function isVisible() * * @return bool */ - public function isRequired() + public function isRequired(): bool { return $this->required; } @@ -109,7 +109,7 @@ public function isRequired() * * @param bool $fixed */ - public function setFixed($fixed) + public function setFixed($fixed): void { $this->fixed = $fixed; } @@ -119,7 +119,7 @@ public function setFixed($fixed) * * @param bool $visible */ - public function setVisible($visible) + public function setVisible($visible): void { $this->visible = $visible; } @@ -129,7 +129,7 @@ public function setVisible($visible) * * @param bool $required */ - public function setRequired($required) + public function setRequired($required): void { $this->required = $required; } @@ -139,7 +139,7 @@ public function setRequired($required) * * @param bool $keepTogether */ - public function setKeepTogether($keepTogether) + public function setKeepTogether($keepTogether): void { $this->keepTogether = $keepTogether; } @@ -149,7 +149,7 @@ public function setKeepTogether($keepTogether) * * @return bool */ - public function mustKeepTogether() + public function mustKeepTogether(): bool { return $this->keepTogether; } diff --git a/src/qtism/runtime/tests/SelectableRouteCollection.php b/src/qtism/runtime/tests/SelectableRouteCollection.php index bd46a418e..6d98ac194 100644 --- a/src/qtism/runtime/tests/SelectableRouteCollection.php +++ b/src/qtism/runtime/tests/SelectableRouteCollection.php @@ -38,7 +38,7 @@ class SelectableRouteCollection extends AbstractCollection * @param mixed $value * @throws InvalidArgumentException If $value is not a Route object. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof SelectableRoute) { $msg = "SelectableRouteCollection class only accept SelectableRoute objects, '" . gettype($value) . "' given."; @@ -54,7 +54,7 @@ protected function checkType($value) * @param int $position2 A RouteItem position. * @throws OutOfBoundsException If $position1 or $position2 are not poiting to any Route. */ - public function swap($position1, $position2) + public function swap($position1, $position2): void { $routes = &$this->getDataPlaceHolder(); @@ -79,7 +79,7 @@ public function swap($position1, $position2) * @param SelectableRoute $route A SelectableRoute object. * @param int $position An integer index where $route must be placed. */ - public function insertAt(SelectableRoute $route, $position) + public function insertAt(SelectableRoute $route, $position): void { $data = &$this->getDataPlaceHolder(); if ($position === 0) { diff --git a/src/qtism/runtime/tests/SelectionException.php b/src/qtism/runtime/tests/SelectionException.php index 730eaf4ed..9ec564b05 100644 --- a/src/qtism/runtime/tests/SelectionException.php +++ b/src/qtism/runtime/tests/SelectionException.php @@ -37,7 +37,7 @@ class SelectionException extends Exception * * @var int */ - const UNKNOWN = 0; + public const UNKNOWN = 0; /** * Error code to use when the error comes @@ -45,7 +45,7 @@ class SelectionException extends Exception * * @var int */ - const LOGIC_ERROR = 1; + public const LOGIC_ERROR = 1; /** * Create a new SelectionException exception object. diff --git a/src/qtism/runtime/tests/SessionManager.php b/src/qtism/runtime/tests/SessionManager.php index 534e4196c..1894460ae 100644 --- a/src/qtism/runtime/tests/SessionManager.php +++ b/src/qtism/runtime/tests/SessionManager.php @@ -40,7 +40,7 @@ class SessionManager extends AbstractSessionManager * @param int $config (optional) The configuration of the AssessmentTestSession object. * @return AssessmentTestSession */ - protected function instantiateAssessmentTestSession(AssessmentTest $test, Route $route, $config = 0) + protected function instantiateAssessmentTestSession(AssessmentTest $test, Route $route, $config = 0): AssessmentTestSession { return new AssessmentTestSession($test, $this, $route, $config); } @@ -53,7 +53,7 @@ protected function instantiateAssessmentTestSession(AssessmentTest $test, Route * @param int $submissionMode A value from the SubmissionMode enumeration. * @return AssessmentItemSession */ - protected function instantiateAssessmentItemSession(IAssessmentItem $assessmentItem, $navigationMode, $submissionMode) + protected function instantiateAssessmentItemSession(IAssessmentItem $assessmentItem, $navigationMode, $submissionMode): AssessmentItemSession { // When instantiating an AssessmentItemSession for a test, template processing must not occur automatically. // is always false. diff --git a/src/qtism/runtime/tests/TestResultsSubmission.php b/src/qtism/runtime/tests/TestResultsSubmission.php index b17133720..71e6c0138 100644 --- a/src/qtism/runtime/tests/TestResultsSubmission.php +++ b/src/qtism/runtime/tests/TestResultsSubmission.php @@ -31,14 +31,14 @@ */ class TestResultsSubmission implements Enumeration { - const END = 0; + public const END = 0; - const OUTCOME_PROCESSING = 1; + public const OUTCOME_PROCESSING = 1; /** * @return array */ - public static function asArray() + public static function asArray(): array { return [ 'END' => self::END, @@ -52,7 +52,7 @@ public static function asArray() */ public static function getConstantByName($name) { - switch (strtolower($name)) { + switch (strtolower((string)$name)) { case 'end': return self::END; break; diff --git a/src/qtism/runtime/tests/TimeConstraint.php b/src/qtism/runtime/tests/TimeConstraint.php index 7d735f53a..3582b95df 100644 --- a/src/qtism/runtime/tests/TimeConstraint.php +++ b/src/qtism/runtime/tests/TimeConstraint.php @@ -78,7 +78,7 @@ public function __construct(QtiComponent $source, QtiDuration $duration, $naviga * * @param QtiComponent $source A TestPart or SectionPart object. */ - protected function setSource(QtiComponent $source) + protected function setSource(QtiComponent $source): void { $this->source = $source; } @@ -88,7 +88,7 @@ protected function setSource(QtiComponent $source) * * @return QtiComponent A TestPart or SectionPart object. */ - public function getSource() + public function getSource(): QtiComponent { return $this->source; } @@ -99,7 +99,7 @@ public function getSource() * * @param QtiDuration $duration A Duration object. */ - protected function setDuration(QtiDuration $duration) + protected function setDuration(QtiDuration $duration): void { $this->duration = $duration; } @@ -110,7 +110,7 @@ protected function setDuration(QtiDuration $duration) * * @return QtiDuration A Duration object. */ - public function getDuration() + public function getDuration(): QtiDuration { return $this->duration; } @@ -120,7 +120,7 @@ public function getDuration() * * @param int $navigationMode A value from the NavigationMode enumeration. */ - protected function setNavigationMode($navigationMode) + protected function setNavigationMode($navigationMode): void { $this->navigationMode = $navigationMode; } @@ -130,7 +130,7 @@ protected function setNavigationMode($navigationMode) * * @return int A value from the NavigationMode enumeration. */ - public function getNavigationMode() + public function getNavigationMode(): int { return $this->navigationMode; } @@ -178,7 +178,7 @@ public function getMinimumRemainingTime() * * @return bool */ - public function maxTimeInForce() + public function maxTimeInForce(): bool { return ($timeLimits = $this->getSource()->getTimeLimits()) !== null && $timeLimits->hasMaxTime() === true; } @@ -194,7 +194,7 @@ public function maxTimeInForce() * @see http://www.imsglobal.org/question/qtiv2p1/imsqti_infov2p1.html#element10535 QTI timeLimits * @return bool */ - public function minTimeInForce() + public function minTimeInForce(): bool { if (($source = $this->getSource()) instanceof SectionPart && $this->getNavigationMode() === NavigationMode::NONLINEAR) { return false; @@ -210,7 +210,7 @@ public function minTimeInForce() * * @return bool */ - public function allowLateSubmission() + public function allowLateSubmission(): bool { if (($timeLimits = $this->getSource()->getTimeLimits()) !== null && $timeLimits->hasMaxTime() === false) { return true; diff --git a/src/qtism/runtime/tests/TimeConstraintCollection.php b/src/qtism/runtime/tests/TimeConstraintCollection.php index 70db100b1..c5bdc3bac 100644 --- a/src/qtism/runtime/tests/TimeConstraintCollection.php +++ b/src/qtism/runtime/tests/TimeConstraintCollection.php @@ -37,7 +37,7 @@ class TimeConstraintCollection extends AbstractCollection * @param mixed $value * @throws InvalidArgumentException If $value is not an instance of TimeConstraint. */ - protected function checkType($value) + protected function checkType($value): void { if (!$value instanceof TimeConstraint) { $msg = 'TimeConstraintCollection objects only accept to store TimeConstraint objects.'; diff --git a/src/qtism/runtime/tests/Utils.php b/src/qtism/runtime/tests/Utils.php index 0e4064162..0643facbb 100644 --- a/src/qtism/runtime/tests/Utils.php +++ b/src/qtism/runtime/tests/Utils.php @@ -58,7 +58,7 @@ class Utils * @param ResponseValidityConstraint $constraint * @return bool */ - public static function isResponseValid(QtiDatatype $response = null, ResponseValidityConstraint $constraint) + public static function isResponseValid(QtiDatatype $response = null, ResponseValidityConstraint $constraint): bool { $min = $constraint->getMinConstraint(); $max = $constraint->getMaxConstraint(); @@ -93,7 +93,7 @@ public static function isResponseValid(QtiDatatype $response = null, ResponseVal && self::isSingleMatchGroup($patternMask); foreach ($values as $value) { - $result = @preg_match($patternMask, $value); + $result = @preg_match($patternMask, (string)$value); if ($result === 0) { return false; diff --git a/test/qtismtest/QtiSmAssessmentItemTestCase.php b/test/qtismtest/QtiSmAssessmentItemTestCase.php index e32f81a68..792e77119 100644 --- a/test/qtismtest/QtiSmAssessmentItemTestCase.php +++ b/test/qtismtest/QtiSmAssessmentItemTestCase.php @@ -41,7 +41,7 @@ protected function createAssessmentItemSession(IAssessmentItem $assessmentItem): * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function createExtendedAssessmentItemRefFromXml($xmlString) + protected function createExtendedAssessmentItemRefFromXml($xmlString): ExtendedAssessmentItemRef { $marshaller = new ExtendedAssessmentItemRefMarshaller('2.1'); $element = $this->createDOMElement($xmlString); @@ -60,7 +60,7 @@ protected function createExtendedAssessmentItemRefFromXml($xmlString) * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function instantiateBasicAssessmentItemSession() + protected function instantiateBasicAssessmentItemSession(): AssessmentItemSession { $itemRef = $this->createExtendedAssessmentItemRefFromXml(' @@ -96,7 +96,7 @@ protected function instantiateBasicAssessmentItemSession() * @throws MarshallerNotFoundException * @throws UnmarshallingException */ - protected function instantiateBasicAdaptiveAssessmentItem() + protected function instantiateBasicAdaptiveAssessmentItem(): AssessmentItemSession { $itemRef = $this->createExtendedAssessmentItemRefFromXml(' diff --git a/test/qtismtest/QtiSmAssessmentTestSessionTestCase.php b/test/qtismtest/QtiSmAssessmentTestSessionTestCase.php index 2ac74c2b7..1d7972b84 100644 --- a/test/qtismtest/QtiSmAssessmentTestSessionTestCase.php +++ b/test/qtismtest/QtiSmAssessmentTestSessionTestCase.php @@ -31,7 +31,7 @@ public function tearDown(): void * @return AssessmentTestSession * @throws XmlStorageException */ - protected static function instantiate($url, $validate = false, $config = 0) + protected static function instantiate($url, $validate = false, $config = 0): AssessmentTestSession { $doc = new XmlCompactDocument(); $doc->load($url, $validate); diff --git a/test/qtismtest/QtiSmEnumTestCase.php b/test/qtismtest/QtiSmEnumTestCase.php index 4cd4f90fc..908a88732 100644 --- a/test/qtismtest/QtiSmEnumTestCase.php +++ b/test/qtismtest/QtiSmEnumTestCase.php @@ -17,7 +17,7 @@ public function tearDown(): void parent::tearDown(); } - public function testConsistency() + public function testConsistency(): void { $refCount = count($this->getNames()); @@ -25,7 +25,7 @@ public function testConsistency() $this::assertCount($refCount, $this->getKeys()); } - public function testAsArray() + public function testAsArray(): void { $enumerationName = $this->getEnumerationFqcn(); $array = $enumerationName::asArray(); @@ -39,7 +39,7 @@ public function testAsArray() } } - public function testGetConstantByName() + public function testGetConstantByName(): void { $names = $this->getNames(); $constants = $this->getConstants(); @@ -56,7 +56,7 @@ public function testGetConstantByName() $this::assertFalse($enumerationName::getConstantByName($this->getUnknownConstantName())); } - public function testGetNameByConstant() + public function testGetNameByConstant(): void { $names = $this->getNames(); $constants = $this->getConstants(); @@ -76,7 +76,7 @@ public function testGetNameByConstant() /** * @return string */ - protected function getUnknownConstantName() + protected function getUnknownConstantName(): string { return 'xyz'; } @@ -84,7 +84,7 @@ protected function getUnknownConstantName() /** * @return int */ - protected function getUnknownConstantValue() + protected function getUnknownConstantValue(): int { return PHP_INT_MAX; } diff --git a/test/qtismtest/QtiSmItemSubsetTestCase.php b/test/qtismtest/QtiSmItemSubsetTestCase.php index dabe7d3af..6640e2208 100644 --- a/test/qtismtest/QtiSmItemSubsetTestCase.php +++ b/test/qtismtest/QtiSmItemSubsetTestCase.php @@ -43,7 +43,7 @@ public function tearDown(): void * * @param AssessmentTestSession $testSession An instantiated AssessmentTestSession object in INTERACTING state. */ - protected function setTestSession(AssessmentTestSession $testSession) + protected function setTestSession(AssessmentTestSession $testSession): void { $this->testSession = $testSession; } @@ -53,7 +53,7 @@ protected function setTestSession(AssessmentTestSession $testSession) * * @return AssessmentTestSession An instantiated AssessmentTestSession object in INTERACTING state. */ - protected function getTestSession() + protected function getTestSession(): AssessmentTestSession { return $this->testSession; } diff --git a/test/qtismtest/QtiSmPhpMarshallerTestCase.php b/test/qtismtest/QtiSmPhpMarshallerTestCase.php index 01c9d74b3..c899df887 100644 --- a/test/qtismtest/QtiSmPhpMarshallerTestCase.php +++ b/test/qtismtest/QtiSmPhpMarshallerTestCase.php @@ -49,7 +49,7 @@ public function tearDown(): void /** * @return PhpMarshallingContext */ - public function createMarshallingContext() + public function createMarshallingContext(): PhpMarshallingContext { $ctx = new PhpMarshallingContext($this->getStreamAccess()); $ctx->setFormatOutput(true); @@ -59,7 +59,7 @@ public function createMarshallingContext() /** * @param MemoryStream $stream */ - protected function setStream(MemoryStream $stream) + protected function setStream(MemoryStream $stream): void { $this->stream = $stream; } @@ -67,7 +67,7 @@ protected function setStream(MemoryStream $stream) /** * @return MemoryStream */ - protected function getStream() + protected function getStream(): MemoryStream { return $this->stream; } @@ -75,7 +75,7 @@ protected function getStream() /** * @return PhpStreamAccess */ - protected function getStreamAccess() + protected function getStreamAccess(): PhpStreamAccess { return $this->streamAccess; } @@ -83,7 +83,7 @@ protected function getStreamAccess() /** * @param PhpStreamAccess $streamAccess */ - protected function setStreamAccess(PhpStreamAccess $streamAccess) + protected function setStreamAccess(PhpStreamAccess $streamAccess): void { $this->streamAccess = $streamAccess; } diff --git a/test/qtismtest/QtiSmRouteTestCase.php b/test/qtismtest/QtiSmRouteTestCase.php index 960efe825..beda6562e 100644 --- a/test/qtismtest/QtiSmRouteTestCase.php +++ b/test/qtismtest/QtiSmRouteTestCase.php @@ -45,7 +45,7 @@ public function tearDown(): void * @param int $itemCount * @return Route */ - public static function buildSimpleRoute($routeClass = Route::class, $testPartCount = 1, $itemCount = 3) + public static function buildSimpleRoute($routeClass = Route::class, $testPartCount = 1, $itemCount = 3): Route { $route = new $routeClass(); $assessmentTest = new AssessmentTest('test', 'A Test'); diff --git a/test/qtismtest/QtiSmTestCase.php b/test/qtismtest/QtiSmTestCase.php index d522667f9..aabb51f07 100644 --- a/test/qtismtest/QtiSmTestCase.php +++ b/test/qtismtest/QtiSmTestCase.php @@ -55,7 +55,7 @@ public function tearDown(): void * * @return FilesystemInterface */ - protected function getFileSystem() + protected function getFileSystem(): FilesystemInterface { return $this->fileSystem; } @@ -67,7 +67,7 @@ protected function getFileSystem() * * @param FilesystemInterface $filesystem */ - protected function setFileSystem(FilesystemInterface $filesystem) + protected function setFileSystem(FilesystemInterface $filesystem): void { $this->fileSystem = $filesystem; } @@ -79,7 +79,7 @@ protected function setFileSystem(FilesystemInterface $filesystem) * * @return FilesystemInterface */ - protected function getOutputFileSystem() + protected function getOutputFileSystem(): FilesystemInterface { return $this->outputFileSystem; } @@ -91,7 +91,7 @@ protected function getOutputFileSystem() * * @param FilesystemInterface $filesystem */ - protected function setOutputFileSystem(FilesystemInterface $filesystem) + protected function setOutputFileSystem(FilesystemInterface $filesystem): void { $this->outputFileSystem = $filesystem; } @@ -125,7 +125,7 @@ public static function assertFileDoesNotExist(string $filename, string $message * * @return string */ - public static function samplesDir() + public static function samplesDir(): string { return __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR; } @@ -136,7 +136,7 @@ public static function samplesDir() * @return string The path to the created directory. * @throws RuntimeException If the directory has not been created. */ - public static function tempDir() + public static function tempDir(): string { $tmpFile = tempnam(sys_get_temp_dir(), 'qsm'); @@ -160,7 +160,7 @@ public static function tempDir() * @param string $source The source file to be copied. * @return string The path to the copied file. */ - public static function tempCopy($source) + public static function tempCopy($source): string { $tmpFile = tempnam(sys_get_temp_dir(), 'qsm'); @@ -180,7 +180,7 @@ public static function tempCopy($source) * @param string $xmlString A string containing XML markup * @return DOMElement The according DOMElement; */ - public function createDOMElement($xmlString) + public function createDOMElement($xmlString): DOMElement { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML($xmlString); @@ -195,7 +195,7 @@ public function createDOMElement($xmlString) * @param string $tz A timezone name. * @return DateTime */ - public static function createDate($date, $tz = 'UTC') + public static function createDate($date, $tz = 'UTC'): DateTime { return DateTime::createFromFormat('Y-m-d H:i:s', $date, new DateTimeZone($tz)); } @@ -208,7 +208,7 @@ public static function createDate($date, $tz = 'UTC') * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createComponentFromXml($xmlString, $version = '2.1.0') + public function createComponentFromXml($xmlString, $version = '2.1.0'): QtiComponent { $element = $this->createDOMElement($xmlString); $factory = $this->getMarshallerFactory($version); diff --git a/test/qtismtest/common/beans/BeanMethodTest.php b/test/qtismtest/common/beans/BeanMethodTest.php index ede5dc300..da43bc1e7 100644 --- a/test/qtismtest/common/beans/BeanMethodTest.php +++ b/test/qtismtest/common/beans/BeanMethodTest.php @@ -13,7 +13,7 @@ */ class BeanMethodTest extends QtiSmTestCase { - public function testNoMethod() + public function testNoMethod(): void { $class = new ReflectionClass(SimpleBean::class); $this->expectException(BeanException::class); diff --git a/test/qtismtest/common/beans/BeanParameterTest.php b/test/qtismtest/common/beans/BeanParameterTest.php index 63a25bc7a..ebbb3727c 100644 --- a/test/qtismtest/common/beans/BeanParameterTest.php +++ b/test/qtismtest/common/beans/BeanParameterTest.php @@ -12,7 +12,7 @@ */ class BeanParameterTest extends QtiSmTestCase { - public function testNoParameter() + public function testNoParameter(): void { $this->expectException(BeanException::class); $this->expectExceptionMessage("No such parameter 'method' for method 'getMethod' of class 'stdClass'."); diff --git a/test/qtismtest/common/beans/BeanPropertyTest.php b/test/qtismtest/common/beans/BeanPropertyTest.php index 43572920e..c6a5ac453 100644 --- a/test/qtismtest/common/beans/BeanPropertyTest.php +++ b/test/qtismtest/common/beans/BeanPropertyTest.php @@ -13,7 +13,7 @@ */ class BeanPropertyTest extends QtiSmTestCase { - public function testNoProperty() + public function testNoProperty(): void { $this->expectException(BeanException::class); $this->expectExceptionMessage("The class property with name 'prop' does not exist in class 'stdClass'."); @@ -22,7 +22,7 @@ public function testNoProperty() $beanProperty = new BeanProperty(stdClass::class, 'prop'); } - public function testPropertyNotAnnotated() + public function testPropertyNotAnnotated(): void { $this->expectException(BeanException::class); $this->expectExceptionMessage("The property with name 'anotherUselessProperty' for class '" . SimpleBean::class . "' is not annotated."); diff --git a/test/qtismtest/common/beans/BeanTest.php b/test/qtismtest/common/beans/BeanTest.php index 5492faffe..b97d775f1 100644 --- a/test/qtismtest/common/beans/BeanTest.php +++ b/test/qtismtest/common/beans/BeanTest.php @@ -18,7 +18,7 @@ */ class BeanTest extends QtiSmTestCase { - public function testSimpleBean() + public function testSimpleBean(): void { $mock = new SimpleBean('Mister Bean', 'Mini Cooper'); $bean = new Bean($mock); @@ -152,7 +152,7 @@ public function testSimpleBean() } } - public function testNotStrictBeanBecauseOfConstructor() + public function testNotStrictBeanBecauseOfConstructor(): void { // must work in unstrict mode. $mock = new NotStrictConstructorBean('John', 'Dunbar', 'red'); @@ -167,7 +167,7 @@ public function testNotStrictBeanBecauseOfConstructor() } } - public function testNotStrictBeanBecauseOfMissingSetter() + public function testNotStrictBeanBecauseOfMissingSetter(): void { // must work if no strict mode. $mock = new NotStrictMissingSetterBean('John', 'Dunbar', 'brown'); @@ -182,7 +182,7 @@ public function testNotStrictBeanBecauseOfMissingSetter() } } - public function testStrictBean() + public function testStrictBean(): void { $mock = new StrictBean('John', 'Dunbar', 'blond', true); $bean = new Bean($mock, true); @@ -214,7 +214,7 @@ public function testStrictBean() $this::assertCount(0, $bean->getSetters(true)); } - public function testGetGetterByBeanProperty() + public function testGetGetterByBeanProperty(): void { $mock = new StrictBean('John', 'Dunbar', 'white', false); $bean = new Bean($mock, true); @@ -224,7 +224,7 @@ public function testGetGetterByBeanProperty() $this::assertEquals('isCool', $getter->getName()); } - public function testGetSetterByBeanProperty() + public function testGetSetterByBeanProperty(): void { $mock = new StrictBean('John', 'Dunbar', 'white', false); $bean = new Bean($mock, true); @@ -234,7 +234,7 @@ public function testGetSetterByBeanProperty() $this::assertEquals('setCool', $setter->getName()); } - public function testHasGetterByBeanProperty() + public function testHasGetterByBeanProperty(): void { $mock = new StrictBean('Mickael', 'Dundie', 'black', true); $bean = new Bean($mock); @@ -243,7 +243,7 @@ public function testHasGetterByBeanProperty() $this::assertNotFalse($bean->hasGetter($property)); } - public function testHasSetterByBeanProperty() + public function testHasSetterByBeanProperty(): void { $mock = new StrictBean('Mickael', 'Dundie', 'black', true); $bean = new Bean($mock); @@ -252,14 +252,14 @@ public function testHasSetterByBeanProperty() $this::assertTrue($bean->hasSetter($property)); } - public function testWrongInstanciation() + public function testWrongInstanciation(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The given 'object' argument is not an object."); new Bean(10); } - public function testInvalidGetGetterCall() + public function testInvalidGetGetterCall(): void { $mock = new StrictBean('John', 'Dunbar', 'white', false); $bean = new Bean($mock, true); @@ -270,7 +270,7 @@ public function testInvalidGetGetterCall() $getter = $bean->getGetter(null); } - public function testInvalidGetSetterCall() + public function testInvalidGetSetterCall(): void { $mock = new StrictBean('John', 'Dunbar', 'white', false); $bean = new Bean($mock, true); @@ -281,7 +281,7 @@ public function testInvalidGetSetterCall() $getter = $bean->getSetter(false); } - public function testUnknownSetter() + public function testUnknownSetter(): void { $mock = new StrictBean('John', 'Dunbar', 'white', false); $bean = new Bean($mock, true); @@ -293,7 +293,7 @@ public function testUnknownSetter() $getter = $bean->getSetter('melissa'); } - public function testInvalidHasGetterCall() + public function testInvalidHasGetterCall(): void { $mock = new StrictBean('John', 'Dunbar', 'white', false); $bean = new Bean($mock, true); @@ -304,7 +304,7 @@ public function testInvalidHasGetterCall() $getter = $bean->hasGetter(null); } - public function testInvalidHasSetterCall() + public function testInvalidHasSetterCall(): void { $mock = new StrictBean('John', 'Dunbar', 'white', false); $bean = new Bean($mock, true); @@ -315,7 +315,7 @@ public function testInvalidHasSetterCall() $getter = $bean->hasSetter(null); } - public function testPropertyButNoSetter() + public function testPropertyButNoSetter(): void { $mock = new SimpleBean('Name', 'Car'); $bean = new Bean($mock); diff --git a/test/qtismtest/common/beans/mocks/NotStrictConstructorBean.php b/test/qtismtest/common/beans/mocks/NotStrictConstructorBean.php index eee36a9de..ba34014dd 100644 --- a/test/qtismtest/common/beans/mocks/NotStrictConstructorBean.php +++ b/test/qtismtest/common/beans/mocks/NotStrictConstructorBean.php @@ -43,7 +43,7 @@ public function __construct($firstName, $lastName, $hairColor) /** * @param $firstName */ - public function setFirstName($firstName) + public function setFirstName($firstName): void { $this->firstName = $firstName; } @@ -51,7 +51,7 @@ public function setFirstName($firstName) /** * @return mixed */ - public function getFirstName() + public function getFirstName(): mixed { return $this->girstName; } @@ -60,15 +60,17 @@ public function getFirstName() * @param $lastName * @return string */ - public function setLastName($lastName) + public function setLastName($lastName): string { + $this->lastName = $lastName; + return $this->lastName; } /** * @return string */ - public function getLastName() + public function getLastName(): string { return $this->lastName; } @@ -76,7 +78,7 @@ public function getLastName() /** * @param $hair */ - public function setHair($hair) + public function setHair($hair): void { $this->hair = $hair; } @@ -84,7 +86,7 @@ public function setHair($hair) /** * @return string */ - public function getHair() + public function getHair(): string { return $this->hair; } diff --git a/test/qtismtest/common/beans/mocks/NotStrictMissingSetterBean.php b/test/qtismtest/common/beans/mocks/NotStrictMissingSetterBean.php index 8a5245b97..ac43fec96 100644 --- a/test/qtismtest/common/beans/mocks/NotStrictMissingSetterBean.php +++ b/test/qtismtest/common/beans/mocks/NotStrictMissingSetterBean.php @@ -42,7 +42,7 @@ public function __construct($firstName, $lastName, $hair) /** * @param $firstName */ - public function setFirstName($firstName) + public function setFirstName($firstName): void { $this->firstName = $firstName; } @@ -50,7 +50,7 @@ public function setFirstName($firstName) /** * @return mixed */ - public function getFirstName() + public function getFirstName(): mixed { return $this->girstName; } @@ -59,15 +59,17 @@ public function getFirstName() * @param $lastName * @return string */ - public function setLastName($lastName) + public function setLastName($lastName): string { + $this->lastName = $lastName; + return $this->lastName; } /** * @return string */ - public function getLastName() + public function getLastName(): string { return $this->lastName; } @@ -77,7 +79,7 @@ public function getLastName() * * @param string $hair */ - protected function setHair($hair) + protected function setHair($hair): void { $this->hair = $hair; } @@ -85,7 +87,7 @@ protected function setHair($hair) /** * @return string */ - public function getHair() + public function getHair(): string { return $this->hair; } diff --git a/test/qtismtest/common/beans/mocks/SimpleBean.php b/test/qtismtest/common/beans/mocks/SimpleBean.php index 936818725..4f9431286 100644 --- a/test/qtismtest/common/beans/mocks/SimpleBean.php +++ b/test/qtismtest/common/beans/mocks/SimpleBean.php @@ -63,7 +63,7 @@ public function __construct($name, $car, $uselessProperty = '') /** * @param $name */ - public function setName($name) + public function setName($name): void { $this->name = $name; } @@ -71,7 +71,7 @@ public function setName($name) /** * @return string */ - public function getName() + public function getName(): string { return $this->name; } @@ -79,7 +79,7 @@ public function getName() /** * @param $car */ - public function setCar($car) + public function setCar($car): void { $this->car = $car; } @@ -87,7 +87,7 @@ public function setCar($car) /** * @return string */ - public function getCar() + public function getCar(): string { return $this->car; } @@ -95,7 +95,7 @@ public function getCar() /** * @param $uselessProperty */ - public function setUselessProperty($uselessProperty) + public function setUselessProperty($uselessProperty): void { $this->uselessProperty = $uselessProperty; } @@ -103,7 +103,7 @@ public function setUselessProperty($uselessProperty) /** * @return string */ - public function getUselessProperty() + public function getUselessProperty(): string { return $this->uselessProperty; } @@ -111,7 +111,7 @@ public function getUselessProperty() /** * @param $anotherUselessProperty */ - private function setAnotherUselessProperty($anotherUselessProperty) + private function setAnotherUselessProperty($anotherUselessProperty): void { $this->anotherUselessProperty = $anotherUselessProperty; } @@ -119,7 +119,7 @@ private function setAnotherUselessProperty($anotherUselessProperty) /** * @return string */ - public function getAnotherUselessProperty() + public function getAnotherUselessProperty(): string { return $this->anotherUselessProperty; } diff --git a/test/qtismtest/common/beans/mocks/StrictBean.php b/test/qtismtest/common/beans/mocks/StrictBean.php index fbe72ae43..26c4baf2b 100644 --- a/test/qtismtest/common/beans/mocks/StrictBean.php +++ b/test/qtismtest/common/beans/mocks/StrictBean.php @@ -50,7 +50,7 @@ public function __construct($firstName, $lastName, $hair, $cool) /** * @param $firstName */ - public function setFirstName($firstName) + public function setFirstName($firstName): void { $this->firstName = $firstName; } @@ -58,7 +58,7 @@ public function setFirstName($firstName) /** * @return mixed */ - public function getFirstName() + public function getFirstName(): mixed { return $this->girstName; } @@ -67,15 +67,17 @@ public function getFirstName() * @param $lastName * @return string */ - public function setLastName($lastName) + public function setLastName($lastName): string { + $this->lastName = $lastName; + return $this->lastName; } /** * @return string */ - public function getLastName() + public function getLastName(): string { return $this->lastName; } @@ -83,7 +85,7 @@ public function getLastName() /** * @param $hair */ - public function setHair($hair) + public function setHair($hair): void { $this->hair = $hair; } @@ -91,7 +93,7 @@ public function setHair($hair) /** * @return string */ - public function getHair() + public function getHair(): string { return $this->hair; } @@ -99,7 +101,7 @@ public function getHair() /** * @param $cool */ - public function setCool($cool) + public function setCool($cool): void { $this->cool = $cool; } @@ -107,7 +109,7 @@ public function setCool($cool) /** * @return bool */ - public function isCool() + public function isCool(): bool { return $this->cool; } diff --git a/test/qtismtest/common/collections/IdentifierCollectionTest.php b/test/qtismtest/common/collections/IdentifierCollectionTest.php index 9889ba092..d559c7085 100644 --- a/test/qtismtest/common/collections/IdentifierCollectionTest.php +++ b/test/qtismtest/common/collections/IdentifierCollectionTest.php @@ -30,7 +30,7 @@ public function tearDown(): void unset($this->collection); } - public function testAddIdentifier() + public function testAddIdentifier(): void { $string = 'foobar'; $this->collection[] = $string; @@ -41,7 +41,7 @@ public function testAddIdentifier() /** * @depends testAddIdentifier */ - public function testRemoveIdentifier() + public function testRemoveIdentifier(): void { $string = 'foobar'; $this->collection[] = $string; @@ -52,7 +52,7 @@ public function testRemoveIdentifier() /** * @depends testAddIdentifier */ - public function testModifyIdentifier() + public function testModifyIdentifier(): void { $string = 'foobar'; $this->collection[] = $string; @@ -61,21 +61,21 @@ public function testModifyIdentifier() $this::assertNotEquals($this->collection[0], $string); } - public function testAddIdentifierWrongFormat() + public function testAddIdentifierWrongFormat(): void { $identifier = '.identifier'; $this->expectException(InvalidArgumentException::class); $this->collection[] = $identifier; } - public function testAddIdentifierWrongType() + public function testAddIdentifierWrongType(): void { $identifier = 999; $this->expectException(InvalidArgumentException::class); $this->collection[] = $identifier; } - public function testToString() + public function testToString(): void { $this->collection[] = 'one'; $this::assertEquals('one', $this->collection->__toString()); diff --git a/test/qtismtest/common/collections/StringCollectionTest.php b/test/qtismtest/common/collections/StringCollectionTest.php index 76ffa8723..1813b92a4 100644 --- a/test/qtismtest/common/collections/StringCollectionTest.php +++ b/test/qtismtest/common/collections/StringCollectionTest.php @@ -30,7 +30,7 @@ public function tearDown(): void unset($this->collection); } - public function testAddString() + public function testAddString(): void { $string = 'foobar'; $this->collection[] = $string; @@ -41,7 +41,7 @@ public function testAddString() /** * @depends testAddString */ - public function testRemoveString() + public function testRemoveString(): void { $string = 'foobar'; $this->collection[] = $string; @@ -52,7 +52,7 @@ public function testRemoveString() /** * @depends testAddString */ - public function testModifyString() + public function testModifyString(): void { $string = 'foobar'; $this->collection[] = $string; @@ -61,14 +61,14 @@ public function testModifyString() $this::assertNotEquals($this->collection[0], $string); } - public function testAddStringWrongType() + public function testAddStringWrongType(): void { $int = 1; $this->expectException(InvalidArgumentException::class); $this->collection[] = $int; } - public function testForeachable() + public function testForeachable(): void { $a = ['string1', 'string2', 'string3']; foreach ($a as $s) { @@ -103,14 +103,14 @@ public function testForeachable() $this::assertEquals(3, $i); } - public function testAttachNotObject() + public function testAttachNotObject(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("You can only attach 'objects' into an AbstractCollection, 'string' given"); $this->collection->attach('string'); } - public function testResetKeys() + public function testResetKeys(): void { $this->collection[] = 'string1'; $this->collection[] = 'string2'; diff --git a/test/qtismtest/common/datatypes/BooleanTest.php b/test/qtismtest/common/datatypes/BooleanTest.php index b24ac7687..da04cf5ee 100644 --- a/test/qtismtest/common/datatypes/BooleanTest.php +++ b/test/qtismtest/common/datatypes/BooleanTest.php @@ -11,13 +11,13 @@ */ class BooleanTest extends QtiSmTestCase { - public function testWrongValue() + public function testWrongValue(): void { $this->expectException(InvalidArgumentException::class); $boolean = new QtiBoolean('string'); } - public function testClone() + public function testClone(): void { $boolean = new QtiBoolean(true); $otherBoolean = clone $boolean; diff --git a/test/qtismtest/common/datatypes/CoordsTest.php b/test/qtismtest/common/datatypes/CoordsTest.php index d11b8818c..db8b6f2a2 100644 --- a/test/qtismtest/common/datatypes/CoordsTest.php +++ b/test/qtismtest/common/datatypes/CoordsTest.php @@ -14,14 +14,14 @@ */ class CoordsTest extends QtiSmTestCase { - public function testInstantiate() + public function testInstantiate(): void { $coords = new QtiCoords(QtiShape::POLY, [0, 0, 0, 3, 3, 0]); $this::assertEquals(BaseType::COORDS, $coords->getBaseType()); $this::assertEquals(Cardinality::SINGLE, $coords->getCardinality()); } - public function testInsideCircle() + public function testInsideCircle(): void { $coords = new QtiCoords(QtiShape::CIRCLE, [5, 5, 5]); @@ -38,7 +38,7 @@ public function testInsideCircle() $this::assertFalse($coords->inside($point)); } - public function testInsideEllipse() + public function testInsideEllipse(): void { $coords = new QtiCoords(QtiShape::ELLIPSE, [10, 10, 3, 2]); @@ -55,7 +55,7 @@ public function testInsideEllipse() $this::assertTrue($coords->inside($point)); } - public function testInsideRectangle() + public function testInsideRectangle(): void { // Do not forget (x1, y1) -> left top corner, (x2, y2) -> right bottom corner. $coords = new QtiCoords(QtiShape::RECT, [0, 0, 5, 3]); @@ -76,7 +76,7 @@ public function testInsideRectangle() $this::assertFalse($coords->inside($point)); } - public function testInsidePolygon() + public function testInsidePolygon(): void { $coords = new QtiCoords(QtiShape::POLY, [0, 8, 7, 4, 2, 2, 8, -4, -2, 1]); @@ -102,14 +102,14 @@ public function testInsidePolygon() $this::assertFalse($coords->inside($point)); } - public function testOnEdgePolygon() + public function testOnEdgePolygon(): void { $coords = new QtiCoords(QtiShape::POLY, [0, 0, 0, 3, 3, 0]); $point = new QtiPoint(0, 2); $this::assertTrue($coords->inside($point)); } - public function testInsideDefault() + public function testInsideDefault(): void { // always true. $coords = new QtiCoords(QtiShape::DEF); diff --git a/test/qtismtest/common/datatypes/DatatypeUtilsTest.php b/test/qtismtest/common/datatypes/DatatypeUtilsTest.php index 5e4ec6537..7c9b46182 100644 --- a/test/qtismtest/common/datatypes/DatatypeUtilsTest.php +++ b/test/qtismtest/common/datatypes/DatatypeUtilsTest.php @@ -14,7 +14,7 @@ class DatatypeUtilsTest extends QtiSmTestCase * @dataProvider isQtiIntegerValidProvider * @param int $value */ - public function testIsQtiIntegerValid($value) + public function testIsQtiIntegerValid($value): void { $this::assertTrue(Utils::isQtiInteger($value)); } @@ -23,7 +23,7 @@ public function testIsQtiIntegerValid($value) * @dataProvider isQtiIntegerInvalidProvider * @param int $value */ - public function testIsQtiIntegerInvalid($value) + public function testIsQtiIntegerInvalid($value): void { $this::assertFalse(Utils::isQtiInteger($value)); } @@ -31,7 +31,7 @@ public function testIsQtiIntegerInvalid($value) /** * @return array */ - public function isQtiIntegerValidProvider() + public function isQtiIntegerValidProvider(): array { return [ [0], @@ -46,7 +46,7 @@ public function isQtiIntegerValidProvider() /** * @return array */ - public function isQtiIntegerInvalidProvider() + public function isQtiIntegerInvalidProvider(): array { return [ [null], diff --git a/test/qtismtest/common/datatypes/DirectedPairTest.php b/test/qtismtest/common/datatypes/DirectedPairTest.php index c667252d6..299f79f14 100644 --- a/test/qtismtest/common/datatypes/DirectedPairTest.php +++ b/test/qtismtest/common/datatypes/DirectedPairTest.php @@ -11,7 +11,7 @@ */ class DirectedPairTest extends QtiSmTestCase { - public function testEquality() + public function testEquality(): void { $p1 = new QtiDirectedPair('A', 'B'); $p2 = new QtiDirectedPair('A', 'B'); diff --git a/test/qtismtest/common/datatypes/DurationTest.php b/test/qtismtest/common/datatypes/DurationTest.php index 228a22a8b..4f15cf527 100644 --- a/test/qtismtest/common/datatypes/DurationTest.php +++ b/test/qtismtest/common/datatypes/DurationTest.php @@ -16,7 +16,7 @@ class DurationTest extends QtiSmTestCase * @dataProvider validDurationProvider * @param string $intervalSpec */ - public function testValidDurationCreation($intervalSpec) + public function testValidDurationCreation($intervalSpec): void { $duration = new QtiDuration($intervalSpec); $this::assertInstanceOf(QtiDuration::class, $duration); @@ -26,13 +26,13 @@ public function testValidDurationCreation($intervalSpec) * @dataProvider invalidDurationProvider * @param string $intervalSpec */ - public function testInvalidDurationCreation($intervalSpec) + public function testInvalidDurationCreation($intervalSpec): void { $this->expectException(InvalidArgumentException::class); $duration = new QtiDuration($intervalSpec); } - public function testPositiveDuration() + public function testPositiveDuration(): void { $duration = new QtiDuration('P3YT6H8M'); // 2 years, 0 days, 6 hours, 8 minutes. $this::assertEquals(3, $duration->getYears()); @@ -43,7 +43,7 @@ public function testPositiveDuration() $this::assertEquals(0, $duration->getSeconds()); } - public function testEquality() + public function testEquality(): void { $d1 = new QtiDuration('P1DT12H'); // 1 day + 12 hours. $d2 = new QtiDuration('P1DT12H'); @@ -56,7 +56,7 @@ public function testEquality() $this::assertTrue($d3->equals($d3)); } - public function testClone() + public function testClone(): void { $d = new QtiDuration('P1DT12H'); // 1 day + 12 hours. $c = clone $d; @@ -76,12 +76,12 @@ public function testClone() * @param QtiDuration $duration * @param string $expected */ - public function testToString(QtiDuration $duration, $expected) + public function testToString(QtiDuration $duration, $expected): void { $this::assertEquals($expected, $duration->__toString()); } - public function testAdd() + public function testAdd(): void { $d1 = new QtiDuration('PT1S'); $d2 = new QtiDuration('PT1S'); @@ -99,7 +99,7 @@ public function testAdd() $this::assertEquals('PT2S', $d1->__toString()); } - public function testSub() + public function testSub(): void { $d1 = new QtiDuration('PT2S'); $d2 = new QtiDuration('PT1S'); @@ -127,7 +127,7 @@ public function testSub() $this::assertTrue($d1->isNegative()); } - public function testCreateFromDateInterval() + public function testCreateFromDateInterval(): void { $interval = new DateInterval('PT5S'); $duration = QtiDuration::createFromDateInterval($interval); @@ -141,7 +141,7 @@ public function testCreateFromDateInterval() * @param QtiDuration $duration2 * @param bool $expected */ - public function testShorterThan(QtiDuration $duration1, QtiDuration $duration2, $expected) + public function testShorterThan(QtiDuration $duration1, QtiDuration $duration2, $expected): void { $this::assertSame($expected, $duration1->shorterThan($duration2)); } @@ -149,7 +149,7 @@ public function testShorterThan(QtiDuration $duration1, QtiDuration $duration2, /** * @return array */ - public function shorterThanProvider() + public function shorterThanProvider(): array { $returnValue = []; $returnValue[] = [new QtiDuration('P1Y'), new QtiDuration('P2Y'), true]; @@ -170,7 +170,7 @@ public function shorterThanProvider() * @param QtiDuration $duration2 * @param bool $expected */ - public function testLongerThanOrEquals(QtiDuration $duration1, QtiDuration $duration2, $expected) + public function testLongerThanOrEquals(QtiDuration $duration1, QtiDuration $duration2, $expected): void { $this::assertSame($expected, $duration1->longerThanOrEquals($duration2)); } @@ -178,7 +178,7 @@ public function testLongerThanOrEquals(QtiDuration $duration1, QtiDuration $dura /** * @return array */ - public function longerThanOrEqualsProvider() + public function longerThanOrEqualsProvider(): array { $returnValue = []; $returnValue[] = [new QtiDuration('P1Y'), new QtiDuration('P2Y'), false]; @@ -201,7 +201,7 @@ public function longerThanOrEqualsProvider() /** * @return array */ - public function validDurationProvider() + public function validDurationProvider(): array { return [ ['P2D'], // 2 days @@ -213,7 +213,7 @@ public function validDurationProvider() /** * @return array */ - public function invalidDurationProvider() + public function invalidDurationProvider(): array { return [ ['D2P'], @@ -226,7 +226,7 @@ public function invalidDurationProvider() /** * @return array */ - public function toStringProvider() + public function toStringProvider(): array { return [ [new QtiDuration('P2D'), 'P2D'], // 2 days diff --git a/test/qtismtest/common/datatypes/FloatTest.php b/test/qtismtest/common/datatypes/FloatTest.php index 3d3092e69..b12a573e0 100644 --- a/test/qtismtest/common/datatypes/FloatTest.php +++ b/test/qtismtest/common/datatypes/FloatTest.php @@ -11,7 +11,7 @@ */ class FloatTest extends QtiSmTestCase { - public function testWrongValue() + public function testWrongValue(): void { $this->expectException(InvalidArgumentException::class); $float = new QtiFloat(null); diff --git a/test/qtismtest/common/datatypes/IdentifierTest.php b/test/qtismtest/common/datatypes/IdentifierTest.php index 03263eeaa..ed18932bb 100644 --- a/test/qtismtest/common/datatypes/IdentifierTest.php +++ b/test/qtismtest/common/datatypes/IdentifierTest.php @@ -11,14 +11,14 @@ */ class IdentifierTest extends QtiSmTestCase { - public function testWrongValue() + public function testWrongValue(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The Identifier Datatype only accepts to store identifier values.'); $float = new QtiIdentifier(1337); } - public function testEmptyIdentifier() + public function testEmptyIdentifier(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The Identifier Datatype do not accept empty strings as valid identifiers.'); diff --git a/test/qtismtest/common/datatypes/IntOrIdentifierTest.php b/test/qtismtest/common/datatypes/IntOrIdentifierTest.php index bb7b6e8b6..2a776d541 100644 --- a/test/qtismtest/common/datatypes/IntOrIdentifierTest.php +++ b/test/qtismtest/common/datatypes/IntOrIdentifierTest.php @@ -11,7 +11,7 @@ */ class IntOrIdentifierTest extends QtiSmTestCase { - public function testWrongValue() + public function testWrongValue(): void { $this->expectException(InvalidArgumentException::class); $intOrIdentifier = new QtiIntOrIdentifier(13.37); diff --git a/test/qtismtest/common/datatypes/IntegerTest.php b/test/qtismtest/common/datatypes/IntegerTest.php index cdb5f3011..0d1828a72 100644 --- a/test/qtismtest/common/datatypes/IntegerTest.php +++ b/test/qtismtest/common/datatypes/IntegerTest.php @@ -11,7 +11,7 @@ */ class IntegerTest extends QtiSmTestCase { - public function testWrongValue() + public function testWrongValue(): void { $this->expectException(InvalidArgumentException::class); $integer = new QtiInteger(13.37); diff --git a/test/qtismtest/common/datatypes/PairTest.php b/test/qtismtest/common/datatypes/PairTest.php index 24cd6978d..d971b76d0 100644 --- a/test/qtismtest/common/datatypes/PairTest.php +++ b/test/qtismtest/common/datatypes/PairTest.php @@ -11,7 +11,7 @@ */ class PairTest extends QtiSmTestCase { - public function testEquality() + public function testEquality(): void { $p1 = new QtiPair('A', 'B'); $p2 = new QtiPair('A', 'B'); @@ -27,13 +27,13 @@ public function testEquality() $this::assertTrue($p4->equals($p3)); } - public function testInvalidFirstIdentifier() + public function testInvalidFirstIdentifier(): void { $this->expectException(InvalidArgumentException::class); $pair = new QtiPair('_33', '33tt'); } - public function testInvalidSecondIdentifier() + public function testInvalidSecondIdentifier(): void { $this->expectException(InvalidArgumentException::class); $pair = new QtiPair('33tt', '_33'); diff --git a/test/qtismtest/common/datatypes/PointTest.php b/test/qtismtest/common/datatypes/PointTest.php index c7c2e2dfa..48a2343be 100644 --- a/test/qtismtest/common/datatypes/PointTest.php +++ b/test/qtismtest/common/datatypes/PointTest.php @@ -10,7 +10,7 @@ */ class PointTest extends QtiSmTestCase { - public function testEquality() + public function testEquality(): void { $p1 = new QtiPoint(10, 10); $p2 = new QtiPoint(10, 10); diff --git a/test/qtismtest/common/datatypes/ShapeTest.php b/test/qtismtest/common/datatypes/ShapeTest.php index 6d59c68cd..2f9eba7d2 100644 --- a/test/qtismtest/common/datatypes/ShapeTest.php +++ b/test/qtismtest/common/datatypes/ShapeTest.php @@ -13,7 +13,7 @@ class ShapeTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return QtiShape::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'default', @@ -35,7 +35,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'DEF', @@ -49,7 +49,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ QtiShape::DEF, diff --git a/test/qtismtest/common/datatypes/StringTest.php b/test/qtismtest/common/datatypes/StringTest.php index b6c999a22..5e6cfa159 100644 --- a/test/qtismtest/common/datatypes/StringTest.php +++ b/test/qtismtest/common/datatypes/StringTest.php @@ -11,14 +11,14 @@ */ class StringTest extends QtiSmTestCase { - public function testWrongValue() + public function testWrongValue(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The String Datatype only accepts to store string values.'); $string = new QtiString(1337); } - public function testEmptyString() + public function testEmptyString(): void { $string = new QtiString(''); $this::assertEquals('', $string->getValue()); @@ -30,7 +30,7 @@ public function testEmptyString() * @param string $str * @param mixed $val */ - public function testEqual($str, $val) + public function testEqual($str, $val): void { $qtiString = new QtiString($str); $this::assertTrue($qtiString->equals($val)); @@ -39,7 +39,7 @@ public function testEqual($str, $val) /** * @return array */ - public function equalProvider() + public function equalProvider(): array { return [ ['', null], @@ -56,7 +56,7 @@ public function equalProvider() * @param string $str * @param mixed $val */ - public function testNotEqual($str, $val) + public function testNotEqual($str, $val): void { $qtiString = new QtiString($str); $this::assertFalse($qtiString->equals($val)); @@ -65,7 +65,7 @@ public function testNotEqual($str, $val) /** * @return array */ - public function notEqualProvider() + public function notEqualProvider(): array { return [ ['test', null], diff --git a/test/qtismtest/common/datatypes/UtilsTest.php b/test/qtismtest/common/datatypes/UtilsTest.php index 03a5eeae1..8f5d671f5 100644 --- a/test/qtismtest/common/datatypes/UtilsTest.php +++ b/test/qtismtest/common/datatypes/UtilsTest.php @@ -36,7 +36,7 @@ class UtilsTest extends TestCase * @param mixed $integer integer to test * @param bool test result */ - public function testIsQtiInteger($integer, $expected) + public function testIsQtiInteger($integer, $expected): void { $this::assertEquals($expected, Utils::isQtiInteger($integer)); } @@ -62,7 +62,7 @@ public function integersToTest(): array * @param string $string * @param string $normalizedString */ - public function testNormalizeString($string, $normalizedString) + public function testNormalizeString($string, $normalizedString): void { $this::assertEquals($normalizedString, Utils::normalizeString($string)); } @@ -70,7 +70,7 @@ public function testNormalizeString($string, $normalizedString) /** * @return array */ - public function stringsToNormalize() + public function stringsToNormalize(): array { return [ [ diff --git a/test/qtismtest/common/datatypes/files/FileSystemFileManagerTest.php b/test/qtismtest/common/datatypes/files/FileSystemFileManagerTest.php index 84a2f2000..60a94013d 100644 --- a/test/qtismtest/common/datatypes/files/FileSystemFileManagerTest.php +++ b/test/qtismtest/common/datatypes/files/FileSystemFileManagerTest.php @@ -11,7 +11,7 @@ */ class FileSystemFileManagerTest extends QtiSmTestCase { - public function testCreateFromFile() + public function testCreateFromFile(): void { $manager = new FileSystemFileManager(); $mFile = $manager->createFromFile(self::samplesDir() . 'datatypes/file/raw/text.txt', 'text/plain', 'newname.txt'); @@ -26,7 +26,7 @@ public function testCreateFromFile() unlink($mFile->getPath()); } - public function testCreateFromData() + public function testCreateFromData(): void { $manager = new FileSystemFileManager(); $file = $manager->createFromData('Some text...', 'text/html'); @@ -40,7 +40,7 @@ public function testCreateFromData() /** * @depends testCreateFromFile */ - public function testCreateFromFileError() + public function testCreateFromFileError(): void { $manager = new FileSystemFileManager('/root'); @@ -50,7 +50,7 @@ public function testCreateFromFileError() $manager->createFromFile(self::samplesDir() . 'datatypes/file/raw/text.txt', 'text/plain', 'newname.txt'); } - public function testCreateFromDataError() + public function testCreateFromDataError(): void { $manager = new FileSystemFileManager('/root'); @@ -60,7 +60,7 @@ public function testCreateFromDataError() $manager->createFromData('Some text...', 'text/html'); } - public function testDelete() + public function testDelete(): void { $manager = new FileSystemFileManager(); $mFile = $manager->createFromFile(self::samplesDir() . 'datatypes/file/raw/text.txt', 'text/plain', 'newname.txt'); @@ -74,7 +74,7 @@ public function testDelete() * @depends testDelete * @depends testCreateFromFile */ - public function testRetrieve() + public function testRetrieve(): void { $manager = new FileSystemFileManager(); $mFile = $manager->createFromFile(self::samplesDir() . 'datatypes/file/raw/text.txt', 'text/plain', 'newname.txt'); @@ -88,7 +88,7 @@ public function testRetrieve() /** * @depends testRetrieve */ - public function testRetrieveError() + public function testRetrieveError(): void { $manager = new FileSystemFileManager(); $mFile = $manager->createFromFile(self::samplesDir() . 'datatypes/file/raw/text.txt', 'text/plain', 'newname.txt'); @@ -103,7 +103,7 @@ public function testRetrieveError() /** * @depends testDelete */ - public function testDeleteError() + public function testDeleteError(): void { $manager = new FileSystemFileManager(); $mFile = $manager->createFromFile(self::samplesDir() . 'datatypes/file/raw/text.txt', 'text/plain', 'newname.txt'); diff --git a/test/qtismtest/common/datatypes/files/FileSystemFileTest.php b/test/qtismtest/common/datatypes/files/FileSystemFileTest.php index 5268150cc..dbe0076ae 100644 --- a/test/qtismtest/common/datatypes/files/FileSystemFileTest.php +++ b/test/qtismtest/common/datatypes/files/FileSystemFileTest.php @@ -20,7 +20,7 @@ class FileSystemFileTest extends QtiSmTestCase * @param string $expectedMimeType * @param string $expectedData */ - public function testRetrieve($path, $expectedFilename, $expectedMimeType, $expectedData) + public function testRetrieve($path, $expectedFilename, $expectedMimeType, $expectedData): void { $pFile = FileSystemFile::retrieveFile($path); $this::assertEquals($expectedFilename, $pFile->getFilename()); @@ -35,7 +35,7 @@ public function testRetrieve($path, $expectedFilename, $expectedMimeType, $expec * @param string $mimeType * @param bool|string $withFilename */ - public function testCreateFromExistingFile($source, $mimeType, $withFilename = true) + public function testCreateFromExistingFile($source, $mimeType, $withFilename = true): void { $destination = tempnam('/tmp', 'qtism'); $pFile = FileSystemFile::createFromExistingFile($source, $destination, $mimeType, $withFilename); @@ -56,7 +56,7 @@ public function testCreateFromExistingFile($source, $mimeType, $withFilename = t unlink($destination); } - public function testCreateFromExistingFileMalformedDestinationPath() + public function testCreateFromExistingFileMalformedDestinationPath(): void { try { FileSystemFile::createFromExistingFile( @@ -71,7 +71,7 @@ public function testCreateFromExistingFileMalformedDestinationPath() } } - public function testCreateFromExistingFileMalformedDestinationPathTwo() + public function testCreateFromExistingFileMalformedDestinationPathTwo(): void { try { FileSystemFile::createFromExistingFile( @@ -84,7 +84,7 @@ public function testCreateFromExistingFileMalformedDestinationPathTwo() } } - public function testCreateFromExistingFileSourceIsNotAFile() + public function testCreateFromExistingFileSourceIsNotAFile(): void { try { FileSystemFile::createFromExistingFile( @@ -105,7 +105,7 @@ public function testCreateFromExistingFileSourceIsNotAFile() * @param string $path * @param string $expectedData */ - public function testGetStream($path, $expectedData) + public function testGetStream($path, $expectedData): void { $pFile = FileSystemFile::retrieveFile($path); $stream = $pFile->getStream(); @@ -121,7 +121,7 @@ public function testGetStream($path, $expectedData) $this::assertEquals($expectedData, $data); } - public function testGetStreamError() + public function testGetStreamError(): void { $path = tempnam(sys_get_temp_dir(), 'qtism'); file_put_contents( @@ -140,7 +140,7 @@ public function testGetStreamError() } } - public function testInstantiationWrongPath() + public function testInstantiationWrongPath(): void { $this->expectException(RuntimeException::class); new FileSystemFile('/qtism/test'); @@ -149,7 +149,7 @@ public function testInstantiationWrongPath() /** * @return array */ - public function retrieveProvider() + public function retrieveProvider(): array { return [ [self::samplesDir() . 'datatypes/file/text-plain_name.txt', 'yours.txt', 'text/plain', ''], @@ -161,7 +161,7 @@ public function retrieveProvider() /** * @return array */ - public function getStreamProvider() + public function getStreamProvider(): array { return [ [self::samplesDir() . 'datatypes/file/text-plain_name.txt', ''], @@ -173,7 +173,7 @@ public function getStreamProvider() /** * @return array */ - public function createFromExistingFileProvider() + public function createFromExistingFileProvider(): array { return [ [self::samplesDir() . 'datatypes/file/raw/text.txt', 'text/plain', true], @@ -181,7 +181,7 @@ public function createFromExistingFileProvider() ]; } - public function testEqualsNonQtiFile() + public function testEqualsNonQtiFile(): void { $destination = tempnam('/tmp', 'qtism'); $pFile = FileSystemFile::createFromExistingFile( @@ -193,7 +193,7 @@ public function testEqualsNonQtiFile() @unlink($destination); } - public function testEqualsMimeTypeDifference() + public function testEqualsMimeTypeDifference(): void { $destination1 = tempnam('/tmp', 'qtism'); $pFile1 = FileSystemFile::createFromExistingFile( diff --git a/test/qtismtest/common/dom/SerializableDomDocumentTest.php b/test/qtismtest/common/dom/SerializableDomDocumentTest.php index 20668ba36..8e66f0e56 100644 --- a/test/qtismtest/common/dom/SerializableDomDocumentTest.php +++ b/test/qtismtest/common/dom/SerializableDomDocumentTest.php @@ -11,7 +11,7 @@ */ class SerializableDomDocumentTest extends QtiSmTestCase { - public function testSerialization() + public function testSerialization(): void { $ser = serialize($this->getSerializableDomDocument()); $dom = unserialize($ser); @@ -20,7 +20,7 @@ public function testSerialization() } - public function testAccessingProperty() + public function testAccessingProperty(): void { $xmlVersion = '1.0'; $dom = $this->getSerializableDomDocument($xmlVersion); @@ -29,7 +29,7 @@ public function testAccessingProperty() $this->assertEquals($xmlVersion, $dom->xmlVersion); } - public function testAccessingInexistentProperty() + public function testAccessingInexistentProperty(): void { $dom = $this->getSerializableDomDocument(); $property = 'test'; @@ -42,7 +42,7 @@ public function testAccessingInexistentProperty() $dom->$property; } - public function testSettingVirtualPropertyToDom() + public function testSettingVirtualPropertyToDom(): void { $xmlVersion = '1.0'; $dom = $this->getSerializableDomDocument($xmlVersion); @@ -53,14 +53,14 @@ public function testSettingVirtualPropertyToDom() $this->assertEquals('1.1', $dom->xmlVersion); } - public function testCheckingIfPropertyExists() + public function testCheckingIfPropertyExists(): void { $dom = $this->getSerializableDomDocument(); $this->assertTrue(isset($dom->xmlVersion)); } - public function testCallingVirtualMethods() + public function testCallingVirtualMethods(): void { $dom = $this->getSerializableDomDocument(); @@ -68,7 +68,7 @@ public function testCallingVirtualMethods() $this->assertNotEmpty((string)$dom); } - public function testCallingNotExistedVirtualMethods() + public function testCallingNotExistedVirtualMethods(): void { $dom = $this->getSerializableDomDocument(); $method = 'saveXML2'; @@ -81,7 +81,7 @@ public function testCallingNotExistedVirtualMethods() $dom->$method(); } - public function testCheckThatUnsetIsWorkingSimilarToRealDomObject() + public function testCheckThatUnsetIsWorkingSimilarToRealDomObject(): void { $serializableDOM = $this->getSerializableDomDocument(); $coreDom = new DOMDocument($serializableDOM->xmlVersion, $serializableDOM->encoding); diff --git a/test/qtismtest/common/enums/BaseTypeTest.php b/test/qtismtest/common/enums/BaseTypeTest.php index 666c2b553..c8934d926 100644 --- a/test/qtismtest/common/enums/BaseTypeTest.php +++ b/test/qtismtest/common/enums/BaseTypeTest.php @@ -13,7 +13,7 @@ class BaseTypeTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return BaseType::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'identifier', @@ -43,7 +43,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'IDENTIFIER', @@ -65,7 +65,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ BaseType::IDENTIFIER, diff --git a/test/qtismtest/common/enums/CardinalityTest.php b/test/qtismtest/common/enums/CardinalityTest.php index 74c517659..6aa368260 100644 --- a/test/qtismtest/common/enums/CardinalityTest.php +++ b/test/qtismtest/common/enums/CardinalityTest.php @@ -13,7 +13,7 @@ class CardinalityTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return Cardinality::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'single', @@ -34,7 +34,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'SINGLE', @@ -47,7 +47,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ Cardinality::SINGLE, diff --git a/test/qtismtest/common/utils/ArraysTest.php b/test/qtismtest/common/utils/ArraysTest.php index 27ca16d62..c2e021871 100644 --- a/test/qtismtest/common/utils/ArraysTest.php +++ b/test/qtismtest/common/utils/ArraysTest.php @@ -14,7 +14,7 @@ class ArraysTest extends QtiSmTestCase * @dataProvider isAssocValidProvider * @param array $array */ - public function testIsAssocValid(array $array) + public function testIsAssocValid(array $array): void { $this::assertTrue(Arrays::isAssoc($array)); } @@ -23,7 +23,7 @@ public function testIsAssocValid(array $array) * @dataProvider isAssocInvalidProvider * @param array $array */ - public function testIsAssocInvalid(array $array) + public function testIsAssocInvalid(array $array): void { $this::assertFalse(Arrays::isAssoc($array)); } @@ -31,7 +31,7 @@ public function testIsAssocInvalid(array $array) /** * @return array */ - public function isAssocValidProvider() + public function isAssocValidProvider(): array { return [ [['test' => 0, 'bli' => 2]], @@ -41,7 +41,7 @@ public function isAssocValidProvider() /** * @return array */ - public function isAssocInvalidProvider() + public function isAssocInvalidProvider(): array { return [ [[0, 1]], diff --git a/test/qtismtest/common/utils/ExceptionTest.php b/test/qtismtest/common/utils/ExceptionTest.php index 03cb1cd76..2709257d6 100644 --- a/test/qtismtest/common/utils/ExceptionTest.php +++ b/test/qtismtest/common/utils/ExceptionTest.php @@ -11,7 +11,7 @@ */ class ExceptionTest extends QtiSmTestCase { - public function testNoChaining() + public function testNoChaining(): void { $e = new Exception('This is an error message!'); $this::assertEquals( @@ -25,7 +25,7 @@ public function testNoChaining() ); } - public function testChaining() + public function testChaining(): void { $e1 = new Exception('This is an error message!'); $e2 = new Exception('This is a 2nd error message!', 0, $e1); diff --git a/test/qtismtest/common/utils/ReflectionTest.php b/test/qtismtest/common/utils/ReflectionTest.php index b5cf7005d..60a2ae923 100644 --- a/test/qtismtest/common/utils/ReflectionTest.php +++ b/test/qtismtest/common/utils/ReflectionTest.php @@ -19,12 +19,12 @@ class ReflectionTest extends QtiSmTestCase * @param mixed $expected * @param mixed $object */ - public function testShortClassName($expected, $object) + public function testShortClassName($expected, $object): void { $this::assertSame($expected, Reflection::shortClassName($object)); } - public function testNewInstanceWithArguments() + public function testNewInstanceWithArguments(): void { $clazz = new ReflectionClass(Exception::class); $args = ['A message', 12]; @@ -35,7 +35,7 @@ public function testNewInstanceWithArguments() $this::assertEquals(12, $instance->getCode()); } - public function testNewInstanceWithoutArguments() + public function testNewInstanceWithoutArguments(): void { $clazz = new ReflectionClass(stdClass::class); $instance = Reflection::newInstance($clazz); @@ -46,7 +46,7 @@ public function testNewInstanceWithoutArguments() /** * @return array */ - public function shortClassNameProvider() + public function shortClassNameProvider(): array { return [ ['SomeClass', 'SomeClass'], diff --git a/test/qtismtest/common/utils/TimeTest.php b/test/qtismtest/common/utils/TimeTest.php index fcfc241ed..ad534db30 100644 --- a/test/qtismtest/common/utils/TimeTest.php +++ b/test/qtismtest/common/utils/TimeTest.php @@ -20,12 +20,12 @@ class TimeTest extends QtiSmTestCase * @param DateTime $time2 * @param int $expectedSeconds */ - public function testTimeDiffSeconds(DateTime $time1, DateTime $time2, $expectedSeconds) + public function testTimeDiffSeconds(DateTime $time1, DateTime $time2, $expectedSeconds): void { $this::assertSame($expectedSeconds, TimeUtils::timeDiffSeconds($time1, $time2)); } - public function testBasicToUtc() + public function testBasicToUtc(): void { $originalTime = DateTime::createFromFormat('Y-m-d G:i:s', '2014-07-15 16:56:20', new DateTimeZone('Europe/Luxembourg')); $utcTime = TimeUtils::toUtc($originalTime); @@ -36,7 +36,7 @@ public function testBasicToUtc() * @return array * @throws Exception */ - public function timeDiffSecondsProvider() + public function timeDiffSecondsProvider(): array { $tz = new DateTimeZone('UTC'); diff --git a/test/qtismtest/common/utils/UrlTest.php b/test/qtismtest/common/utils/UrlTest.php index ba2397180..a339895f3 100644 --- a/test/qtismtest/common/utils/UrlTest.php +++ b/test/qtismtest/common/utils/UrlTest.php @@ -14,7 +14,7 @@ class UrlTest extends QtiSmTestCase * @dataProvider validRelativeUrlProvider * @param string $url */ - public function testValidRelativeUrl($url) + public function testValidRelativeUrl($url): void { $this::assertTrue(Url::isRelative($url)); } @@ -23,22 +23,22 @@ public function testValidRelativeUrl($url) * @dataProvider invalidRelativeUrlProvider * @param string $url */ - public function testInvalidRelativeUrl($url) + public function testInvalidRelativeUrl($url): void { $this::assertFalse(Url::isRelative($url)); } - public function testTrim() + public function testTrim(): void { $this::assertEquals('hello', Url::trim("/hello/\n")); } - public function testLtrim() + public function testLtrim(): void { $this::assertEquals("hello/\n", Url::ltrim("/hello/\n")); } - public function testRtrim() + public function testRtrim(): void { $this::assertEquals('/hello', Url::rtrim("/hello/\n")); } @@ -46,7 +46,7 @@ public function testRtrim() /** * @return array */ - public function validRelativeUrlProvider() + public function validRelativeUrlProvider(): array { return [ ['./path'], @@ -62,7 +62,7 @@ public function validRelativeUrlProvider() /** * @return array */ - public function invalidRelativeUrlProvider() + public function invalidRelativeUrlProvider(): array { return [ ['/'], diff --git a/test/qtismtest/common/utils/VersionTest.php b/test/qtismtest/common/utils/VersionTest.php index 2efd665ee..f4f19f782 100644 --- a/test/qtismtest/common/utils/VersionTest.php +++ b/test/qtismtest/common/utils/VersionTest.php @@ -19,12 +19,12 @@ class VersionTest extends QtiSmTestCase * @param string|null $operator * @param mixed $expected */ - public function testVersionCompareValid($version1, $version2, $operator, $expected) + public function testVersionCompareValid($version1, $version2, $operator, $expected): void { - $this::assertSame($expected, Version::compare($version1, $version2, $operator)); + $this::assertSame((bool)$expected, Version::compare($version1, $version2, $operator)); } - public function testUnknownOperator() + public function testUnknownOperator(): void { $msg = "Unknown operator '!=='. Known operators are '<', 'lt', '<=', 'le', '>', 'gt', '>=', 'ge', '==', '=', 'eq', '!=', '<>', 'ne'."; $this->expectException(InvalidArgumentException::class); @@ -75,7 +75,7 @@ public function versionCompareValidProvider(): array * @param $originalVersion * @param $patchedVersion */ - public function testAppendPatchVersion($originalVersion, $patchedVersion) + public function testAppendPatchVersion($originalVersion, $patchedVersion): void { $this::assertEquals($patchedVersion, Version::appendPatchVersion($originalVersion)); } @@ -104,7 +104,7 @@ public function appendPatchVersionProvider(): array ]; } - public function testAppendPatchVersionWithNonSemanticVersionThrowsException() + public function testAppendPatchVersionWithNonSemanticVersionThrowsException(): void { $versionNumber = 'whatever'; $this->expectException(InvalidArgumentException::class); diff --git a/test/qtismtest/data/AssessmentItemRefTest.php b/test/qtismtest/data/AssessmentItemRefTest.php index 8717169e2..ad6fed7b5 100644 --- a/test/qtismtest/data/AssessmentItemRefTest.php +++ b/test/qtismtest/data/AssessmentItemRefTest.php @@ -19,7 +19,7 @@ */ class AssessmentItemRefTest extends QtiSmTestCase { - public function testCreateAssessmentItemRefWrongIdentifier() + public function testCreateAssessmentItemRefWrongIdentifier(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("'999' is not a valid QTI Identifier."); @@ -27,7 +27,7 @@ public function testCreateAssessmentItemRefWrongIdentifier() $assessmentItemRef = new AssessmentItemRef('999', 'Nine Nine Nine'); } - public function testSetRequiredWrongType() + public function testSetRequiredWrongType(): void { $assessmentItemRef = new AssessmentItemRef('nine', 'Nine Nine Nine'); @@ -37,7 +37,7 @@ public function testSetRequiredWrongType() $assessmentItemRef->setRequired('test'); } - public function testSetFixedWrongType() + public function testSetFixedWrongType(): void { $assessmentItemRef = new AssessmentItemRef('nine', 'Nine Nine Nine'); @@ -47,7 +47,7 @@ public function testSetFixedWrongType() $assessmentItemRef->setFixed('test'); } - public function testClone() + public function testClone(): void { $assessmentItemRef = new AssessmentItemRef('Q01', 'Q01.xml'); $itemSessionControl = new ItemSessionControl(); diff --git a/test/qtismtest/data/AssessmentItemTest.php b/test/qtismtest/data/AssessmentItemTest.php index ac520a495..0a379fd42 100644 --- a/test/qtismtest/data/AssessmentItemTest.php +++ b/test/qtismtest/data/AssessmentItemTest.php @@ -16,7 +16,7 @@ */ class AssessmentItemTest extends QtiSmTestCase { - public function testModalFeedbackRules() + public function testModalFeedbackRules(): void { $assessmentItem = new AssessmentItem('Q01', 'Question 1', false); @@ -43,7 +43,7 @@ public function testModalFeedbackRules() * @param array $expected * @throws XmlStorageException */ - public function testGetResponseValidityConstraints($path, array $expected) + public function testGetResponseValidityConstraints($path, array $expected): void { $doc = new XmlDocument(); $doc->load($path); @@ -78,7 +78,7 @@ public function testGetResponseValidityConstraints($path, array $expected) /** * @return array */ - public function getResponseValidityConstraintsProvider() + public function getResponseValidityConstraintsProvider(): array { return [ // # 0 @@ -765,7 +765,7 @@ public function getResponseValidityConstraintsProvider() ]; } - public function testCreateAssessmentItemWrongIdentifier() + public function testCreateAssessmentItemWrongIdentifier(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The identifier argument must be a valid QTI Identifier, '999' given."); @@ -773,7 +773,7 @@ public function testCreateAssessmentItemWrongIdentifier() $assessmentItem = new AssessmentItem('999', 'Nine Nine Nine', false); } - public function testCreateAssessmentItemWrongTitle() + public function testCreateAssessmentItemWrongTitle(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The title argument must be a string, 'integer' given."); @@ -781,7 +781,7 @@ public function testCreateAssessmentItemWrongTitle() $assessmentItem = new AssessmentItem('ABC', 9, false); } - public function testCreateAssessmentItemWrongLanguage() + public function testCreateAssessmentItemWrongLanguage(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The lang argument must be a string, 'integer' given."); @@ -789,7 +789,7 @@ public function testCreateAssessmentItemWrongLanguage() $assessmentItem = new AssessmentItem('ABC', 'ABC', false, 1337); } - public function testSetLabelWrongType() + public function testSetLabelWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The label argument must be a string with at most 256 characters.'); @@ -798,7 +798,7 @@ public function testSetLabelWrongType() $assessmentItem->setLabel(str_repeat('1337', 65)); } - public function testSetAdaptiveWrongType() + public function testSetAdaptiveWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The adaptive argument must be a boolean, 'integer' given."); @@ -807,7 +807,7 @@ public function testSetAdaptiveWrongType() $assessmentItem->setAdaptive(9999); } - public function testSetTimeDependentWrongType() + public function testSetTimeDependentWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The timeDependent argument must be a boolean, 'integer' given."); @@ -816,7 +816,7 @@ public function testSetTimeDependentWrongType() $assessmentItem->setTimeDependent(9999); } - public function testSetToolNameWrongType() + public function testSetToolNameWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The toolName argument must be a string with at most 256 characters.'); @@ -825,7 +825,7 @@ public function testSetToolNameWrongType() $assessmentItem->setToolName(str_repeat('tool', 65)); } - public function testSetToolVersionWrongType() + public function testSetToolVersionWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The toolVersion argument must be a string with at most 256 characters.'); diff --git a/test/qtismtest/data/AssessmentSectionTest.php b/test/qtismtest/data/AssessmentSectionTest.php index 32bb16e5a..dfb656965 100644 --- a/test/qtismtest/data/AssessmentSectionTest.php +++ b/test/qtismtest/data/AssessmentSectionTest.php @@ -12,21 +12,21 @@ */ class AssessmentSectionTest extends QtiSmTestCase { - public function testSetTitleWrongType() + public function testSetTitleWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Title must be a string, 'integer' given."); new AssessmentSection('S01', 999, true); } - public function testSetVisibleWrongType() + public function testSetVisibleWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Visible must be a boolean, 'integer' given."); new AssessmentSection('S01', 'Section 01', 1); } - public function testSetKeepTogetherWrongType() + public function testSetKeepTogetherWrongType(): void { $section = new AssessmentSection('S01', 'Section 01', true); @@ -36,7 +36,7 @@ public function testSetKeepTogetherWrongType() $section->setKeepTogether(1); } - public function testHasOrdering() + public function testHasOrdering(): void { $section = new AssessmentSection('S01', 'Section 01', true); $section->setOrdering(new Ordering(true)); diff --git a/test/qtismtest/data/AssessmentTestTest.php b/test/qtismtest/data/AssessmentTestTest.php index 76b531e3d..17192060d 100644 --- a/test/qtismtest/data/AssessmentTestTest.php +++ b/test/qtismtest/data/AssessmentTestTest.php @@ -21,7 +21,7 @@ */ class AssessmentTestTest extends QtiSmTestCase { - public function testTimeLimits() + public function testTimeLimits(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/runtime/timelimits.xml'); @@ -35,7 +35,7 @@ public function testTimeLimits() $this::assertTrue($timeLimits->doesAllowLateSubmission()); } - public function testCreateAssessmentTestWrongIdentifier() + public function testCreateAssessmentTestWrongIdentifier(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("'999' is not a valid QTI Identifier."); @@ -43,7 +43,7 @@ public function testCreateAssessmentTestWrongIdentifier() $test = new AssessmentTest('999', 'Nine Nine Nine'); } - public function testCreateAssessmentTestWrongTitle() + public function testCreateAssessmentTestWrongTitle(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Title must be a string, 'integer' given."); @@ -51,7 +51,7 @@ public function testCreateAssessmentTestWrongTitle() $test = new AssessmentTest('ABC', 999); } - public function testSetToolNameWrongType() + public function testSetToolNameWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Toolname must be a string, 'integer' given."); @@ -60,7 +60,7 @@ public function testSetToolNameWrongType() $test->setToolName(999); } - public function testSetToolVersionWrongType() + public function testSetToolVersionWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("ToolVersion must be a string, 'integer' given."); @@ -69,7 +69,7 @@ public function testSetToolVersionWrongType() $test->setToolVersion(999); } - public function testComponentsWithTimeLimits() + public function testComponentsWithTimeLimits(): void { $test = new AssessmentTest('ABC', 'ABC'); $test->setTimeLimits( @@ -80,13 +80,13 @@ public function testComponentsWithTimeLimits() $this::assertInstanceOf(TimeLimits::class, $components[count($components) - 1]); } - public function testIsExclusivelyLinearNoTestParts() + public function testIsExclusivelyLinearNoTestParts(): void { $test = new AssessmentTest('ABC', 'ABC'); $this::assertFalse($test->isExclusivelyLinear()); } - public function testIsExclusivelyLinear() + public function testIsExclusivelyLinear(): void { $test = new AssessmentTest('ABC', 'ABC'); @@ -114,7 +114,7 @@ public function testIsExclusivelyLinear() $this::assertTrue($test->isExclusivelyLinear()); } - public function testGetPossiblePaths() + public function testGetPossiblePaths(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/tests/branchingpath.xml'); @@ -173,7 +173,7 @@ public function testGetPossiblePaths() $this::assertEquals($possible_paths, $test->getPossiblePaths(false)); } - public function testPossiblePathswithPreCondition() + public function testPossiblePathswithPreCondition(): void { // Case 1 @@ -216,7 +216,7 @@ public function testPossiblePathswithPreCondition() $this::assertEquals($possible_paths, $test->getPossiblePaths(false)); } - public function testPossiblePathsWitPreOnSectionsAndTPs() + public function testPossiblePathsWitPreOnSectionsAndTPs(): void { // Case with testParts and sections @@ -241,7 +241,7 @@ public function testPossiblePathsWitPreOnSectionsAndTPs() $this::assertEquals($possible_paths, $test->getPossiblePaths(false)); } - public function testPossiblePathsWitPreOnSubSections() + public function testPossiblePathsWitPreOnSubSections(): void { // Case with subsections @@ -266,7 +266,7 @@ public function testPossiblePathsWitPreOnSubSections() $this::assertEquals($possible_paths, $test->getPossiblePaths(false)); } - public function testPossiblePathWithSectsAndTPs() + public function testPossiblePathWithSectsAndTPs(): void { // Testing branching on sections @@ -310,7 +310,7 @@ public function testPossiblePathWithSectsAndTPs() $this::assertEquals($possible_paths, $test->getPossiblePaths(false)); } - public function testPossiblePathWithBranchingStartAndEnd() + public function testPossiblePathWithBranchingStartAndEnd(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/tests/branchingstartandend1.xml'); @@ -368,7 +368,7 @@ public function testPossiblePathWithBranchingStartAndEnd() // Testing special cases - public function testRecursiveBranching() + public function testRecursiveBranching(): void { $this->expectException(BranchRuleTargetException::class); $doc = new XmlDocument(); @@ -377,7 +377,7 @@ public function testRecursiveBranching() $test->getPossiblePaths(false); } - public function testRecursiveBranching2() + public function testRecursiveBranching2(): void { $this->expectException(BranchRuleTargetException::class); $doc = new XmlDocument(); @@ -386,7 +386,7 @@ public function testRecursiveBranching2() $test->getPossiblePaths(false); } - public function testRecursiveBranching3() + public function testRecursiveBranching3(): void { $this->expectException(BranchRuleTargetException::class); $doc = new XmlDocument(); @@ -395,7 +395,7 @@ public function testRecursiveBranching3() $test->getPossiblePaths(false); } - public function testRecursiveBranching4() + public function testRecursiveBranching4(): void { $this->expectException(BranchRuleTargetException::class); $doc = new XmlDocument(); @@ -404,7 +404,7 @@ public function testRecursiveBranching4() $test->getPossiblePaths(false); } - public function testRecursiveBranching5() + public function testRecursiveBranching5(): void { $this->expectException(BranchRuleTargetException::class); $doc = new XmlDocument(); @@ -413,7 +413,7 @@ public function testRecursiveBranching5() $test->getPossiblePaths(false); } - public function testBackwardBranching() + public function testBackwardBranching(): void { $this->expectException(BranchRuleTargetException::class); $doc = new XmlDocument(); @@ -422,7 +422,7 @@ public function testBackwardBranching() $test->getPossiblePaths(false); } - public function testWrongTargetBranching() + public function testWrongTargetBranching(): void { $this->expectException(BranchRuleTargetException::class); $doc = new XmlDocument(); @@ -431,7 +431,7 @@ public function testWrongTargetBranching() $test->getPossiblePaths(false); } - public function testGetPossiblePathsWithExitMentions() + public function testGetPossiblePathsWithExitMentions(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/tests/branchingwithexitmentions.xml'); @@ -505,7 +505,7 @@ public function testGetPossiblePathsWithExitMentions() $this::assertEquals($possible_paths, $test->getPossiblePaths(false)); } - public function testGetShortestPaths() + public function testGetShortestPaths(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/tests/branchingpath.xml'); @@ -546,7 +546,7 @@ public function testGetShortestPaths() $this::assertEquals($shortest_paths, $test->getShortestPaths()); } - public function testGetLongestPaths() + public function testGetLongestPaths(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/tests/branchingpath.xml'); diff --git a/test/qtismtest/data/BaseTypeTest.php b/test/qtismtest/data/BaseTypeTest.php index 67dd0e150..3cbe089d9 100644 --- a/test/qtismtest/data/BaseTypeTest.php +++ b/test/qtismtest/data/BaseTypeTest.php @@ -14,7 +14,7 @@ class BaseTypeTest extends QtiSmTestCase * @dataProvider validBaseTypeProvider * @param string $baseType */ - public function testGetConstantByNameValidBaseType($baseType) + public function testGetConstantByNameValidBaseType($baseType): void { $this::assertIsInt(BaseType::getConstantByName($baseType)); } @@ -23,7 +23,7 @@ public function testGetConstantByNameValidBaseType($baseType) * @dataProvider invalidBaseTypeProvider * @param string $baseType */ - public function testGetConstantByNameInvalidBaseType($baseType) + public function testGetConstantByNameInvalidBaseType($baseType): void { $this::assertFalse(BaseType::getConstantByName($baseType)); } @@ -33,7 +33,7 @@ public function testGetConstantByNameInvalidBaseType($baseType) * @param int $constant * @param string $expected */ - public function testGetNameByConstantValidBaseType($constant, $expected) + public function testGetNameByConstantValidBaseType($constant, $expected): void { $this::assertEquals($expected, BaseType::getNameByConstant($constant)); } @@ -42,7 +42,7 @@ public function testGetNameByConstantValidBaseType($constant, $expected) * @dataProvider invalidBaseTypeConstantProvider * @param int $constant */ - public function testGetNameByConstantInvalidBaseType($constant) + public function testGetNameByConstantInvalidBaseType($constant): void { $this::assertFalse(BaseType::getNameByConstant($constant)); } @@ -50,7 +50,7 @@ public function testGetNameByConstantInvalidBaseType($constant) /** * @return array */ - public function validBaseTypeConstantProvider() + public function validBaseTypeConstantProvider(): array { return [ [BaseType::IDENTIFIER, 'identifier'], @@ -71,7 +71,7 @@ public function validBaseTypeConstantProvider() /** * @return array */ - public function invalidBaseTypeConstantProvider() + public function invalidBaseTypeConstantProvider(): array { return [ [-1], @@ -81,7 +81,7 @@ public function invalidBaseTypeConstantProvider() /** * @return array */ - public function validBaseTypeProvider() + public function validBaseTypeProvider(): array { return [ ['identifier'], @@ -102,7 +102,7 @@ public function validBaseTypeProvider() /** * @return array */ - public function invalidBaseTypeProvider() + public function invalidBaseTypeProvider(): array { return [ [10], diff --git a/test/qtismtest/data/ExtendedAssessmentItemRefTest.php b/test/qtismtest/data/ExtendedAssessmentItemRefTest.php index b327e6c55..e75840bab 100644 --- a/test/qtismtest/data/ExtendedAssessmentItemRefTest.php +++ b/test/qtismtest/data/ExtendedAssessmentItemRefTest.php @@ -26,7 +26,7 @@ */ class ExtendedAssessmentItemRefTest extends QtiSmTestCase { - public function testCreateFromAssessmentItemRef() + public function testCreateFromAssessmentItemRef(): void { $assessmentItemRef = new AssessmentItemRef('Q01', 'Q01.xml'); $extendedAssessmentItemRef = ExtendedAssessmentItemRef::createFromAssessmentItemRef($assessmentItemRef); @@ -39,7 +39,7 @@ public function testCreateFromAssessmentItemRef() /** * @depends testCreateFromAssessmentItemRef */ - public function testCreateFromAssessmentItemRefWithWeights() + public function testCreateFromAssessmentItemRefWithWeights(): void { $assessmentItemRef = new AssessmentItemRef('Q01', 'Q01.xml'); $assessmentItemRef->setWeights( @@ -58,7 +58,7 @@ public function testCreateFromAssessmentItemRefWithWeights() $this::assertEquals(2., $weights['WEIGHT']->getValue()); } - public function testRemoveOutcomeDeclaration() + public function testRemoveOutcomeDeclaration(): void { $assessmentItemRef = new ExtendedAssessmentItemRef('Q01', 'Q01.xml'); $outcomeDeclaration = new OutcomeDeclaration('OUTCOME', BaseType::IDENTIFIER, Cardinality::SINGLE); @@ -69,7 +69,7 @@ public function testRemoveOutcomeDeclaration() $this::assertCount(0, $assessmentItemRef->getOutcomeDeclarations()); } - public function testRemoveResponseDeclaration() + public function testRemoveResponseDeclaration(): void { $assessmentItemRef = new ExtendedAssessmentItemRef('Q01', 'Q01.xml'); $responseDeclaration = new ResponseDeclaration('RESPONSE', BaseType::IDENTIFIER, Cardinality::SINGLE); @@ -80,7 +80,7 @@ public function testRemoveResponseDeclaration() $this::assertCount(0, $assessmentItemRef->getResponseDeclarations()); } - public function testAddTemplateDeclaration() + public function testAddTemplateDeclaration(): void { $assessmentItemRef = new ExtendedAssessmentItemRef('Q01', 'Q01.xml'); $templateDeclaration = new TemplateDeclaration('TEMPLATE', BaseType::IDENTIFIER, Cardinality::SINGLE); @@ -89,7 +89,7 @@ public function testAddTemplateDeclaration() $this::assertCount(1, $assessmentItemRef->getTemplateDeclarations()); } - public function testRemoveTemplateDeclaration() + public function testRemoveTemplateDeclaration(): void { $assessmentItemRef = new ExtendedAssessmentItemRef('Q01', 'Q01.xml'); $templateDeclaration = new TemplateDeclaration('TEMPLATE', BaseType::IDENTIFIER, Cardinality::SINGLE); @@ -100,7 +100,7 @@ public function testRemoveTemplateDeclaration() $this::assertCount(0, $assessmentItemRef->getTemplateDeclarations()); } - public function testRemoveModalFeedbackRule() + public function testRemoveModalFeedbackRule(): void { $assessmentItemRef = new ExtendedAssessmentItemRef('Q01', 'Q01.xml'); $modalFeedbackRule = new ModalFeedbackRule('OUTCOME', ShowHide::SHOW, 'MDLF'); @@ -111,7 +111,7 @@ public function testRemoveModalFeedbackRule() $this::assertCount(0, $assessmentItemRef->getModalFeedbackRules()); } - public function testRemoveShuffling() + public function testRemoveShuffling(): void { $shuffling = new Shuffling( 'RESPONSE', @@ -133,7 +133,7 @@ public function testRemoveShuffling() $this::assertCount(0, $assessmentItemRef->getShufflings()); } - public function testSetAdaptiveWrongType() + public function testSetAdaptiveWrongType(): void { $assessmentItemRef = new ExtendedAssessmentItemRef('Q01', 'Q01.xml'); @@ -143,7 +143,7 @@ public function testSetAdaptiveWrongType() $assessmentItemRef->setAdaptive('true'); } - public function testSetTimeDependentWrongType() + public function testSetTimeDependentWrongType(): void { $assessmentItemRef = new ExtendedAssessmentItemRef('Q01', 'Q01.xml'); @@ -153,7 +153,7 @@ public function testSetTimeDependentWrongType() $assessmentItemRef->setTimeDependent('true'); } - public function testAddResponseValidityConstraint() + public function testAddResponseValidityConstraint(): void { $assessmentItemRef = new ExtendedAssessmentItemRef('Q01', 'Q01.xml'); $responseValidityConstraint = new ResponseValidityConstraint('RESPONSE', 0, 1); @@ -161,7 +161,7 @@ public function testAddResponseValidityConstraint() $this::assertCount(1, $assessmentItemRef->getResponseValidityConstraints()); } - public function testRemoveResponseValidityConstraint() + public function testRemoveResponseValidityConstraint(): void { $assessmentItemRef = new ExtendedAssessmentItemRef('Q01', 'Q01.xml'); $responseValidityConstraint = new ResponseValidityConstraint('RESPONSE', 0, 1); diff --git a/test/qtismtest/data/ItemSessionControlTest.php b/test/qtismtest/data/ItemSessionControlTest.php index 48cef6020..3c1844957 100644 --- a/test/qtismtest/data/ItemSessionControlTest.php +++ b/test/qtismtest/data/ItemSessionControlTest.php @@ -11,7 +11,7 @@ */ class ItemSessionControlTest extends QtiSmTestCase { - public function testIsDefault() + public function testIsDefault(): void { $itemSessionControl = new ItemSessionControl(); $this::assertTrue($itemSessionControl->isDefault()); @@ -20,7 +20,7 @@ public function testIsDefault() $this::assertFalse($itemSessionControl->isDefault()); } - public function testSetMaxAttemptsWrongType() + public function testSetMaxAttemptsWrongType(): void { $itemSessionControl = new ItemSessionControl(); @@ -30,7 +30,7 @@ public function testSetMaxAttemptsWrongType() $itemSessionControl->setMaxAttempts(true); } - public function testSetShowFeedbackWrongType() + public function testSetShowFeedbackWrongType(): void { $itemSessionControl = new ItemSessionControl(); @@ -40,7 +40,7 @@ public function testSetShowFeedbackWrongType() $itemSessionControl->setShowFeedback(999); } - public function testSetAllowReviewWrongType() + public function testSetAllowReviewWrongType(): void { $itemSessionControl = new ItemSessionControl(); @@ -50,7 +50,7 @@ public function testSetAllowReviewWrongType() $itemSessionControl->setAllowReview(999); } - public function testSetShowSolutionWrongType() + public function testSetShowSolutionWrongType(): void { $itemSessionControl = new ItemSessionControl(); @@ -60,7 +60,7 @@ public function testSetShowSolutionWrongType() $itemSessionControl->setShowSolution(999); } - public function testSetAllowCommentWrongType() + public function testSetAllowCommentWrongType(): void { $itemSessionControl = new ItemSessionControl(); @@ -70,7 +70,7 @@ public function testSetAllowCommentWrongType() $itemSessionControl->setAllowComment(999); } - public function testSetAllowSkippingWrongType() + public function testSetAllowSkippingWrongType(): void { $itemSessionControl = new ItemSessionControl(); @@ -80,7 +80,7 @@ public function testSetAllowSkippingWrongType() $itemSessionControl->setAllowSkipping(999); } - public function testSetValidateResponsesWrongType() + public function testSetValidateResponsesWrongType(): void { $itemSessionControl = new ItemSessionControl(); diff --git a/test/qtismtest/data/NavigationModeTest.php b/test/qtismtest/data/NavigationModeTest.php index c4f14843b..9862f8a0b 100644 --- a/test/qtismtest/data/NavigationModeTest.php +++ b/test/qtismtest/data/NavigationModeTest.php @@ -13,7 +13,7 @@ class NavigationModeTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return NavigationMode::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'linear', @@ -32,7 +32,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'LINEAR', @@ -43,7 +43,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ NavigationMode::LINEAR, diff --git a/test/qtismtest/data/QtiComponentCollectionTest.php b/test/qtismtest/data/QtiComponentCollectionTest.php index af6f439b9..b2047564b 100644 --- a/test/qtismtest/data/QtiComponentCollectionTest.php +++ b/test/qtismtest/data/QtiComponentCollectionTest.php @@ -16,7 +16,7 @@ */ class QtiComponentCollectionTest extends QtiSmTestCase { - public function testInsertWrongType() + public function testInsertWrongType(): void { $collection = new QtiComponentCollection(); @@ -26,7 +26,7 @@ public function testInsertWrongType() $collection[] = new stdClass(); } - public function testInsertWrongCall() + public function testInsertWrongCall(): void { $collection = new QtiComponentCollection(); @@ -36,7 +36,7 @@ public function testInsertWrongCall() $collection['index'] = new stdClass(); } - public function testExclusivelyContainsComponentsWithClassNameNotFoundRecursive() + public function testExclusivelyContainsComponentsWithClassNameNotFoundRecursive(): void { $collection = new QtiComponentCollection(); $component = new P(); diff --git a/test/qtismtest/data/QtiComponentIteratorTest.php b/test/qtismtest/data/QtiComponentIteratorTest.php index dc11179ef..12eee252f 100644 --- a/test/qtismtest/data/QtiComponentIteratorTest.php +++ b/test/qtismtest/data/QtiComponentIteratorTest.php @@ -16,7 +16,7 @@ */ class QtiComponentIteratorTest extends QtiSmTestCase { - public function testSimple() + public function testSimple(): void { $baseValues = new ExpressionCollection(); $baseValues[] = new BaseValue(BaseType::FLOAT, 0.5); @@ -38,7 +38,7 @@ public function testSimple() $this::assertNull($iterator->parent()); } - public function testOneChildComponents() + public function testOneChildComponents(): void { $baseValues = new ExpressionCollection(); $baseValues[] = new BaseValue(BaseType::FLOAT, 0.5); @@ -57,7 +57,7 @@ public function testOneChildComponents() } } - public function testOneChildComponentsByClassName() + public function testOneChildComponentsByClassName(): void { $baseValues = new ExpressionCollection(); $baseValues[] = new BaseValue(BaseType::FLOAT, 0.5); @@ -72,7 +72,7 @@ public function testOneChildComponentsByClassName() $this::assertEquals(1, $iterations); } - public function testNoChildComponents() + public function testNoChildComponents(): void { $baseValue = new BaseValue(BaseType::FLOAT, 10); $iterator = new QtiComponentIterator($baseValue); @@ -86,7 +86,7 @@ public function testNoChildComponents() $this::assertNull($iterator->current()); } - public function testAvoidRecursions() + public function testAvoidRecursions(): void { $baseValues = new ExpressionCollection(); $baseValues[] = new BaseValue(BaseType::FLOAT, 0.5); @@ -113,7 +113,7 @@ public function testAvoidRecursions() * @param array $classNames * @throws XmlStorageException */ - public function testClassSelection($file, $iterations, array $classNames) + public function testClassSelection($file, $iterations, array $classNames): void { $doc = new XmlCompactDocument(); $doc->load($file); @@ -138,7 +138,7 @@ public function testClassSelection($file, $iterations, array $classNames) /** * @return array */ - public function classSelectionProvider() + public function classSelectionProvider(): array { $dir = self::samplesDir(); diff --git a/test/qtismtest/data/QtiComponentTest.php b/test/qtismtest/data/QtiComponentTest.php index 6d9669877..a51e9eb03 100644 --- a/test/qtismtest/data/QtiComponentTest.php +++ b/test/qtismtest/data/QtiComponentTest.php @@ -14,7 +14,7 @@ */ class QtiComponentTest extends QtiSmTestCase { - public function testGetComponentByIdOrClassNameSimple() + public function testGetComponentByIdOrClassNameSimple(): void { $id = 'assessmentSection1'; $title = 'Assessment Section Title'; @@ -45,7 +45,7 @@ public function testGetComponentByIdOrClassNameSimple() $this::assertCount(4, $search); } - public function testGetComponentByIdOrClassNameComplex() + public function testGetComponentByIdOrClassNameComplex(): void { $id = 'assessmentSectionRoot'; $title = 'Assessment Section Root'; @@ -133,7 +133,7 @@ public function testGetComponentByIdOrClassNameComplex() $this::assertCount(2, $search); } - public function testGetIdentifiableComponentsNoCollision() + public function testGetIdentifiableComponentsNoCollision(): void { $assessmentSection = new AssessmentSection('S01', 'Section S01', true); $assessmentItemRef1a = new AssessmentItemRef('Q01', './Q01.xml'); @@ -146,7 +146,7 @@ public function testGetIdentifiableComponentsNoCollision() $this::assertEquals(['Q01', 'Q02'], $search->getKeys()); } - public function testGetIdentifiableComponentsCollision() + public function testGetIdentifiableComponentsCollision(): void { $assessmentSection = new AssessmentSection('S01', 'Section S01', true); $assessmentSection1a = new AssessmentSection('S01a', 'Section S01a', true); diff --git a/test/qtismtest/data/QtiIdentifiableCollectionTest.php b/test/qtismtest/data/QtiIdentifiableCollectionTest.php index 838d109c5..a5512bdbf 100644 --- a/test/qtismtest/data/QtiIdentifiableCollectionTest.php +++ b/test/qtismtest/data/QtiIdentifiableCollectionTest.php @@ -13,7 +13,7 @@ */ class QtiIdentifiableCollectionTest extends QtiSmTestCase { - public function testWithWeights() + public function testWithWeights(): void { $weight1 = new Weight('weight1', 1.0); $weight2 = new Weight('weight2', 1.1); @@ -45,7 +45,7 @@ public function testWithWeights() /** * @depends testWithWeights */ - public function testReplace() + public function testReplace(): void { $weight1 = new Weight('weight1', 1.0); $weight2 = new Weight('weight2', 1.1); @@ -84,7 +84,7 @@ public function testReplace() /** * @depends testReplace */ - public function testReplaceNotFound() + public function testReplaceNotFound(): void { $weight1 = new Weight('weight1', 1.0); $weight2 = new Weight('weight2', 1.2); @@ -100,7 +100,7 @@ public function testReplaceNotFound() /** * @depends testWithWeights */ - public function testEventsUnset() + public function testEventsUnset(): void { $weight1 = new Weight('weight1', 1.0); $weight2 = new Weight('weight2', 1.2); @@ -125,7 +125,7 @@ public function testEventsUnset() $this::assertNotSame($weight1, $weights['weight2']); } - public function testRenamingOrder() + public function testRenamingOrder(): void { $weight1 = new Weight('weight1', 1.0); $weight2 = new Weight('weight2', 1.2); @@ -146,7 +146,7 @@ public function testRenamingOrder() ); } - public function testOffsetGetNonString() + public function testOffsetGetNonString(): void { $this->expectException(OutOfRangeException::class); $this->expectExceptionMessage('The requested offset must be a non-empty string.'); @@ -155,7 +155,7 @@ public function testOffsetGetNonString() $val = $collection[0]; } - public function testOffsetSetNonNull() + public function testOffsetSetNonNull(): void { $this->expectException(OutOfRangeException::class); $this->expectExceptionMessage("No specific offset can be set in a QtiIdentifiableCollection. The offset is always infered from the 'identifier' attribute of the given QtiIdentifiable object. Given offset is 'offset'."); @@ -164,7 +164,7 @@ public function testOffsetSetNonNull() $val = $collection['offset'] = new Weight('weight1', 1.0); } - public function testOffsetUnsetNonString() + public function testOffsetUnsetNonString(): void { $this->expectException(OutOfRangeException::class); $this->expectExceptionMessage('The requested offset must be a non-empty string.'); @@ -173,7 +173,7 @@ public function testOffsetUnsetNonString() unset($collection[0]); } - public function testClone() + public function testClone(): void { $collection = new WeightCollection(); $w01 = new Weight('W01', 1.0); diff --git a/test/qtismtest/data/ShowHideTest.php b/test/qtismtest/data/ShowHideTest.php index e0a1d6145..0fb92dea7 100644 --- a/test/qtismtest/data/ShowHideTest.php +++ b/test/qtismtest/data/ShowHideTest.php @@ -13,7 +13,7 @@ class ShowHideTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return ShowHide::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'show', @@ -32,7 +32,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'SHOW', @@ -43,7 +43,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ ShowHide::SHOW, diff --git a/test/qtismtest/data/SubmissionModeTest.php b/test/qtismtest/data/SubmissionModeTest.php index c9f5fc9d1..ea36e0fc0 100644 --- a/test/qtismtest/data/SubmissionModeTest.php +++ b/test/qtismtest/data/SubmissionModeTest.php @@ -13,7 +13,7 @@ class SubmissionModeTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return SubmissionMode::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'individual', @@ -32,7 +32,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'INDIVIDUAL', @@ -43,7 +43,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ SubmissionMode::INDIVIDUAL, diff --git a/test/qtismtest/data/TestFeedbackAccessTest.php b/test/qtismtest/data/TestFeedbackAccessTest.php index eaddd8e80..196461178 100644 --- a/test/qtismtest/data/TestFeedbackAccessTest.php +++ b/test/qtismtest/data/TestFeedbackAccessTest.php @@ -13,7 +13,7 @@ class TestFeedbackAccessTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return TestFeedbackAccess::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'atEnd', @@ -32,7 +32,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'AT_END', @@ -43,7 +43,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ TestFeedbackAccess::AT_END, diff --git a/test/qtismtest/data/TestFeedbackRefTest.php b/test/qtismtest/data/TestFeedbackRefTest.php index 8bf267639..c3712670a 100644 --- a/test/qtismtest/data/TestFeedbackRefTest.php +++ b/test/qtismtest/data/TestFeedbackRefTest.php @@ -13,7 +13,7 @@ */ class TestFeedbackRefTest extends QtiSmTestCase { - public function testSetAccessWrongType() + public function testSetAccessWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("'1' is not a value from the TestFeedbackAccess enumeration."); @@ -21,7 +21,7 @@ public function testSetAccessWrongType() $testFeedbackRef = new TestFeedbackRef('IDENTIFIER', 'OUTCOMEIDENTIFIER', true, ShowHide::SHOW, 'ref.xml'); } - public function testSetShowHideWrongType() + public function testSetShowHideWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("'1' is not a value from the ShowHide enumeration."); @@ -29,7 +29,7 @@ public function testSetShowHideWrongType() $testFeedbackRef = new TestFeedbackRef('IDENTIFIER', 'OUTCOMEIDENTIFIER', TestFeedbackAccess::DURING, true, 'ref.xml'); } - public function testSetOutcomeIdentifierWrongType() + public function testSetOutcomeIdentifierWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("'999' is not a valid QTI Identifier."); @@ -37,7 +37,7 @@ public function testSetOutcomeIdentifierWrongType() $testFeedbackRef = new TestFeedbackRef('IDENTIFIER', 999, TestFeedbackAccess::DURING, ShowHide::SHOW, 'ref.xml'); } - public function testSetIdentifierWrongType() + public function testSetIdentifierWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("'999' is not a valid QTI Identifier."); @@ -45,7 +45,7 @@ public function testSetIdentifierWrongType() $testFeedbackRef = new TestFeedbackRef(999, 'OUTCOMEIDENTIFIER', TestFeedbackAccess::DURING, ShowHide::SHOW, 'ref.xml'); } - public function testSetHrefWrongType() + public function testSetHrefWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("'' is not a valid URI."); diff --git a/test/qtismtest/data/TestFeedbackTest.php b/test/qtismtest/data/TestFeedbackTest.php index a56217ce1..6a9ff4439 100644 --- a/test/qtismtest/data/TestFeedbackTest.php +++ b/test/qtismtest/data/TestFeedbackTest.php @@ -12,7 +12,7 @@ */ class TestFeedbackTest extends QtiSmTestCase { - public function testSetAccessWrongType() + public function testSetAccessWrongType(): void { $testFeedback = new TestFeedback('IDENTIFIER', 'OUTCOMEIDENTIFIER', new FlowStaticCollection()); @@ -22,7 +22,7 @@ public function testSetAccessWrongType() $testFeedback->setAccess(true); } - public function testSetOutcomeIdentifierWrongType() + public function testSetOutcomeIdentifierWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("'999' is not a valid QTI Identifier."); @@ -30,7 +30,7 @@ public function testSetOutcomeIdentifierWrongType() $testFeedback = new TestFeedback('IDENTIFIER', 999, new FlowStaticCollection()); } - public function testSetShowHideWrongType() + public function testSetShowHideWrongType(): void { $testFeedback = new TestFeedback('IDENTIFIER', 'OUTCOMEIDENTIFIER', new FlowStaticCollection()); @@ -40,7 +40,7 @@ public function testSetShowHideWrongType() $testFeedback->setShowHide(true); } - public function testSetIdentifierWrongType() + public function testSetIdentifierWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("'999' is not a valid QTI Identifier."); @@ -48,7 +48,7 @@ public function testSetIdentifierWrongType() $testFeedback = new TestFeedback(999, 'OUTCOMEIDENTIFIER', new FlowStaticCollection()); } - public function testSetTitleWrongType() + public function testSetTitleWrongType(): void { $testFeedback = new TestFeedback('IDENTIFIER', 'OUTCOMEIDENTIFIER', new FlowStaticCollection()); diff --git a/test/qtismtest/data/TestPartTest.php b/test/qtismtest/data/TestPartTest.php index 55b06b9f4..7c863886a 100644 --- a/test/qtismtest/data/TestPartTest.php +++ b/test/qtismtest/data/TestPartTest.php @@ -15,7 +15,7 @@ */ class TestPartTest extends QtiSmTestCase { - public function testCreateInvalidIdentifier() + public function testCreateInvalidIdentifier(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("'999' is not a valid QTI Identifier."); @@ -26,7 +26,7 @@ public function testCreateInvalidIdentifier() ); } - public function testCreateNotEnoughAssessmentSections() + public function testCreateNotEnoughAssessmentSections(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A TestPart must contain at least one AssessmentSection.'); @@ -37,7 +37,7 @@ public function testCreateNotEnoughAssessmentSections() ); } - public function testCreateWrongSectionTypes() + public function testCreateWrongSectionTypes(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A TestPart contain only contain AssessmentSection or AssessmentSectionRef objects.'); diff --git a/test/qtismtest/data/UtilsTest.php b/test/qtismtest/data/UtilsTest.php index 284454ed8..838dd31f9 100644 --- a/test/qtismtest/data/UtilsTest.php +++ b/test/qtismtest/data/UtilsTest.php @@ -32,7 +32,7 @@ */ class UtilsTest extends QtiSmTestCase { - public function testGetFirstItem() + public function testGetFirstItem(): void { // Simple cases @@ -74,7 +74,7 @@ public function testGetFirstItem() $this::assertNull(DataUtils::getFirstItem($test, $test, $sections)); } - public function testgetFirstItem2() + public function testgetFirstItem2(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/tests/branchingtestparts.xml'); @@ -118,7 +118,7 @@ public function testgetFirstItem2() ); } - public function testGetLastItem() + public function testGetLastItem(): void { // Simple cases @@ -160,7 +160,7 @@ public function testGetLastItem() $this::assertNull(DataUtils::getLastItem($test, $test, $sections)); } - public function testgetLastItem2() + public function testgetLastItem2(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/tests/branchingtestparts.xml'); diff --git a/test/qtismtest/data/ViewTest.php b/test/qtismtest/data/ViewTest.php index 4f4465dd9..42b7e0877 100644 --- a/test/qtismtest/data/ViewTest.php +++ b/test/qtismtest/data/ViewTest.php @@ -13,7 +13,7 @@ class ViewTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return View::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'author', @@ -36,7 +36,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'AUTHOR', @@ -51,7 +51,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ View::AUTHOR, diff --git a/test/qtismtest/data/content/BodyElementTest.php b/test/qtismtest/data/content/BodyElementTest.php index d658047a6..edc1c4d64 100644 --- a/test/qtismtest/data/content/BodyElementTest.php +++ b/test/qtismtest/data/content/BodyElementTest.php @@ -35,7 +35,7 @@ */ class BodyElementTest extends QtiSmTestCase { - public function testRawInstantiation() + public function testRawInstantiation(): void { $span = new Span(); $this::assertSame('', $span->getAriaControls()); @@ -67,7 +67,7 @@ public function testRawInstantiation() $this::assertFalse($span->hasAriaHidden()); } - public function testSetId() + public function testSetId(): void { $span = new Span(); @@ -82,7 +82,7 @@ public function testSetId() * @param mixed $class the class to set * @param string|null $message the expected message or null if identical to $class to set */ - public function testSetClassWithWrongClass($class, string $message = null) + public function testSetClassWithWrongClass($class, string $message = null): void { $span = new Span(); @@ -126,7 +126,7 @@ public function rightClassesToTest(): array ]; } - public function testSetLabelWrongType() + public function testSetLabelWrongType(): void { $span = new Span(); @@ -136,7 +136,7 @@ public function testSetLabelWrongType() $span->setLabel(str_repeat('9999', 65)); } - public function testSetDirectionWrongLabel() + public function testSetDirectionWrongLabel(): void { $span = new Span(); @@ -150,7 +150,7 @@ public function testSetDirectionWrongLabel() * @param $value * @dataProvider validAriaControlsAttributesProvider */ - public function testValidAriaControlsAttributes($value) + public function testValidAriaControlsAttributes($value): void { $span = new Span(); $span->setAriaControls($value); @@ -161,7 +161,7 @@ public function testValidAriaControlsAttributes($value) /** * @return array */ - public function validAriaControlsAttributesProvider() + public function validAriaControlsAttributesProvider(): array { return [ [''], @@ -174,7 +174,7 @@ public function validAriaControlsAttributesProvider() * @param $value * @dataProvider validAriaDescribedByAttributesProvider */ - public function testValidAriaDescribedByAttributes($value) + public function testValidAriaDescribedByAttributes($value): void { $span = new Span(); $span->setAriaDescribedBy($value); @@ -185,7 +185,7 @@ public function testValidAriaDescribedByAttributes($value) /** * @return array */ - public function validAriaDescribedByAttributesProvider() + public function validAriaDescribedByAttributesProvider(): array { return [ [''], @@ -198,7 +198,7 @@ public function validAriaDescribedByAttributesProvider() * @param $value * @dataProvider validAriaFlowToAttributesProvider */ - public function testValidAriaFlowToAttributes($value) + public function testValidAriaFlowToAttributes($value): void { $span = new Span(); $span->setAriaFlowTo($value); @@ -209,7 +209,7 @@ public function testValidAriaFlowToAttributes($value) /** * @return array */ - public function validAriaFlowToAttributesProvider() + public function validAriaFlowToAttributesProvider(): array { return [ [''], @@ -222,7 +222,7 @@ public function validAriaFlowToAttributesProvider() * @param $value * @dataProvider validAriaLabelledByAttributesProvider */ - public function testValidAriaLabelledByAttributes($value) + public function testValidAriaLabelledByAttributes($value): void { $span = new Span(); $span->setAriaLabelledBy($value); @@ -233,7 +233,7 @@ public function testValidAriaLabelledByAttributes($value) /** * @return array */ - public function validAriaLabelledByAttributesProvider() + public function validAriaLabelledByAttributesProvider(): array { return [ [''], @@ -246,7 +246,7 @@ public function validAriaLabelledByAttributesProvider() * @param $value * @dataProvider validAriaLabelledByAttributesProvider */ - public function testValidAriaOwnsAttributes($value) + public function testValidAriaOwnsAttributes($value): void { $span = new Span(); $span->setAriaOwns($value); @@ -257,7 +257,7 @@ public function testValidAriaOwnsAttributes($value) /** * @return array */ - public function validAriaOwnsAttributesProvider() + public function validAriaOwnsAttributesProvider(): array { return [ [''], @@ -304,7 +304,7 @@ public function testValidAriaLiveAttributes(int $value): void /** * @return array */ - public function validAriaLiveAttributesProvider() + public function validAriaLiveAttributesProvider(): array { return [ [AriaLive::OFF], @@ -317,7 +317,7 @@ public function validAriaLiveAttributesProvider() * @param $value * @dataProvider validAriaOrientationAttributesProvider */ - public function testValidAriaOrientationAttributes($value) + public function testValidAriaOrientationAttributes($value): void { $span = new Span(); $span->setAriaOrientation($value); @@ -328,7 +328,7 @@ public function testValidAriaOrientationAttributes($value) /** * @return array */ - public function validAriaOrientationAttributesProvider() + public function validAriaOrientationAttributesProvider(): array { return [ [AriaOrientation::HORIZONTAL], @@ -340,7 +340,7 @@ public function validAriaOrientationAttributesProvider() * @param $value * @dataProvider validAriaLabelAttributesProvider */ - public function testValidAriaLabelAttributes($value) + public function testValidAriaLabelAttributes($value): void { $span = new Span(); $span->setAriaLabel($value); @@ -351,7 +351,7 @@ public function testValidAriaLabelAttributes($value) /** * @return array */ - public function validAriaLabelAttributesProvider() + public function validAriaLabelAttributesProvider(): array { return [ [''], @@ -544,7 +544,7 @@ public function testInvalidAriaLiveAttributes($value): void /** * @return array */ - public function invalidAriaLiveAttributesProvider() + public function invalidAriaLiveAttributesProvider(): array { return [ [999999], @@ -557,7 +557,7 @@ public function invalidAriaLiveAttributesProvider() * @param string $msg * @dataProvider invalidAriaOrientationAttributesProvider */ - public function testInvalidAriaOrientationAttributes($value, $msg = null) + public function testInvalidAriaOrientationAttributes($value, $msg = null): void { $msg = $msg ?? "'${value}' is not a valid value for attribute 'aria-orientation'."; @@ -571,7 +571,7 @@ public function testInvalidAriaOrientationAttributes($value, $msg = null) /** * @return array */ - public function invalidAriaOrientationAttributesProvider() + public function invalidAriaOrientationAttributesProvider(): array { return [ ['ABCD 999999'], @@ -586,7 +586,7 @@ public function invalidAriaOrientationAttributesProvider() * @param string $msg * @dataProvider invalidAriaLabelAttributesProvider */ - public function testInvalidAriaLabelAttributes($value, $msg = null) + public function testInvalidAriaLabelAttributes($value, $msg = null): void { $msg = $msg ?? "'${value}' is not a valid value for attribute 'aria-label'."; @@ -600,7 +600,7 @@ public function testInvalidAriaLabelAttributes($value, $msg = null) /** * @return array */ - public function invalidAriaLabelAttributesProvider() + public function invalidAriaLabelAttributesProvider(): array { return [ [false], @@ -617,7 +617,7 @@ public function invalidAriaLabelAttributesProvider() * @param string $msg * @dataProvider invalidAriaHiddenAttributesProvider */ - public function testInvalidAriaHiddenAttributes($value, $msg = null) + public function testInvalidAriaHiddenAttributes($value, $msg = null): void { $msg = $msg ?? "'${value}' is not a valid value for attribute 'aria-hidden'."; @@ -631,7 +631,7 @@ public function testInvalidAriaHiddenAttributes($value, $msg = null) /** * @return array */ - public function invalidAriaHiddenAttributesProvider() + public function invalidAriaHiddenAttributesProvider(): array { return [ ['false'], diff --git a/test/qtismtest/data/content/DirectionTest.php b/test/qtismtest/data/content/DirectionTest.php index f116aa27c..f52470867 100644 --- a/test/qtismtest/data/content/DirectionTest.php +++ b/test/qtismtest/data/content/DirectionTest.php @@ -13,7 +13,7 @@ class DirectionTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return Direction::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'auto', @@ -33,7 +33,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'AUTO', @@ -45,7 +45,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ Direction::AUTO, diff --git a/test/qtismtest/data/content/InfoControlTest.php b/test/qtismtest/data/content/InfoControlTest.php index c43dcc8a6..a1c035051 100644 --- a/test/qtismtest/data/content/InfoControlTest.php +++ b/test/qtismtest/data/content/InfoControlTest.php @@ -11,7 +11,7 @@ */ class InfoControlTest extends QtiSmTestCase { - public function testSetTitleWrongType() + public function testSetTitleWrongType(): void { $infoControl = new InfoControl(); diff --git a/test/qtismtest/data/content/MathTest.php b/test/qtismtest/data/content/MathTest.php index e73ae720c..3b4f45c58 100644 --- a/test/qtismtest/data/content/MathTest.php +++ b/test/qtismtest/data/content/MathTest.php @@ -13,7 +13,7 @@ */ class MathTest extends QtiSmTestCase { - public function testMalformedXml() + public function testMalformedXml(): void { $xml = ''; $math = new Math($xml); @@ -22,7 +22,7 @@ public function testMalformedXml() $dom = $math->getXml(); } - public function testWrongNamespace() + public function testWrongNamespace(): void { $xml = ''; $math = new Math($xml); @@ -31,7 +31,7 @@ public function testWrongNamespace() $dom = $math->getXml(); } - public function testCorrect() + public function testCorrect(): void { $xml = ''; $math = new Math($xml); diff --git a/test/qtismtest/data/content/ModalFeedbackRuleTest.php b/test/qtismtest/data/content/ModalFeedbackRuleTest.php index 1653ea9b1..b03cf39e2 100644 --- a/test/qtismtest/data/content/ModalFeedbackRuleTest.php +++ b/test/qtismtest/data/content/ModalFeedbackRuleTest.php @@ -12,28 +12,28 @@ */ class ModalFeedbackRuleTest extends QtiSmTestCase { - public function testCreateWrongOutcomeIdentifier() + public function testCreateWrongOutcomeIdentifier(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'outcomeIdentifier' argument must be a valid QTI identifier, '999' given."); $modalFeedbackRule = new ModalFeedbackRule(999, ShowHide::SHOW, 'IDENTIFIER', 'Title'); } - public function testCreateWrongShowHide() + public function testCreateWrongShowHide(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'showHide' argument must be a value from the ShowHide enumeration, 'boolean' given."); $modalFeedbackRule = new ModalFeedbackRule('OUTCOME', true, 'IDENTIFIER', 'Title'); } - public function testCreateWrongIdentifier() + public function testCreateWrongIdentifier(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'identifier' argument must be a valid QTI identifier, '999' given."); $modalFeedbackRule = new ModalFeedbackRule('OUTCOME', ShowHide::SHOW, 999, 'Title'); } - public function testCreateWrongTitle() + public function testCreateWrongTitle(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'title' argument must be a string, 'boolean' given."); diff --git a/test/qtismtest/data/content/PrintedVariableTest.php b/test/qtismtest/data/content/PrintedVariableTest.php index ade8f7a75..b62400984 100644 --- a/test/qtismtest/data/content/PrintedVariableTest.php +++ b/test/qtismtest/data/content/PrintedVariableTest.php @@ -11,7 +11,7 @@ */ class PrintedVariableTest extends QtiSmTestCase { - public function testCreatePrintedVariableWrongIdentifier() + public function testCreatePrintedVariableWrongIdentifier(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'identifier' argument must be a valid QTI identifier, '999' given."); @@ -23,7 +23,7 @@ public function testCreatePrintedVariableWrongIdentifier() * @dataProvider tooLongStrings * @param string $string */ - public function testSetFormatWrongType(string $string) + public function testSetFormatWrongType(string $string): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'format' argument must be a string with at most 256 characters, '" . $string . "' given."); @@ -32,7 +32,7 @@ public function testSetFormatWrongType(string $string) $printedVariable->setFormat($string); } - public function testSetPowerFormWrongType() + public function testSetPowerFormWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'powerForm' argument must be a boolean value, 'integer' given."); @@ -41,7 +41,7 @@ public function testSetPowerFormWrongType() $printedVariable->setPowerForm(999); } - public function testSetBaseWrongType() + public function testSetBaseWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'base' argument must be an integer or a variable reference, '999.9' given."); @@ -50,7 +50,7 @@ public function testSetBaseWrongType() $printedVariable->setBase(999.9); } - public function testSetIndexWrongType() + public function testSetIndexWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'index' argument must be an integer or a variable reference, '999.9' given."); diff --git a/test/qtismtest/data/content/StylesheetTest.php b/test/qtismtest/data/content/StylesheetTest.php index b2d87f2af..e2cd644cc 100644 --- a/test/qtismtest/data/content/StylesheetTest.php +++ b/test/qtismtest/data/content/StylesheetTest.php @@ -11,7 +11,7 @@ */ class StylesheetTest extends QtiSmTestCase { - public function testCreateWrongHref() + public function testCreateWrongHref(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Href must be a string, 'integer' given."); @@ -19,7 +19,7 @@ public function testCreateWrongHref() $stylesheet = new Stylesheet(999); } - public function testSetInvalidType() + public function testSetInvalidType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Type must be a string, 'integer' given."); @@ -28,7 +28,7 @@ public function testSetInvalidType() $stylesheet->setType(999); } - public function testSetInvalidMedia() + public function testSetInvalidMedia(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Media must be a string, 'integer' given."); @@ -37,7 +37,7 @@ public function testSetInvalidMedia() $stylesheet->setMedia(999); } - public function testSetInvalidTitle() + public function testSetInvalidTitle(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Title must be a string, 'integer' given."); diff --git a/test/qtismtest/data/content/enums/AriaLiveTest.php b/test/qtismtest/data/content/enums/AriaLiveTest.php index 682bf1fed..e31538525 100644 --- a/test/qtismtest/data/content/enums/AriaLiveTest.php +++ b/test/qtismtest/data/content/enums/AriaLiveTest.php @@ -34,7 +34,7 @@ class AriaLiveTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return AriaLive::class; } @@ -42,7 +42,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'off', @@ -54,7 +54,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'OFF', @@ -66,7 +66,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ AriaLive::OFF, diff --git a/test/qtismtest/data/content/enums/AriaOrientationTest.php b/test/qtismtest/data/content/enums/AriaOrientationTest.php index 62bbff157..bfea477b9 100644 --- a/test/qtismtest/data/content/enums/AriaOrientationTest.php +++ b/test/qtismtest/data/content/enums/AriaOrientationTest.php @@ -34,7 +34,7 @@ class AriaOrientationTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return AriaOrientation::class; } @@ -42,7 +42,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'horizontal', @@ -53,7 +53,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'HORIZONTAL', @@ -64,7 +64,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ AriaOrientation::HORIZONTAL, diff --git a/test/qtismtest/data/content/interactions/AssociableHotspotTest.php b/test/qtismtest/data/content/interactions/AssociableHotspotTest.php index a40d2a55a..6bcb4a9f4 100644 --- a/test/qtismtest/data/content/interactions/AssociableHotspotTest.php +++ b/test/qtismtest/data/content/interactions/AssociableHotspotTest.php @@ -13,7 +13,7 @@ */ class AssociableHotspotTest extends QtiSmTestCase { - public function testCreateInvalidMatchMax() + public function testCreateInvalidMatchMax(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'matchMax' argument must be a positive integer, 'boolean' given."); @@ -21,7 +21,7 @@ public function testCreateInvalidMatchMax() new AssociableHotspot('identifier', true, QtiShape::RECT, new QtiCoords(QtiShape::RECT, [0, 0, 1, 1])); } - public function testCreateInvalidShape() + public function testCreateInvalidShape(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'shape' argument must be a value from the Shape enumeration, '1' given."); @@ -29,7 +29,7 @@ public function testCreateInvalidShape() new AssociableHotspot('identifier', 1, true, new QtiCoords(QtiShape::RECT, [0, 0, 1, 1])); } - public function testSetInvalidMatchMin() + public function testSetInvalidMatchMin(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'matchMin' argument must be a positive integer, 'boolean' given."); @@ -38,7 +38,7 @@ public function testSetInvalidMatchMin() $associableHotspot->setMatchMin(true); } - public function testSetInvalidHotspotLabel() + public function testSetInvalidHotspotLabel(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'hotspotLabel' argument must be a string value with at most 256 characters."); diff --git a/test/qtismtest/data/content/interactions/AssociateInteractionTest.php b/test/qtismtest/data/content/interactions/AssociateInteractionTest.php index d872f1510..11576bc68 100644 --- a/test/qtismtest/data/content/interactions/AssociateInteractionTest.php +++ b/test/qtismtest/data/content/interactions/AssociateInteractionTest.php @@ -13,14 +13,14 @@ */ class AssociateInteractionTest extends QtiSmTestCase { - public function testCreateNoAssociableChoices() + public function testCreateNoAssociableChoices(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('An AssociateInteraction object must be composed of at lease one SimpleAssociableChoice object, none given.'); $associateInteraction = new AssociateInteraction('RESPONSE', new SimpleAssociableChoiceCollection()); } - public function testSetMinAssociations() + public function testSetMinAssociations(): void { $associateInteraction = new AssociateInteraction('RESPONSE', new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('identifier', 1)])); $associateInteraction->setMinAssociations(1); @@ -28,7 +28,7 @@ public function testSetMinAssociations() $this::assertTrue($associateInteraction->hasMinAssociations()); } - public function testSetMinAssociationsWrongType() + public function testSetMinAssociationsWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'minAssociations' argument must be a positive (>= 0) integer, 'boolean' given."); @@ -37,7 +37,7 @@ public function testSetMinAssociationsWrongType() $associateInteraction->setMinAssociations(true); } - public function testSetMinAssociationsIllogicValue() + public function testSetMinAssociationsIllogicValue(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'minAssociations' argument must be less than or equal to the limit imposed by 'maxAssociations'."); @@ -47,7 +47,7 @@ public function testSetMinAssociationsIllogicValue() $associateInteraction->setMinAssociations(3); } - public function testSetMaxAssociationsWrongType() + public function testSetMaxAssociationsWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'maxAssociations' argument must be a positive (>= 0) integer, 'boolean' given."); @@ -56,7 +56,7 @@ public function testSetMaxAssociationsWrongType() $associateInteraction->setMaxAssociations(true); } - public function testSetShuffleWrongType() + public function testSetShuffleWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'shuffle' argument must be a boolean value, 'string' given."); diff --git a/test/qtismtest/data/content/interactions/ChoiceInteractionTest.php b/test/qtismtest/data/content/interactions/ChoiceInteractionTest.php index 7d5a9083f..13a03e1bb 100644 --- a/test/qtismtest/data/content/interactions/ChoiceInteractionTest.php +++ b/test/qtismtest/data/content/interactions/ChoiceInteractionTest.php @@ -13,7 +13,7 @@ */ class ChoiceInteractionTest extends QtiSmTestCase { - public function testCreateEmptyChoiceList() + public function testCreateEmptyChoiceList(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A ChoiceInteraction object must be composed of at lease one SimpleChoice object, none given.'); @@ -21,7 +21,7 @@ public function testCreateEmptyChoiceList() new ChoiceInteraction('RESPONSE', new SimpleChoiceCollection()); } - public function testSetShuffleWrongType() + public function testSetShuffleWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'shuffle' argument must be a boolean value, 'string' given."); @@ -30,7 +30,7 @@ public function testSetShuffleWrongType() $choiceInteraction->setShuffle('true'); } - public function testSetMaxChoicesWrongType() + public function testSetMaxChoicesWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'maxChoices' argument must be a positive (>= 0) integer, 'string' given."); @@ -39,7 +39,7 @@ public function testSetMaxChoicesWrongType() $choiceInteraction->setMaxChoices('3'); } - public function testSetMinChoicesWrongType() + public function testSetMinChoicesWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'minChoices' argument must be a positive (>= 0) integer, 'string' given."); @@ -48,7 +48,7 @@ public function testSetMinChoicesWrongType() $choiceInteraction->setMinChoices('3'); } - public function testSetOrientationWrongType() + public function testSetOrientationWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'orientation' argument must be a value from the Orientation enumeration, 'boolean' given."); diff --git a/test/qtismtest/data/content/interactions/ExtendedTextInteractionTest.php b/test/qtismtest/data/content/interactions/ExtendedTextInteractionTest.php index d38010407..7270ddba1 100644 --- a/test/qtismtest/data/content/interactions/ExtendedTextInteractionTest.php +++ b/test/qtismtest/data/content/interactions/ExtendedTextInteractionTest.php @@ -11,7 +11,7 @@ */ class ExtendedTextInteractionTest extends QtiSmTestCase { - public function testSetBaseWrongType() + public function testSetBaseWrongType(): void { $extendedTextInteraction = new ExtendedTextInteraction('RESPONSE'); @@ -21,7 +21,7 @@ public function testSetBaseWrongType() $extendedTextInteraction->setBase('wrong'); } - public function testSetResponseIdentifierWrongType() + public function testSetResponseIdentifierWrongType(): void { $extendedTextInteraction = new ExtendedTextInteraction('RESPONSE'); @@ -31,7 +31,7 @@ public function testSetResponseIdentifierWrongType() $extendedTextInteraction->setResponseIdentifier(1337); } - public function testSetExpectedLengthWrongType() + public function testSetExpectedLengthWrongType(): void { $extendedTextInteraction = new ExtendedTextInteraction('RESPONSE'); @@ -45,7 +45,7 @@ public function testSetExpectedLengthWrongType() * @dataProvider nonNegativeIntegersForExpectedLengthAndLines * @param integer $expectedLength */ - public function testSetExpectedLengthToNonNegativeInteger($expectedLength) + public function testSetExpectedLengthToNonNegativeInteger($expectedLength): void { $textEntryInteraction = new ExtendedTextInteraction('RESPONSE'); @@ -55,7 +55,7 @@ public function testSetExpectedLengthToNonNegativeInteger($expectedLength) $this::assertEquals($expectedLength, $textEntryInteraction->getExpectedLength()); } - public function testSetExpectedLengthToNegativeIntegerThrowsException() + public function testSetExpectedLengthToNegativeIntegerThrowsException(): void { $textEntryInteraction = new ExtendedTextInteraction('RESPONSE'); @@ -65,17 +65,17 @@ public function testSetExpectedLengthToNegativeIntegerThrowsException() $textEntryInteraction->setExpectedLength(-1); } - public function testUnsetExpectedLengthWithNull() + public function testUnsetExpectedLengthWithNull(): void { $textEntryInteraction = new ExtendedTextInteraction('RESPONSE'); $textEntryInteraction->setExpectedLength(null); $this::assertFalse($textEntryInteraction->hasExpectedLength()); - $this::assertNull($textEntryInteraction->getExpectedLength()); + $this::assertTrue($textEntryInteraction->getExpectedLength() === -1); } - public function testSetPatternMaskWrongType() + public function testSetPatternMaskWrongType(): void { $extendedTextInteraction = new ExtendedTextInteraction('RESPONSE'); @@ -85,7 +85,7 @@ public function testSetPatternMaskWrongType() $extendedTextInteraction->setPatternMask(true); } - public function testSetPlaceholderTextWrongType() + public function testSetPlaceholderTextWrongType(): void { $extendedTextInteraction = new ExtendedTextInteraction('RESPONSE'); @@ -95,7 +95,7 @@ public function testSetPlaceholderTextWrongType() $extendedTextInteraction->setPlaceholderText(true); } - public function testSetMaxStringsWrongType() + public function testSetMaxStringsWrongType(): void { $extendedTextInteraction = new ExtendedTextInteraction('RESPONSE'); @@ -105,7 +105,7 @@ public function testSetMaxStringsWrongType() $extendedTextInteraction->setMaxStrings(true); } - public function testSetMinStringsWrongType() + public function testSetMinStringsWrongType(): void { $extendedTextInteraction = new ExtendedTextInteraction('RESPONSE'); @@ -115,7 +115,7 @@ public function testSetMinStringsWrongType() $extendedTextInteraction->setMinStrings(true); } - public function testSetExpectedLinesWrongType() + public function testSetExpectedLinesWrongType(): void { $extendedTextInteraction = new ExtendedTextInteraction('RESPONSE'); @@ -129,7 +129,7 @@ public function testSetExpectedLinesWrongType() * @dataProvider nonNegativeIntegersForExpectedLengthAndLines * @param integer $expectedLines */ - public function testSetExpectedLinesToNonNegativeInteger($expectedLines) + public function testSetExpectedLinesToNonNegativeInteger($expectedLines): void { $textEntryInteraction = new ExtendedTextInteraction('RESPONSE'); @@ -139,7 +139,7 @@ public function testSetExpectedLinesToNonNegativeInteger($expectedLines) $this::assertEquals($expectedLines, $textEntryInteraction->getExpectedLines()); } - public function testSetExpectedLinesToNegativeIntegerThrowsException() + public function testSetExpectedLinesToNegativeIntegerThrowsException(): void { $textEntryInteraction = new ExtendedTextInteraction('RESPONSE'); @@ -149,7 +149,7 @@ public function testSetExpectedLinesToNegativeIntegerThrowsException() $textEntryInteraction->setExpectedLines(-1); } - public function testUnsetExpectedLinesWithNull() + public function testUnsetExpectedLinesWithNull(): void { $textEntryInteraction = new ExtendedTextInteraction('RESPONSE'); @@ -169,7 +169,7 @@ public function nonNegativeIntegersForExpectedLengthAndLines(): array ]; } - public function testSetFormatWrongType() + public function testSetFormatWrongType(): void { $extendedTextInteraction = new ExtendedTextInteraction('RESPONSE'); diff --git a/test/qtismtest/data/content/interactions/GraphicAssociateInteractionTest.php b/test/qtismtest/data/content/interactions/GraphicAssociateInteractionTest.php index 6a8d57304..e6057dca6 100644 --- a/test/qtismtest/data/content/interactions/GraphicAssociateInteractionTest.php +++ b/test/qtismtest/data/content/interactions/GraphicAssociateInteractionTest.php @@ -16,7 +16,7 @@ */ class GraphicAssociateInteractionTest extends QtiSmTestCase { - public function testCreateNotEnoughAssociableHotspots() + public function testCreateNotEnoughAssociableHotspots(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A GraphicAssociateInteraction must be composed of at least 1 AssociableHotspot object, none given.'); @@ -28,7 +28,7 @@ public function testCreateNotEnoughAssociableHotspots() ); } - public function testSetMaxAssociationsWrongType() + public function testSetMaxAssociationsWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'maxAssociations' argument must be a positive (>= 0) integer, 'boolean' given."); @@ -44,7 +44,7 @@ public function testSetMaxAssociationsWrongType() $interaction->setMaxAssociations(true); } - public function testSetMinAssociationsWrongType() + public function testSetMinAssociationsWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'minAssociations' argument must be a positive (>= 0) integer, 'boolean'."); @@ -61,7 +61,7 @@ public function testSetMinAssociationsWrongType() $interaction->setMinAssociations(true); } - public function testSetMinAssociationsInvalidValue() + public function testSetMinAssociationsInvalidValue(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'minAssociations' argument must be less than or equal to the limit imposed by 'maxAssociations'."); diff --git a/test/qtismtest/data/content/interactions/GraphicOrderInteractionTest.php b/test/qtismtest/data/content/interactions/GraphicOrderInteractionTest.php index 0d65abcfa..94d046d49 100644 --- a/test/qtismtest/data/content/interactions/GraphicOrderInteractionTest.php +++ b/test/qtismtest/data/content/interactions/GraphicOrderInteractionTest.php @@ -16,7 +16,7 @@ */ class GraphicOrderInteractionTest extends QtiSmTestCase { - public function testCreateNotEnoughHotspotChoices() + public function testCreateNotEnoughHotspotChoices(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A GraphicOrderInteraction must contain at least 1 hotspotChoice object. None given.'); @@ -24,7 +24,7 @@ public function testCreateNotEnoughHotspotChoices() $graphicOrderInteraction = new GraphicOrderInteraction('RESPONSE', new ObjectElement('http://my-data/data.png', 'image/png'), new HotSpotChoiceCollection()); } - public function testTooLargeMinChoices() + public function testTooLargeMinChoices(): void { $choices = new HotSpotChoiceCollection([new HotspotChoice('identifier1', QtiShape::RECT, new QtiCoords(QtiShape::RECT, [0, 0, 1, 1])), new HotspotChoice('identifier2', QtiShape::RECT, new QtiCoords(QtiShape::RECT, [0, 0, 1, 1]))]); $graphicOrderInteraction = new GraphicOrderInteraction('RESPONSE', new ObjectElement('http://my-data/data.png', 'image/png'), $choices); @@ -35,7 +35,7 @@ public function testTooLargeMinChoices() $graphicOrderInteraction->setMinChoices(3); } - public function testSetMinChoicesWrongType() + public function testSetMinChoicesWrongType(): void { $choices = new HotSpotChoiceCollection([new HotspotChoice('identifier1', QtiShape::RECT, new QtiCoords(QtiShape::RECT, [0, 0, 1, 1])), new HotspotChoice('identifier2', QtiShape::RECT, new QtiCoords(QtiShape::RECT, [0, 0, 1, 1]))]); $graphicOrderInteraction = new GraphicOrderInteraction('RESPONSE', new ObjectElement('http://my-data/data.png', 'image/png'), $choices); @@ -46,7 +46,7 @@ public function testSetMinChoicesWrongType() $graphicOrderInteraction->setMinChoices('3'); } - public function testSetMaxChoicesWrongType() + public function testSetMaxChoicesWrongType(): void { $choices = new HotSpotChoiceCollection([new HotspotChoice('identifier1', QtiShape::RECT, new QtiCoords(QtiShape::RECT, [0, 0, 1, 1])), new HotspotChoice('identifier2', QtiShape::RECT, new QtiCoords(QtiShape::RECT, [0, 0, 1, 1]))]); $graphicOrderInteraction = new GraphicOrderInteraction('RESPONSE', new ObjectElement('http://my-data/data.png', 'image/png'), $choices); @@ -57,7 +57,7 @@ public function testSetMaxChoicesWrongType() $graphicOrderInteraction->setMaxChoices('3'); } - public function testSetMaxDoesNotExceedsMinChoices() + public function testSetMaxDoesNotExceedsMinChoices(): void { $choices = new HotSpotChoiceCollection([new HotspotChoice('identifier1', QtiShape::RECT, new QtiCoords(QtiShape::RECT, [0, 0, 1, 1])), new HotspotChoice('identifier2', QtiShape::RECT, new QtiCoords(QtiShape::RECT, [0, 0, 1, 1]))]); $graphicOrderInteraction = new GraphicOrderInteraction('RESPONSE', new ObjectElement('http://my-data/data.png', 'image/png'), $choices); diff --git a/test/qtismtest/data/content/interactions/HottextInteractionTest.php b/test/qtismtest/data/content/interactions/HottextInteractionTest.php index dffbf4ed5..700661fa8 100644 --- a/test/qtismtest/data/content/interactions/HottextInteractionTest.php +++ b/test/qtismtest/data/content/interactions/HottextInteractionTest.php @@ -15,7 +15,7 @@ */ class HottextInteractionTest extends QtiSmTestCase { - public function testCreateNoContent() + public function testCreateNoContent(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A HottextInteraction object must be composed of at least one BlockStatic object, none given.'); @@ -23,7 +23,7 @@ public function testCreateNoContent() new HottextInteraction('RESPONSE', new BlockStaticCollection()); } - public function testSetMaxChoicesInvalidValue() + public function testSetMaxChoicesInvalidValue(): void { $div = new Div(); $div->setContent(new FlowCollection([new TextRun('content...')])); @@ -35,7 +35,7 @@ public function testSetMaxChoicesInvalidValue() $hottextInteraction->setMaxChoices(true); } - public function testSetMinChoicesInvalidValue() + public function testSetMinChoicesInvalidValue(): void { $div = new Div(); $div->setContent(new FlowCollection([new TextRun('content...')])); @@ -47,7 +47,7 @@ public function testSetMinChoicesInvalidValue() $hottextInteraction->setMinChoices(true); } - public function testSetMinChoicesInvalidValueRegardingMaxChoices() + public function testSetMinChoicesInvalidValueRegardingMaxChoices(): void { $div = new Div(); $div->setContent(new FlowCollection([new TextRun('content...')])); @@ -60,7 +60,7 @@ public function testSetMinChoicesInvalidValueRegardingMaxChoices() $hottextInteraction->setMinChoices(2); } - public function testSetMinChoicesValidValueWhenMaxChoicesIsZero() + public function testSetMinChoicesValidValueWhenMaxChoicesIsZero(): void { $div = new Div(); $div->setContent(new FlowCollection([new TextRun('content...')])); diff --git a/test/qtismtest/data/content/interactions/MatchInteractionTest.php b/test/qtismtest/data/content/interactions/MatchInteractionTest.php index 91df57c63..717be57de 100644 --- a/test/qtismtest/data/content/interactions/MatchInteractionTest.php +++ b/test/qtismtest/data/content/interactions/MatchInteractionTest.php @@ -15,7 +15,7 @@ */ class MatchInteractionTest extends QtiSmTestCase { - public function testSetShuffleWrongType() + public function testSetShuffleWrongType(): void { $matchSet1 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceA', 1)])); $matchSet2 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceB', 1)])); @@ -34,7 +34,7 @@ public function testSetShuffleWrongType() $matchInteraction->setShuffle('true'); } - public function testSetMaxAssociationsWrongType() + public function testSetMaxAssociationsWrongType(): void { $matchSet1 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceA', 1)])); $matchSet2 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceB', 1)])); @@ -53,7 +53,7 @@ public function testSetMaxAssociationsWrongType() $matchInteraction->setMaxAssociations('true'); } - public function testSetMinAssociationsWrongType() + public function testSetMinAssociationsWrongType(): void { $matchSet1 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceA', 1)])); $matchSet2 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceB', 1)])); @@ -72,7 +72,7 @@ public function testSetMinAssociationsWrongType() $matchInteraction->setMinAssociations('true'); } - public function testSetMinAssociationsWrongValue() + public function testSetMinAssociationsWrongValue(): void { $matchSet1 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceA', 1)])); $matchSet2 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceB', 1)])); @@ -92,7 +92,7 @@ public function testSetMinAssociationsWrongValue() $matchInteraction->setMinAssociations(4); } - public function testHasMinAssociations() + public function testHasMinAssociations(): void { $matchSet1 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceA', 1)])); $matchSet2 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceB', 1)])); @@ -108,7 +108,7 @@ public function testHasMinAssociations() $this::assertFalse($matchInteraction->hasMinAssociations()); } - public function testNotEnoughMatchSets() + public function testNotEnoughMatchSets(): void { $matchSet1 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceA', 1)])); @@ -123,7 +123,7 @@ public function testNotEnoughMatchSets() ); } - public function testGetSourceChoices() + public function testGetSourceChoices(): void { $matchSet1 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceA', 1)])); $matchSet2 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceB', 1)])); @@ -139,7 +139,7 @@ public function testGetSourceChoices() $this::assertSame($matchSet1, $matchInteraction->getSourceChoices()); } - public function testGetTargetChoices() + public function testGetTargetChoices(): void { $matchSet1 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceA', 1)])); $matchSet2 = new SimpleMatchSet(new SimpleAssociableChoiceCollection([new SimpleAssociableChoice('ChoiceB', 1)])); diff --git a/test/qtismtest/data/content/interactions/MediaInteractionTest.php b/test/qtismtest/data/content/interactions/MediaInteractionTest.php index 73055e800..6cd89cc4e 100644 --- a/test/qtismtest/data/content/interactions/MediaInteractionTest.php +++ b/test/qtismtest/data/content/interactions/MediaInteractionTest.php @@ -12,7 +12,7 @@ */ class MediaInteractionTest extends QtiSmTestCase { - public function testCreateWrongAutostartType() + public function testCreateWrongAutostartType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'autostart' argument must be a boolean value, 'integer' given."); @@ -20,7 +20,7 @@ public function testCreateWrongAutostartType() $mediaInteraction = new MediaInteraction('RESPONSE', 999, new ObjectElement('http://myobject.com/video.mpg', 'video/mpeg')); } - public function testSetMinPlaysWrongType() + public function testSetMinPlaysWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'minPlays' argument must be a positive (>= 0) integer, 'boolean' given."); @@ -29,7 +29,7 @@ public function testSetMinPlaysWrongType() $mediaInteraction->setMinPlays(true); } - public function testSetMaxPlaysWrongType() + public function testSetMaxPlaysWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'maxPlays' argument must be a positive (>= 0) integer, 'boolean' given."); @@ -38,7 +38,7 @@ public function testSetMaxPlaysWrongType() $mediaInteraction->setMaxPlays(true); } - public function testSetLoopWrongType() + public function testSetLoopWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'loop' argument must be a boolean value, 'integer' given."); @@ -47,7 +47,7 @@ public function testSetLoopWrongType() $mediaInteraction->setLoop(999); } - public function testHasMinMAxPlays() + public function testHasMinMAxPlays(): void { $mediaInteraction = new MediaInteraction('RESPONSE', true, new ObjectElement('http://myobject.com/video.mpg', 'video/mpeg')); $mediaInteraction->setMinPlays(1); diff --git a/test/qtismtest/data/content/interactions/OrderInteractionTest.php b/test/qtismtest/data/content/interactions/OrderInteractionTest.php index e1a2c4ff5..8bb181052 100644 --- a/test/qtismtest/data/content/interactions/OrderInteractionTest.php +++ b/test/qtismtest/data/content/interactions/OrderInteractionTest.php @@ -13,7 +13,7 @@ */ class OrderInteractionTest extends QtiSmTestCase { - public function testNotEnoughChoices() + public function testNotEnoughChoices(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('An OrderInteraction object must be composed of at lease one SimpleChoice object, none given'); @@ -24,7 +24,7 @@ public function testNotEnoughChoices() ); } - public function testSetShuffleWrongType() + public function testSetShuffleWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'shuffle' argument must be a boolean value, 'string' given"); @@ -42,7 +42,7 @@ public function testSetShuffleWrongType() $orderInteraction->setShuffle('true'); } - public function testSetMinChoicesWrongType() + public function testSetMinChoicesWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'minChoices' argument must be a strictly positive (> 0) integer or -1, 'string' given."); @@ -60,7 +60,7 @@ public function testSetMinChoicesWrongType() $orderInteraction->setMinChoices('true'); } - public function testSetMinChoicesChoicesOverflow() + public function testSetMinChoicesChoicesOverflow(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The value of 'minChoices' cannot exceed the number of available choices."); @@ -78,7 +78,7 @@ public function testSetMinChoicesChoicesOverflow() $orderInteraction->setMinChoices(3); } - public function testSetMaxChoicesWrongType() + public function testSetMaxChoicesWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'maxChoices' argument must be a strictly positive (> 0) integer or -1, 'string' given."); @@ -96,7 +96,7 @@ public function testSetMaxChoicesWrongType() $orderInteraction->setMaxChoices('true'); } - public function testSetMaxChoicesOverflow() + public function testSetMaxChoicesOverflow(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'maxChoices' argument cannot exceed the number of available choices."); @@ -115,7 +115,7 @@ public function testSetMaxChoicesOverflow() $orderInteraction->setMaxChoices(3); } - public function testSetOrientationWrongType() + public function testSetOrientationWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'orientation' argument must be a value from the Orientation enumeration, 'string' given."); diff --git a/test/qtismtest/data/content/interactions/OrientationTest.php b/test/qtismtest/data/content/interactions/OrientationTest.php index 7f3d1969e..86a473b1e 100644 --- a/test/qtismtest/data/content/interactions/OrientationTest.php +++ b/test/qtismtest/data/content/interactions/OrientationTest.php @@ -13,7 +13,7 @@ class OrientationTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return Orientation::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'vertical', @@ -32,7 +32,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'VERTICAL', @@ -43,7 +43,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ Orientation::VERTICAL, diff --git a/test/qtismtest/data/content/interactions/PositionObjectInteractionTest.php b/test/qtismtest/data/content/interactions/PositionObjectInteractionTest.php index 100d90a0d..c96d88960 100644 --- a/test/qtismtest/data/content/interactions/PositionObjectInteractionTest.php +++ b/test/qtismtest/data/content/interactions/PositionObjectInteractionTest.php @@ -14,7 +14,7 @@ */ class PositionObjectInteractionTest extends QtiSmTestCase { - public function testSetMinChoicesValidValueWhenMaxChoicesIsZero() + public function testSetMinChoicesValidValueWhenMaxChoicesIsZero(): void { $div = new Div(); $div->setContent(new FlowCollection([new TextRun('content...')])); diff --git a/test/qtismtest/data/content/interactions/SimpleChoiceTest.php b/test/qtismtest/data/content/interactions/SimpleChoiceTest.php index 6b964eb68..5f328c6a6 100644 --- a/test/qtismtest/data/content/interactions/SimpleChoiceTest.php +++ b/test/qtismtest/data/content/interactions/SimpleChoiceTest.php @@ -11,7 +11,7 @@ */ class ChoiceTest extends QtiSmTestCase { - public function testCreateChoiceWrongIdentifier() + public function testCreateChoiceWrongIdentifier(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'identifier' argument must be a valid QTI identifier"); @@ -19,7 +19,7 @@ public function testCreateChoiceWrongIdentifier() $choice = new SimpleChoice('999'); } - public function testSetFixedWrongType() + public function testSetFixedWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'fixed' argument must be a boolean value, 'string' given."); @@ -28,7 +28,7 @@ public function testSetFixedWrongType() $choice->setFixed('bla'); } - public function testSetTemplateIdentifierWrongType() + public function testSetTemplateIdentifierWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'templateIdentifier' must be an empty string or a valid QTI identifier, 'integer' given."); @@ -37,7 +37,7 @@ public function testSetTemplateIdentifierWrongType() $choice->setTemplateIdentifier(999); } - public function testSetShowHideWrongType() + public function testSetShowHideWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'showHide' argument must be a value from the ShowHide enumeration."); diff --git a/test/qtismtest/data/content/interactions/SliderInteractionTest.php b/test/qtismtest/data/content/interactions/SliderInteractionTest.php index 07ee39f01..c73a1eef3 100644 --- a/test/qtismtest/data/content/interactions/SliderInteractionTest.php +++ b/test/qtismtest/data/content/interactions/SliderInteractionTest.php @@ -11,7 +11,7 @@ */ class SliderInteractionTest extends QtiSmTestCase { - public function testCreateSliderInteractionLowerBoundWrongType() + public function testCreateSliderInteractionLowerBoundWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'lowerBound' argument must be a float value, 'integer' given."); @@ -19,7 +19,7 @@ public function testCreateSliderInteractionLowerBoundWrongType() $sliderInteraction = new SliderInteraction('RESPONSE', 3, 3.33); } - public function testCreateSliderInteractionUpperBoundWrongType() + public function testCreateSliderInteractionUpperBoundWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'upperBound' argument must be a float value, 'integer' given."); @@ -27,7 +27,7 @@ public function testCreateSliderInteractionUpperBoundWrongType() $sliderInteraction = new SliderInteraction('RESPONSE', 3.33, 3); } - public function testSetStepNegative() + public function testSetStepNegative(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'step' argument must be a positive (>= 0) integer, 'integer' given."); @@ -36,7 +36,7 @@ public function testSetStepNegative() $sliderInteraction->setStep(-5); } - public function testSetStepLabelNonBoolean() + public function testSetStepLabelNonBoolean(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'stepLabel' argument must be a boolean value, 'string' given."); @@ -45,7 +45,7 @@ public function testSetStepLabelNonBoolean() $sliderInteraction->setStepLabel('true'); } - public function testSetOrientationWrongValue() + public function testSetOrientationWrongValue(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'orientation' argument must be a value from the Orientation enumeration."); @@ -54,7 +54,7 @@ public function testSetOrientationWrongValue() $sliderInteraction->setOrientation('true'); } - public function testSetReverseWrongValue() + public function testSetReverseWrongValue(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'reverse' argument must be a boolean value, 'string' given."); diff --git a/test/qtismtest/data/content/interactions/TextFormatTest.php b/test/qtismtest/data/content/interactions/TextFormatTest.php index f9118be21..e00291698 100644 --- a/test/qtismtest/data/content/interactions/TextFormatTest.php +++ b/test/qtismtest/data/content/interactions/TextFormatTest.php @@ -13,7 +13,7 @@ class TextFormatTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return TextFormat::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'plain', @@ -33,7 +33,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'PLAIN', @@ -45,7 +45,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ TextFormat::PLAIN, diff --git a/test/qtismtest/data/content/interactions/TextInteractionTest.php b/test/qtismtest/data/content/interactions/TextInteractionTest.php index 10f45fe49..23947b770 100644 --- a/test/qtismtest/data/content/interactions/TextInteractionTest.php +++ b/test/qtismtest/data/content/interactions/TextInteractionTest.php @@ -11,7 +11,7 @@ */ class TextInteractionTest extends QtiSmTestCase { - public function testSetBaseWrongType() + public function testSetBaseWrongType(): void { $textEntryInteraction = new TextEntryInteraction('RESPONSE'); @@ -21,7 +21,7 @@ public function testSetBaseWrongType() $textEntryInteraction->setBase(true); } - public function testSetStringIdentifierWrongType() + public function testSetStringIdentifierWrongType(): void { $textEntryInteraction = new TextEntryInteraction('RESPONSE'); @@ -31,7 +31,7 @@ public function testSetStringIdentifierWrongType() $textEntryInteraction->setStringIdentifier(true); } - public function testSetExpectedLengthWrongType() + public function testSetExpectedLengthWrongType(): void { $textEntryInteraction = new TextEntryInteraction('RESPONSE'); @@ -45,7 +45,7 @@ public function testSetExpectedLengthWrongType() * @dataProvider nonNegativeIntegersForExpectedLength * @param integer $expectedLength */ - public function testSetExpectedLengthToNonNegativeInteger($expectedLength) + public function testSetExpectedLengthToNonNegativeInteger($expectedLength): void { $textEntryInteraction = new TextEntryInteraction('RESPONSE'); @@ -65,7 +65,7 @@ public function nonNegativeIntegersForExpectedLength(): array ]; } - public function testSetExpectedLengthToNegativeIntegerThrowsException() + public function testSetExpectedLengthToNegativeIntegerThrowsException(): void { $textEntryInteraction = new TextEntryInteraction('RESPONSE'); @@ -75,17 +75,17 @@ public function testSetExpectedLengthToNegativeIntegerThrowsException() $textEntryInteraction->setExpectedLength(-1); } - public function testUnsetExpectedLengthWithNull() + public function testUnsetExpectedLengthWithNull(): void { $textEntryInteraction = new TextEntryInteraction('RESPONSE'); $textEntryInteraction->setExpectedLength(null); $this::assertFalse($textEntryInteraction->hasExpectedLength()); - $this::assertNull($textEntryInteraction->getExpectedLength()); + $this::assertTrue($textEntryInteraction->getExpectedLength() === -1); } - public function testSetPatternMaskWrongType() + public function testSetPatternMaskWrongType(): void { $textEntryInteraction = new TextEntryInteraction('RESPONSE'); @@ -95,7 +95,7 @@ public function testSetPatternMaskWrongType() $textEntryInteraction->setPatternMask(true); } - public function testSetPlaceholderTextWrongType() + public function testSetPlaceholderTextWrongType(): void { $textEntryInteraction = new TextEntryInteraction('RESPONSE'); diff --git a/test/qtismtest/data/content/xhtml/ImgTest.php b/test/qtismtest/data/content/xhtml/ImgTest.php index 987131b07..738655bab 100644 --- a/test/qtismtest/data/content/xhtml/ImgTest.php +++ b/test/qtismtest/data/content/xhtml/ImgTest.php @@ -11,7 +11,7 @@ */ class ImgTest extends QtiSmTestCase { - public function testCreateInvalidAlt() + public function testCreateInvalidAlt(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'alt' argument must be a string, 'integer' given."); diff --git a/test/qtismtest/data/content/xhtml/ObjectTest.php b/test/qtismtest/data/content/xhtml/ObjectTest.php index 09e3b4cb1..d62d97406 100644 --- a/test/qtismtest/data/content/xhtml/ObjectTest.php +++ b/test/qtismtest/data/content/xhtml/ObjectTest.php @@ -11,7 +11,7 @@ */ class ObjectTest extends QtiSmTestCase { - public function testCreateWrongType() + public function testCreateWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'type' argument must be a non-empty string, 'integer' given."); diff --git a/test/qtismtest/data/content/xhtml/ParamTest.php b/test/qtismtest/data/content/xhtml/ParamTest.php index 3a95d24cf..8ddb3d171 100644 --- a/test/qtismtest/data/content/xhtml/ParamTest.php +++ b/test/qtismtest/data/content/xhtml/ParamTest.php @@ -12,28 +12,28 @@ */ class ParamTest extends QtiSmTestCase { - public function testCreateWrongNameType() + public function testCreateWrongNameType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'name' argument must be a string, 'integer' given."); $param = new Param(999, 'value', ParamType::DATA); } - public function testCreateWrongValueType() + public function testCreateWrongValueType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'value' argument must be a string, 'integer' given."); $param = new Param('name', 999, ParamType::DATA); } - public function testCreateNotParamType() + public function testCreateNotParamType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'valueType' argument must be a value from the ParamType enumeration, 'boolean' given."); $param = new Param('name', 'value', true); } - public function testCreateWrongTypeType() + public function testCreateWrongTypeType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The 'type' argument must be a string, 'integer' given."); diff --git a/test/qtismtest/data/content/xhtml/ParamTypeTest.php b/test/qtismtest/data/content/xhtml/ParamTypeTest.php index c7bf34b1b..e786a14b7 100644 --- a/test/qtismtest/data/content/xhtml/ParamTypeTest.php +++ b/test/qtismtest/data/content/xhtml/ParamTypeTest.php @@ -13,7 +13,7 @@ class ParamTypeTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return ParamType::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'DATA', @@ -32,7 +32,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'DATA', @@ -43,7 +43,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ ParamType::DATA, diff --git a/test/qtismtest/data/content/xhtml/html5/FigcaptionTest.php b/test/qtismtest/data/content/xhtml/html5/FigcaptionTest.php index 74c75fbbb..40761a95a 100644 --- a/test/qtismtest/data/content/xhtml/html5/FigcaptionTest.php +++ b/test/qtismtest/data/content/xhtml/html5/FigcaptionTest.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtismtest\data\content\xhtml\html5; use qtism\data\content\xhtml\html5\Figcaption; diff --git a/test/qtismtest/data/content/xhtml/html5/FigureTest.php b/test/qtismtest/data/content/xhtml/html5/FigureTest.php index fb2573625..e0efef590 100644 --- a/test/qtismtest/data/content/xhtml/html5/FigureTest.php +++ b/test/qtismtest/data/content/xhtml/html5/FigureTest.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtismtest\data\content\xhtml\html5; use qtism\data\content\xhtml\html5\Figure; diff --git a/test/qtismtest/data/content/xhtml/html5/RbTest.php b/test/qtismtest/data/content/xhtml/html5/RbTest.php index da09dfb45..b70fb60c8 100644 --- a/test/qtismtest/data/content/xhtml/html5/RbTest.php +++ b/test/qtismtest/data/content/xhtml/html5/RbTest.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtismtest\data\content\xhtml\html5; use qtism\data\content\xhtml\html5\Rb; @@ -27,7 +25,7 @@ class RbTest extends QtiSmTestCase { - const SUBJECT_QTI_CLASS_NAME = 'rb'; + public const SUBJECT_QTI_CLASS_NAME = 'rb'; public function testCreateWithValues(): void { diff --git a/test/qtismtest/data/content/xhtml/html5/RpTest.php b/test/qtismtest/data/content/xhtml/html5/RpTest.php index c94569e07..7e7ce8b6b 100644 --- a/test/qtismtest/data/content/xhtml/html5/RpTest.php +++ b/test/qtismtest/data/content/xhtml/html5/RpTest.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtismtest\data\content\xhtml\html5; use qtism\data\content\xhtml\html5\Rp; @@ -27,7 +25,7 @@ class RpTest extends QtiSmTestCase { - const SUBJECT_QTI_CLASS_NAME = 'rp'; + public const SUBJECT_QTI_CLASS_NAME = 'rp'; public function testCreateWithValues(): void { diff --git a/test/qtismtest/data/content/xhtml/html5/RtTest.php b/test/qtismtest/data/content/xhtml/html5/RtTest.php index 7fa9d7ca5..27f2eb5e9 100644 --- a/test/qtismtest/data/content/xhtml/html5/RtTest.php +++ b/test/qtismtest/data/content/xhtml/html5/RtTest.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtismtest\data\content\xhtml\html5; use qtism\data\content\xhtml\html5\Rt; @@ -27,7 +25,7 @@ class RtTest extends QtiSmTestCase { - const SUBJECT_QTI_CLASS_NAME = 'rt'; + public const SUBJECT_QTI_CLASS_NAME = 'rt'; public function testCreateWithValues(): void { diff --git a/test/qtismtest/data/content/xhtml/html5/RubyTest.php b/test/qtismtest/data/content/xhtml/html5/RubyTest.php index e911caf56..3ad09f10b 100644 --- a/test/qtismtest/data/content/xhtml/html5/RubyTest.php +++ b/test/qtismtest/data/content/xhtml/html5/RubyTest.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtismtest\data\content\xhtml\html5; use qtism\data\content\xhtml\html5\Ruby; @@ -27,7 +25,7 @@ class RubyTest extends QtiSmTestCase { - const SUBJECT_QTI_CLASS_NAME = 'ruby'; + public const SUBJECT_QTI_CLASS_NAME = 'ruby'; public function testCreateWithValues(): void { diff --git a/test/qtismtest/data/content/xhtml/tables/TableCellScopeTest.php b/test/qtismtest/data/content/xhtml/tables/TableCellScopeTest.php index e0021d4ce..a317f5407 100644 --- a/test/qtismtest/data/content/xhtml/tables/TableCellScopeTest.php +++ b/test/qtismtest/data/content/xhtml/tables/TableCellScopeTest.php @@ -13,7 +13,7 @@ class TableCellScopeTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return TableCellScope::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'row', @@ -34,7 +34,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'ROW', @@ -47,7 +47,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ TableCellScope::ROW, diff --git a/test/qtismtest/data/content/xhtml/tables/TdTest.php b/test/qtismtest/data/content/xhtml/tables/TdTest.php index fbca0b6ab..4ad6aaa60 100644 --- a/test/qtismtest/data/content/xhtml/tables/TdTest.php +++ b/test/qtismtest/data/content/xhtml/tables/TdTest.php @@ -11,7 +11,7 @@ */ class TdTest extends QtiSmTestCase { - public function testSetScopeWrongValue() + public function testSetScopeWrongValue(): void { $td = new Td(); @@ -21,7 +21,7 @@ public function testSetScopeWrongValue() $td->setScope(true); } - public function testSetAbbrWrongType() + public function testSetAbbrWrongType(): void { $td = new Td(); @@ -31,7 +31,7 @@ public function testSetAbbrWrongType() $td->setAbbr(true); } - public function testSetAxisWrongType() + public function testSetAxisWrongType(): void { $td = new Td(); @@ -41,7 +41,7 @@ public function testSetAxisWrongType() $td->setAxis(true); } - public function testSetRowspanWrongType() + public function testSetRowspanWrongType(): void { $td = new Td(); @@ -51,7 +51,7 @@ public function testSetRowspanWrongType() $td->setRowspan(true); } - public function testSetColspanWrongType() + public function testSetColspanWrongType(): void { $td = new Td(); diff --git a/test/qtismtest/data/expressions/ExpressionTest.php b/test/qtismtest/data/expressions/ExpressionTest.php index 5e566cf27..110ffec87 100644 --- a/test/qtismtest/data/expressions/ExpressionTest.php +++ b/test/qtismtest/data/expressions/ExpressionTest.php @@ -19,7 +19,7 @@ */ class ExpressionTest extends QtiSmTestCase { - public function testIsPure() + public function testIsPure(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/tests/branchingpath.xml'); @@ -43,7 +43,7 @@ public function testIsPure() } } - public function testQtiPL() + public function testQtiPL(): void { $renderer = new QtiPLRenderer(ConditionRenderingOptions::getDefault()); $doc = new XmlDocument(); @@ -82,7 +82,7 @@ public function testQtiPL() } } - public function testcoverageforQtiPL() + public function testcoverageforQtiPL(): void { $renderer = new QtiPLRenderer(ConditionRenderingOptions::getDefault()); $doc = new XmlDocument(); diff --git a/test/qtismtest/data/expressions/MathEnumerationTest.php b/test/qtismtest/data/expressions/MathEnumerationTest.php index 7fda4e39e..b95a67a8e 100644 --- a/test/qtismtest/data/expressions/MathEnumerationTest.php +++ b/test/qtismtest/data/expressions/MathEnumerationTest.php @@ -13,7 +13,7 @@ class MathEnumerationTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return MathEnumeration::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'pi', @@ -32,7 +32,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'PI', @@ -43,7 +43,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ MathEnumeration::PI, diff --git a/test/qtismtest/data/expressions/OutcomeMaximumTest.php b/test/qtismtest/data/expressions/OutcomeMaximumTest.php index ce70acad4..3efe6283a 100644 --- a/test/qtismtest/data/expressions/OutcomeMaximumTest.php +++ b/test/qtismtest/data/expressions/OutcomeMaximumTest.php @@ -10,7 +10,7 @@ */ class OutcomeMaximumTest extends QtiSmTestCase { - public function testOutcomeMaximum() + public function testOutcomeMaximum(): void { $outcomeMaximum = new OutcomeMaximum('SCORE', 'WEIGHT'); $this::assertInstanceOf(OutcomeMaximum::class, $outcomeMaximum); diff --git a/test/qtismtest/data/expressions/OutcomeMinimumTest.php b/test/qtismtest/data/expressions/OutcomeMinimumTest.php index e7bb25f9a..506a52ca6 100644 --- a/test/qtismtest/data/expressions/OutcomeMinimumTest.php +++ b/test/qtismtest/data/expressions/OutcomeMinimumTest.php @@ -10,7 +10,7 @@ */ class OutcomeMinimumTest extends QtiSmTestCase { - public function testOutcomeMaximum() + public function testOutcomeMaximum(): void { $outcomeMinimum = new OutcomeMinimum('SCORE', 'WEIGHT'); $this::assertInstanceOf(OutcomeMinimum::class, $outcomeMinimum); diff --git a/test/qtismtest/data/expressions/TestVariablesTest.php b/test/qtismtest/data/expressions/TestVariablesTest.php index cc4e625ac..3dd21b209 100644 --- a/test/qtismtest/data/expressions/TestVariablesTest.php +++ b/test/qtismtest/data/expressions/TestVariablesTest.php @@ -11,7 +11,7 @@ */ class TestVariablesTest extends QtiSmTestCase { - public function testTestVariables() + public function testTestVariables(): void { $testVariables = new TestVariables('SCORE', BaseType::FLOAT, 'WEIGHT'); $this::assertInstanceOf(TestVariables::class, $testVariables); diff --git a/test/qtismtest/data/expressions/operators/EqualTest.php b/test/qtismtest/data/expressions/operators/EqualTest.php index a2b4e59aa..0602684c8 100644 --- a/test/qtismtest/data/expressions/operators/EqualTest.php +++ b/test/qtismtest/data/expressions/operators/EqualTest.php @@ -16,7 +16,7 @@ */ class EqualTest extends QtiSmTestCase { - public function testInstantiationNoToleranceButRequired() + public function testInstantiationNoToleranceButRequired(): void { $this->expectException(UnexpectedValueException::class); $this->expectExceptionMessage('The tolerance argument must be specified when ToleranceMode = ABSOLUTE or EXACT.'); @@ -27,7 +27,7 @@ public function testInstantiationNoToleranceButRequired() ); } - public function testSetToleranceModeWrongValue() + public function testSetToleranceModeWrongValue(): void { $equal = new Equal( new ExpressionCollection([new BaseValue(BaseType::INTEGER, 10), new BaseValue(BaseType::INTEGER, 10)]) @@ -39,7 +39,7 @@ public function testSetToleranceModeWrongValue() $equal->setToleranceMode(true); } - public function testSetToleranceMissingT0() + public function testSetToleranceMissingT0(): void { $equal = new Equal( new ExpressionCollection([new BaseValue(BaseType::INTEGER, 10), new BaseValue(BaseType::INTEGER, 10)]) @@ -53,7 +53,7 @@ public function testSetToleranceMissingT0() $equal->setTolerance([]); } - public function testSetToleranceTooMuchTs() + public function testSetToleranceTooMuchTs(): void { $equal = new Equal( new ExpressionCollection([new BaseValue(BaseType::INTEGER, 10), new BaseValue(BaseType::INTEGER, 10)]) @@ -67,7 +67,7 @@ public function testSetToleranceTooMuchTs() $equal->setTolerance([1, 2, 3]); } - public function testSetIncludeLowerBoundWrongType() + public function testSetIncludeLowerBoundWrongType(): void { $equal = new Equal( new ExpressionCollection([new BaseValue(BaseType::INTEGER, 10), new BaseValue(BaseType::INTEGER, 10)]) @@ -79,7 +79,7 @@ public function testSetIncludeLowerBoundWrongType() $equal->setIncludeLowerBound('str'); } - public function testSetIncludeUpperBoundWrongType() + public function testSetIncludeUpperBoundWrongType(): void { $equal = new Equal( new ExpressionCollection([new BaseValue(BaseType::INTEGER, 10), new BaseValue(BaseType::INTEGER, 10)]) diff --git a/test/qtismtest/data/expressions/operators/MatchTest.php b/test/qtismtest/data/expressions/operators/MatchTest.php index f82da8a9f..bda1960f8 100644 --- a/test/qtismtest/data/expressions/operators/MatchTest.php +++ b/test/qtismtest/data/expressions/operators/MatchTest.php @@ -18,7 +18,7 @@ */ class MatchTest extends TestCase { - public function testClassCreation() + public function testClassCreation(): void { if (version_compare(PHP_VERSION, '8.0.0', '<')) { $expression = $this->createMock(ExpressionCollection::class); diff --git a/test/qtismtest/data/expressions/operators/MathFunctionsTest.php b/test/qtismtest/data/expressions/operators/MathFunctionsTest.php index c62d14b12..e2562b62b 100644 --- a/test/qtismtest/data/expressions/operators/MathFunctionsTest.php +++ b/test/qtismtest/data/expressions/operators/MathFunctionsTest.php @@ -13,7 +13,7 @@ class MathFunctionsTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return MathFunctions::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'sin', @@ -58,7 +58,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'SIN', @@ -95,7 +95,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ MathFunctions::SIN, diff --git a/test/qtismtest/data/expressions/operators/MaxTest.php b/test/qtismtest/data/expressions/operators/MaxTest.php index 8719d7145..d95974b94 100644 --- a/test/qtismtest/data/expressions/operators/MaxTest.php +++ b/test/qtismtest/data/expressions/operators/MaxTest.php @@ -15,7 +15,7 @@ */ class MaxTest extends QtiSmTestCase { - public function testInstantiation() + public function testInstantiation(): void { $expressions = new ExpressionCollection(); $expressions[] = new BaseValue(BaseType::INTEGER, 15); @@ -35,7 +35,7 @@ public function testInstantiation() /** * @depends testInstantiation */ - public function testSetMinOperandsWrongType() + public function testSetMinOperandsWrongType(): void { $expressions = new ExpressionCollection(); $expressions[] = new BaseValue(BaseType::INTEGER, 15); @@ -51,7 +51,7 @@ public function testSetMinOperandsWrongType() /** * @depends testInstantiation */ - public function testSetMaxOperandsWrongType() + public function testSetMaxOperandsWrongType(): void { $expressions = new ExpressionCollection(); $expressions[] = new BaseValue(BaseType::INTEGER, 15); @@ -67,7 +67,7 @@ public function testSetMaxOperandsWrongType() /** * @depends testInstantiation */ - public function testSetAcceptedCardinalitiesWrongValue() + public function testSetAcceptedCardinalitiesWrongValue(): void { $expressions = new ExpressionCollection(); $expressions[] = new BaseValue(BaseType::INTEGER, 15); @@ -83,7 +83,7 @@ public function testSetAcceptedCardinalitiesWrongValue() /** * @depends testInstantiation */ - public function testSetAcceptedBaseTypesWrongValue() + public function testSetAcceptedBaseTypesWrongValue(): void { $expressions = new ExpressionCollection(); $expressions[] = new BaseValue(BaseType::INTEGER, 15); diff --git a/test/qtismtest/data/expressions/operators/RoundingModeTest.php b/test/qtismtest/data/expressions/operators/RoundingModeTest.php index 7eeed9b88..c95affba1 100644 --- a/test/qtismtest/data/expressions/operators/RoundingModeTest.php +++ b/test/qtismtest/data/expressions/operators/RoundingModeTest.php @@ -13,7 +13,7 @@ class RoundingModeTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return RoundingMode::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'significantFigures', @@ -32,7 +32,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'SIGNIFICANT_FIGURES', @@ -43,7 +43,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ RoundingMode::SIGNIFICANT_FIGURES, diff --git a/test/qtismtest/data/expressions/operators/StatisticsTest.php b/test/qtismtest/data/expressions/operators/StatisticsTest.php index de041ff7b..4e201a114 100644 --- a/test/qtismtest/data/expressions/operators/StatisticsTest.php +++ b/test/qtismtest/data/expressions/operators/StatisticsTest.php @@ -13,7 +13,7 @@ class StatisticsTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return Statistics::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'mean', @@ -35,7 +35,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'MEAN', @@ -49,7 +49,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ Statistics::MEAN, diff --git a/test/qtismtest/data/expressions/operators/ToleranceModeTest.php b/test/qtismtest/data/expressions/operators/ToleranceModeTest.php index ea00d5a94..254c8a3c1 100644 --- a/test/qtismtest/data/expressions/operators/ToleranceModeTest.php +++ b/test/qtismtest/data/expressions/operators/ToleranceModeTest.php @@ -13,7 +13,7 @@ class ToleranceModeTest extends QtiSmEnumTestCase /** * @return string */ - protected function getEnumerationFqcn() + protected function getEnumerationFqcn(): string { return ToleranceMode::class; } @@ -21,7 +21,7 @@ protected function getEnumerationFqcn() /** * @return array */ - protected function getNames() + protected function getNames(): array { return [ 'exact', @@ -33,7 +33,7 @@ protected function getNames() /** * @return array */ - protected function getKeys() + protected function getKeys(): array { return [ 'EXACT', @@ -45,7 +45,7 @@ protected function getKeys() /** * @return array */ - protected function getConstants() + protected function getConstants(): array { return [ ToleranceMode::EXACT, diff --git a/test/qtismtest/data/results/ContextTest.php b/test/qtismtest/data/results/ContextTest.php index 8bee2fe71..aea0df26b 100644 --- a/test/qtismtest/data/results/ContextTest.php +++ b/test/qtismtest/data/results/ContextTest.php @@ -33,7 +33,7 @@ */ class ContextTest extends TestCase { - public function testAddSessionIdentifier() + public function testAddSessionIdentifier(): void { $sourceId = 'a source id'; $identifier = "string with\n\rtabulations\tand\r\nnew lines\nto be replaced\rby spaces"; @@ -56,7 +56,7 @@ public function testAddSessionIdentifier() $this::assertEquals($normalizedIdentifier, $sessionIdentifier->getIdentifier()->getValue()); } - public function testAddSessionIdentifierWithDuplicateSourceIdThrowsException() + public function testAddSessionIdentifierWithDuplicateSourceIdThrowsException(): void { $sourceId = 'a source id'; $identifier1 = 'id1'; @@ -73,7 +73,7 @@ public function testAddSessionIdentifierWithDuplicateSourceIdThrowsException() $subject->addSessionIdentifier($sourceId, $identifier2); } - public function testAddSessionIdentifierWithDuplicateIdentifierAdds() + public function testAddSessionIdentifierWithDuplicateIdentifierAdds(): void { $sourceId1 = 'sourceId1'; $sourceId2 = 'sourceId2'; diff --git a/test/qtismtest/data/rules/OutcomeConditionTest.php b/test/qtismtest/data/rules/OutcomeConditionTest.php index a92f64075..da3822453 100644 --- a/test/qtismtest/data/rules/OutcomeConditionTest.php +++ b/test/qtismtest/data/rules/OutcomeConditionTest.php @@ -18,7 +18,7 @@ */ class OutcomeConditionTest extends QtiSmTestCase { - public function testHasOutcomeElseGetComponents() + public function testHasOutcomeElseGetComponents(): void { $outcomeIf = new OutcomeIf( new MatchOperator( diff --git a/test/qtismtest/data/rules/OutcomeElseTest.php b/test/qtismtest/data/rules/OutcomeElseTest.php index 88a70b796..46d08631e 100644 --- a/test/qtismtest/data/rules/OutcomeElseTest.php +++ b/test/qtismtest/data/rules/OutcomeElseTest.php @@ -14,7 +14,7 @@ */ class OutcomeElseTest extends QtiSmTestCase { - public function testGetComponents() + public function testGetComponents(): void { $outcomeElse = new OutcomeElse( new OutcomeRuleCollection( diff --git a/test/qtismtest/data/state/AreaMappingTest.php b/test/qtismtest/data/state/AreaMappingTest.php index 9cf7112f6..d76e35a0a 100644 --- a/test/qtismtest/data/state/AreaMappingTest.php +++ b/test/qtismtest/data/state/AreaMappingTest.php @@ -15,7 +15,7 @@ */ class AreaMappingTest extends QtiSmTestCase { - public function testCreateNoAreaMapEntries() + public function testCreateNoAreaMapEntries(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('An AreaMapping object must contain at least one AreaMapEntry object. none given.'); @@ -27,7 +27,7 @@ public function testCreateNoAreaMapEntries() ); } - public function testSetLowerBoundWrongType() + public function testSetLowerBoundWrongType(): void { $mapping = new AreaMapping( new AreaMapEntryCollection( @@ -43,7 +43,7 @@ public function testSetLowerBoundWrongType() $mapping->setLowerBound(true); } - public function testSetUpperBoundWrongType() + public function testSetUpperBoundWrongType(): void { $mapping = new AreaMapping( new AreaMapEntryCollection( @@ -59,7 +59,7 @@ public function testSetUpperBoundWrongType() $mapping->setUpperBound(true); } - public function testSetDefaultValueWrongType() + public function testSetDefaultValueWrongType(): void { $mapping = new AreaMapping( new AreaMapEntryCollection( diff --git a/test/qtismtest/data/state/AssociationValidityConstraintTest.php b/test/qtismtest/data/state/AssociationValidityConstraintTest.php index f7bfeb587..00fe50653 100644 --- a/test/qtismtest/data/state/AssociationValidityConstraintTest.php +++ b/test/qtismtest/data/state/AssociationValidityConstraintTest.php @@ -16,7 +16,7 @@ class AssociationValidityConstraintTest extends QtiSmTestCase * @param int $minConstraint * @param int $maxConstraint */ - public function testSuccessfulInstantiation($minConstraint, $maxConstraint) + public function testSuccessfulInstantiation($minConstraint, $maxConstraint): void { $associationValidityConstraint = new AssociationValidityConstraint('IDENTIFIER', $minConstraint, $maxConstraint); $this::assertEquals('IDENTIFIER', $associationValidityConstraint->getIdentifier()); @@ -27,7 +27,7 @@ public function testSuccessfulInstantiation($minConstraint, $maxConstraint) /** * @return array */ - public function successfulInstantiationProvider() + public function successfulInstantiationProvider(): array { return [ [0, 1], @@ -46,7 +46,7 @@ public function successfulInstantiationProvider() * @param int $maxConstraint * @param string $msg */ - public function testUnsuccessfulInstantiation($identifier, $minConstraint, $maxConstraint, $msg) + public function testUnsuccessfulInstantiation($identifier, $minConstraint, $maxConstraint, $msg): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage($msg); @@ -56,7 +56,7 @@ public function testUnsuccessfulInstantiation($identifier, $minConstraint, $maxC /** * @return array */ - public function unsuccessfulInstantiationProvider() + public function unsuccessfulInstantiationProvider(): array { return [ ['', 0, 0, "The 'identifier' argument must be a non-empty string."], diff --git a/test/qtismtest/data/state/InterpolationTableTest.php b/test/qtismtest/data/state/InterpolationTableTest.php index c26eefe42..ce98b118f 100644 --- a/test/qtismtest/data/state/InterpolationTableTest.php +++ b/test/qtismtest/data/state/InterpolationTableTest.php @@ -13,7 +13,7 @@ */ class InterpolationTableTest extends QtiSmTestCase { - public function testCreateNotEnoughInterpolationEntries() + public function testCreateNotEnoughInterpolationEntries(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('An InterpolationTable object must contain at least one InterpolationTableEntry object.'); @@ -21,7 +21,7 @@ public function testCreateNotEnoughInterpolationEntries() new InterpolationTable(new InterpolationTableEntryCollection()); } - public function testGetComponents() + public function testGetComponents(): void { $interpolationTable = new InterpolationTable( new InterpolationTableEntryCollection( diff --git a/test/qtismtest/data/state/MappingTest.php b/test/qtismtest/data/state/MappingTest.php index 31b37e96c..37e0d8d0d 100644 --- a/test/qtismtest/data/state/MappingTest.php +++ b/test/qtismtest/data/state/MappingTest.php @@ -13,7 +13,7 @@ */ class MappingTest extends QtiSmTestCase { - public function testCreateNoMapEntries() + public function testCreateNoMapEntries(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A Mapping object must contain at least one MapEntry object, none given.'); @@ -25,7 +25,7 @@ public function testCreateNoMapEntries() ); } - public function testSetLowerBoundWrongType() + public function testSetLowerBoundWrongType(): void { $mapping = new Mapping( new MapEntryCollection( @@ -41,7 +41,7 @@ public function testSetLowerBoundWrongType() $mapping->setLowerBound(true); } - public function testSetUpperBoundWrongType() + public function testSetUpperBoundWrongType(): void { $mapping = new Mapping( new MapEntryCollection( @@ -57,7 +57,7 @@ public function testSetUpperBoundWrongType() $mapping->setUpperBound(true); } - public function testSetDefaultValueWrongType() + public function testSetDefaultValueWrongType(): void { $mapping = new Mapping( new MapEntryCollection( diff --git a/test/qtismtest/data/state/MatchTableTest.php b/test/qtismtest/data/state/MatchTableTest.php index e97cb9f2f..1c161b513 100644 --- a/test/qtismtest/data/state/MatchTableTest.php +++ b/test/qtismtest/data/state/MatchTableTest.php @@ -13,7 +13,7 @@ */ class MatchTableTest extends QtiSmTestCase { - public function testCreateNotEnoughMatchTableEntries() + public function testCreateNotEnoughMatchTableEntries(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A MatchTable object must contain at least one MatchTableEntry object.'); @@ -21,7 +21,7 @@ public function testCreateNotEnoughMatchTableEntries() new MatchTable(new MatchTableEntryCollection()); } - public function testGetComponents() + public function testGetComponents(): void { $matchTable = new MatchTable( new MatchTableEntryCollection( diff --git a/test/qtismtest/data/state/OutcomeDeclarationTest.php b/test/qtismtest/data/state/OutcomeDeclarationTest.php index fe6664883..ea6824290 100644 --- a/test/qtismtest/data/state/OutcomeDeclarationTest.php +++ b/test/qtismtest/data/state/OutcomeDeclarationTest.php @@ -1,4 +1,6 @@ subject = new OutcomeDeclaration('SCORE', BaseType::FLOAT, Cardinality::SINGLE); } - public function testSetInterpretationWrongType() + public function testSetInterpretationWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Interpretation must be a string, 'integer' given."); @@ -53,7 +55,7 @@ public function testSetInterpretationWrongType() $this->subject->setInterpretation(999); } - public function testSetLongInterpretationWrongType() + public function testSetLongInterpretationWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("LongInterpretation must be a string, 'integer' given."); @@ -61,7 +63,7 @@ public function testSetLongInterpretationWrongType() $this->subject->setLongInterpretation(999); } - public function testSetNormalMinimumWrongType() + public function testSetNormalMinimumWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("NormalMinimum must be a number or (boolean) false, 'string' given."); @@ -69,7 +71,7 @@ public function testSetNormalMinimumWrongType() $this->subject->setNormalMinimum('string'); } - public function testSetNormalMaximumWrongType() + public function testSetNormalMaximumWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("NormalMaximum must be a number or (boolean) false, 'string' given."); @@ -77,7 +79,7 @@ public function testSetNormalMaximumWrongType() $this->subject->setNormalMaximum('string'); } - public function testSetMasteryValueWrongType() + public function testSetMasteryValueWrongType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("MasteryValue must be a number or (boolean) false, 'string' given."); @@ -85,7 +87,7 @@ public function testSetMasteryValueWrongType() $this->subject->setMasteryValue('string'); } - public function getComponentsWithLookupTable() + public function getComponentsWithLookupTable(): void { $this->subject->setLookupTable( new MatchTable( @@ -100,7 +102,7 @@ public function getComponentsWithLookupTable() $this::assertInstanceOf(MatchTable::class, $last); } - public function testExternalScoredAccessors() + public function testExternalScoredAccessors(): void { $this::assertFalse($this->subject->isExternallyScored()); $this::assertFalse($this->subject->isScoredByHuman()); diff --git a/test/qtismtest/data/state/ResponseValidityConstraintTest.php b/test/qtismtest/data/state/ResponseValidityConstraintTest.php index cfa36c613..9a2904779 100644 --- a/test/qtismtest/data/state/ResponseValidityConstraintTest.php +++ b/test/qtismtest/data/state/ResponseValidityConstraintTest.php @@ -20,7 +20,7 @@ class ResponseValidityConstraintTest extends QtiSmTestCase * @param int $maxConstraint * @param string $patternMask */ - public function testSuccessfulInstantiationBasic($minConstraint, $maxConstraint, $patternMask = '') + public function testSuccessfulInstantiationBasic($minConstraint, $maxConstraint, $patternMask = ''): void { $responseValidityConstraint = new ResponseValidityConstraint('RESPONSE', $minConstraint, $maxConstraint, $patternMask); $this::assertEquals('RESPONSE', $responseValidityConstraint->getResponseIdentifier()); @@ -32,7 +32,7 @@ public function testSuccessfulInstantiationBasic($minConstraint, $maxConstraint, /** * @return array */ - public function successfulInstantiationBasicProvider() + public function successfulInstantiationBasicProvider(): array { return [ [0, 1], @@ -53,7 +53,7 @@ public function successfulInstantiationBasicProvider() * @param string $msg * @param string $patternMask */ - public function testUnsuccessfulInstantiation($responseIdentifier, $minConstraint, $maxConstraint, $msg, $patternMask = '') + public function testUnsuccessfulInstantiation($responseIdentifier, $minConstraint, $maxConstraint, $msg, $patternMask = ''): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage($msg); @@ -63,7 +63,7 @@ public function testUnsuccessfulInstantiation($responseIdentifier, $minConstrain /** * @return array */ - public function unsuccessfulInstantiationProvider() + public function unsuccessfulInstantiationProvider(): array { return [ ['', 0, 0, "The 'responseIdentifier' argument must be a non-empty string."], @@ -74,7 +74,7 @@ public function unsuccessfulInstantiationProvider() ]; } - public function testAssociations() + public function testAssociations(): void { $responseValidityConstraint = new ResponseValidityConstraint('RESPONSE', 0, 0); $responseValidityConstraint->addAssociationValidityConstraint( diff --git a/test/qtismtest/data/state/ShufflingTest.php b/test/qtismtest/data/state/ShufflingTest.php index ec3c21841..4611dc74a 100644 --- a/test/qtismtest/data/state/ShufflingTest.php +++ b/test/qtismtest/data/state/ShufflingTest.php @@ -14,7 +14,7 @@ */ class ShufflingTest extends QtiSmTestCase { - public function testShufflingShuffle() + public function testShufflingShuffle(): void { $identifiers1 = new IdentifierCollection(['id1', 'id2', 'id3', 'id4', 'id5']); $identifiers2 = new IdentifierCollection(['id6', 'id7', 'id8', 'id9', 'id10']); @@ -46,7 +46,7 @@ public function testShufflingShuffle() } } - public function testGetIdentifierAtWithValidIndexes() + public function testGetIdentifierAtWithValidIndexes(): void { $identifiers1 = new IdentifierCollection(['id1', 'id2', 'id3']); $identifiers2 = new IdentifierCollection(['id4', 'id5', 'id6']); @@ -67,7 +67,7 @@ public function testGetIdentifierAtWithValidIndexes() * @dataProvider getIdentifierAtWithInvalidIndexesProvider * @param mixed $index */ - public function testGetIdentifierAtWithInvalidIndexes($index) + public function testGetIdentifierAtWithInvalidIndexes($index): void { $identifiers1 = new IdentifierCollection(['id1', 'id2', 'id3']); $identifiers2 = new IdentifierCollection(['id4', 'id5', 'id6']); @@ -82,7 +82,7 @@ public function testGetIdentifierAtWithInvalidIndexes($index) /** * @return array */ - public function getIdentifierAtWithInvalidIndexesProvider() + public function getIdentifierAtWithInvalidIndexesProvider(): array { return [ [-1], diff --git a/test/qtismtest/data/state/StateUtilsTest.php b/test/qtismtest/data/state/StateUtilsTest.php index 1c0aea561..518a21e95 100644 --- a/test/qtismtest/data/state/StateUtilsTest.php +++ b/test/qtismtest/data/state/StateUtilsTest.php @@ -29,7 +29,7 @@ */ class StateUtilsTest extends QtiSmTestCase { - public function testCreateShufflingFromInteractionChoice() + public function testCreateShufflingFromInteractionChoice(): void { $choice1 = new SimpleChoice('id1'); $choice2 = new SimpleChoice('id2'); @@ -50,7 +50,7 @@ public function testCreateShufflingFromInteractionChoice() $this::assertEquals(['id1', 'id3'], $shufflingGroups[0]->getFixedIdentifiers()->getArrayCopy()); } - public function testCreateShufflingFromOrder() + public function testCreateShufflingFromOrder(): void { $choiceCollection = new SimpleChoiceCollection(); $choiceCollection[] = new SimpleChoice('id1'); @@ -67,7 +67,7 @@ public function testCreateShufflingFromOrder() $this::assertEquals(['id1', 'id2', 'id3'], $shufflingGroups[0]->getIdentifiers()->getArrayCopy()); } - public function testCreateShufflingFromAssociateInteraction() + public function testCreateShufflingFromAssociateInteraction(): void { $choiceCollection = new SimpleAssociableChoiceCollection(); $choice1 = new SimpleAssociableChoice('id1', 1); @@ -89,7 +89,7 @@ public function testCreateShufflingFromAssociateInteraction() $this::assertEquals(['id2'], $shufflingGroups[0]->getFixedIdentifiers()->getArrayCopy()); } - public function testCreateShufflingFromMatchInteraction() + public function testCreateShufflingFromMatchInteraction(): void { $choiceCollection1 = new SimpleAssociableChoiceCollection(); $choice11 = new SimpleAssociableChoice('id1', 1); @@ -120,7 +120,7 @@ public function testCreateShufflingFromMatchInteraction() $this::assertEquals(['id3', 'id4'], $shufflingGroups[1]->getIdentifiers()->getArrayCopy()); } - public function testCreateShufflingFromGapMatchInteraction() + public function testCreateShufflingFromGapMatchInteraction(): void { $choiceCollection = new GapChoiceCollection(); $gapText1 = new GapText('id1', 1); @@ -144,7 +144,7 @@ public function testCreateShufflingFromGapMatchInteraction() $this::assertEquals(['id3'], $shufflingGroups[0]->getFixedIdentifiers()->getArrayCopy()); } - public function testCreateShufflingFromInlineChoiceInteraction() + public function testCreateShufflingFromInlineChoiceInteraction(): void { $choiceCollection = new InlineChoiceCollection(); $choice1 = new InlineChoice('id1'); @@ -166,14 +166,14 @@ public function testCreateShufflingFromInlineChoiceInteraction() $this::assertEquals(['id3'], $shufflingGroups[0]->getFixedIdentifiers()->getArrayCopy()); } - public function testCreateShufflingFromNonShufflableInteraction() + public function testCreateShufflingFromNonShufflableInteraction(): void { $textEntryInteraction = new TextEntryInteraction('RESPONSE'); $shuffling = StateUtils::createShufflingFromInteraction($textEntryInteraction); $this::assertFalse($shuffling); } - public function testCreateShufflingWithShuffleFalse() + public function testCreateShufflingWithShuffleFalse(): void { $choiceCollection = new SimpleChoiceCollection(); $choiceCollection[] = new SimpleChoice('id1'); diff --git a/test/qtismtest/data/storage/php/PhpArgumentTest.php b/test/qtismtest/data/storage/php/PhpArgumentTest.php index 65424f9d0..541e4fc61 100644 --- a/test/qtismtest/data/storage/php/PhpArgumentTest.php +++ b/test/qtismtest/data/storage/php/PhpArgumentTest.php @@ -13,7 +13,7 @@ */ class PhpArgumentTest extends QtiSmTestCase { - public function testPhpArgument() + public function testPhpArgument(): void { // Test a variable reference. $arg = new PhpArgument(new PhpVariable('test')); @@ -59,7 +59,7 @@ public function testPhpArgument() $this::assertTrue($arg->isScalar()); } - public function testObject() + public function testObject(): void { $this->expectException(InvalidArgumentException::class); $arg = new PhpArgument(new stdClass()); diff --git a/test/qtismtest/data/storage/php/PhpDocumentTest.php b/test/qtismtest/data/storage/php/PhpDocumentTest.php index 18ac30f9b..eabb5d4d3 100644 --- a/test/qtismtest/data/storage/php/PhpDocumentTest.php +++ b/test/qtismtest/data/storage/php/PhpDocumentTest.php @@ -65,7 +65,7 @@ class PhpDocumentTest extends QtiSmTestCase * @param string $path * @throws PhpStorageException */ - public function testSimpleLoad($path = '') + public function testSimpleLoad($path = ''): void { $doc = new PhpDocument(); if (empty($path)) { @@ -141,7 +141,7 @@ public function testSimpleLoad($path = '') } } - public function testSimpleSave() + public function testSimpleSave(): void { $doc = new XmlCompactDocument(); $doc->load(self::samplesDir() . 'custom/php/php_storage_simple.xml'); @@ -154,7 +154,7 @@ public function testSimpleSave() unlink($file); } - public function testCustomOperatorOne() + public function testCustomOperatorOne(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/operators/custom_operator_1.xml'); @@ -180,7 +180,7 @@ public function testCustomOperatorOne() unlink($file); } - public function testCustomOperatorTwo() + public function testCustomOperatorTwo(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/operators/custom_operator_2.xml'); @@ -202,7 +202,7 @@ public function testCustomOperatorTwo() unlink($file); } - public function testCustomSelection() + public function testCustomSelection(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/tests/selection/custom_selection.xml'); @@ -251,7 +251,7 @@ public function testCustomSelection() * @throws StreamAccessException * @throws PhpMarshallingException */ - public function testLoadTestSamples($testUri, $rootType) + public function testLoadTestSamples($testUri, $rootType): void { // Basic XML -> PHP transormation + save + load $xmlDoc = new XmlDocument('2.1'); @@ -273,7 +273,7 @@ public function testLoadTestSamples($testUri, $rootType) $this::assertFileDoesNotExist($file); } - public function testLoadInteractionMixSaschsen() + public function testLoadInteractionMixSaschsen(): void { $xmlDoc = new XmlDocument('2.1'); $xmlDoc->load(self::samplesDir() . 'ims/tests/interaction_mix_sachsen/interaction_mix_sachsen.xml'); @@ -295,7 +295,7 @@ public function testLoadInteractionMixSaschsen() /** * @return array */ - public function loadTestSamplesDataProvider() + public function loadTestSamplesDataProvider(): array { return [ [self::samplesDir() . 'ims/tests/arbitrary_collections_of_item_outcomes/arbitrary_collections_of_item_outcomes.xml', AssessmentTest::class], @@ -357,7 +357,7 @@ public function loadTestSamplesDataProvider() ]; } - public function testSaveComponentWithArrayBeanProperty() + public function testSaveComponentWithArrayBeanProperty(): void { $equal = new Equal( new ExpressionCollection( @@ -384,7 +384,7 @@ public function testSaveComponentWithArrayBeanProperty() unlink($file); } - public function testSaveError() + public function testSaveError(): void { $phpDoc = new PhpDocument(); @@ -394,7 +394,7 @@ public function testSaveError() $phpDoc->save('/root/root.php'); } - public function testLoadError() + public function testLoadError(): void { $phpDoc = new PhpDocument(); @@ -412,7 +412,7 @@ public function testLoadError() * @throws ReflectionException * @throws StreamAccessException */ - public function testBodyElement() + public function testBodyElement(): void { $span = new Span('myid', 'myclass'); $span->setAriaControls('IDREF1 IDREF2'); diff --git a/test/qtismtest/data/storage/php/PhpStreamAccessTest.php b/test/qtismtest/data/storage/php/PhpStreamAccessTest.php index ad5851a06..ba6891b73 100644 --- a/test/qtismtest/data/storage/php/PhpStreamAccessTest.php +++ b/test/qtismtest/data/storage/php/PhpStreamAccessTest.php @@ -29,7 +29,7 @@ class PhpStreamAccessTest extends QtiSmTestCase * * @param MemoryStream $stream */ - protected function setStream(MemoryStream $stream) + protected function setStream(MemoryStream $stream): void { $this->stream = $stream; } @@ -39,7 +39,7 @@ protected function setStream(MemoryStream $stream) * * @return MemoryStream */ - protected function getStream() + protected function getStream(): MemoryStream { return $this->stream; } @@ -62,7 +62,7 @@ public function tearDown(): void } } - public function testInstantiation() + public function testInstantiation(): void { $access = new PhpStreamAccess($this->getStream()); $this::assertInstanceOf(PhpStreamAccess::class, $access); @@ -74,21 +74,21 @@ public function testInstantiation() * @param string $expected * @throws StreamAccessException */ - public function testWriteScalar($toWrite, $expected) + public function testWriteScalar($toWrite, $expected): void { $access = new PhpStreamAccess($this->getStream()); $access->writeScalar($toWrite); $this::assertEquals($expected, $this->getStream()->getBinary()); } - public function testWriteScalarInvalidData() + public function testWriteScalarInvalidData(): void { $this->expectException(InvalidArgumentException::class); $access = new PhpStreamAccess($this->getStream()); $access->writeScalar(new stdClass()); } - public function testWriteScalarCloseStream() + public function testWriteScalarCloseStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -100,7 +100,7 @@ public function testWriteScalarCloseStream() $access->writeScalar(10); } - public function testWriteEquals() + public function testWriteEquals(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeEquals(); @@ -111,7 +111,7 @@ public function testWriteEquals() $this::assertEquals('=', $this->getStream()->getBinary()); } - public function testWriteEqualsClosedStream() + public function testWriteEqualsClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -123,14 +123,14 @@ public function testWriteEqualsClosedStream() $access->writeEquals(); } - public function testWriteNewline() + public function testWriteNewline(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeNewline(); $this::assertEquals("\n", $this->getStream()->getBinary()); } - public function testWriteNewlineClosedStream() + public function testWriteNewlineClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -142,7 +142,7 @@ public function testWriteNewlineClosedStream() $access->writeNewline(); } - public function testWriteOpeningTag() + public function testWriteOpeningTag(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeOpeningTag(); @@ -153,7 +153,7 @@ public function testWriteOpeningTag() $this::assertEquals('getStream()->getBinary()); } - public function testWriteOpeningTagClosedStream() + public function testWriteOpeningTagClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -165,7 +165,7 @@ public function testWriteOpeningTagClosedStream() $access->writeOpeningTag(); } - public function testWriteClosingTag() + public function testWriteClosingTag(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeClosingTag(); @@ -177,7 +177,7 @@ public function testWriteClosingTag() $this::assertEquals('?>', $this->getStream()->getBinary()); } - public function testWriteClosingTagClosedStream() + public function testWriteClosingTagClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -189,7 +189,7 @@ public function testWriteClosingTagClosedStream() $access->writeClosingTag(); } - public function testWriteSemicolon() + public function testWriteSemicolon(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeSemicolon(); @@ -200,7 +200,7 @@ public function testWriteSemicolon() $this::assertEquals(';', $this->getStream()->getBinary()); } - public function testWriteSemicolonClosedStream() + public function testWriteSemicolonClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -212,14 +212,14 @@ public function testWriteSemicolonClosedStream() $access->writeSemicolon(); } - public function testWriteScopeResolution() + public function testWriteScopeResolution(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeScopeResolution(); $this::assertEquals('::', $this->getStream()->getBinary()); } - public function testWriteScopeResolutionClosedStream() + public function testWriteScopeResolutionClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -231,14 +231,14 @@ public function testWriteScopeResolutionClosedStream() $access->writeScopeResolution(); } - public function testWriteOpeningParenthesis() + public function testWriteOpeningParenthesis(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeOpeningParenthesis(); $this::assertEquals('(', $this->getStream()->getBinary()); } - public function testWriteOpeningParenthesisClosedStream() + public function testWriteOpeningParenthesisClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -250,14 +250,14 @@ public function testWriteOpeningParenthesisClosedStream() $access->writeOpeningParenthesis(); } - public function testWriteClosingParenthesis() + public function testWriteClosingParenthesis(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeClosingParenthesis(); $this::assertEquals(')', $this->getStream()->getBinary()); } - public function testWriteClosingParenthesisClosedStream() + public function testWriteClosingParenthesisClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -269,7 +269,7 @@ public function testWriteClosingParenthesisClosedStream() $access->writeClosingParenthesis(); } - public function testWriteComma() + public function testWriteComma(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeComma(); @@ -280,7 +280,7 @@ public function testWriteComma() $this::assertEquals(',', $this->getStream()->getBinary()); } - public function testWriteCommaClosedStream() + public function testWriteCommaClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -292,14 +292,14 @@ public function testWriteCommaClosedStream() $access->writeComma(); } - public function testWriteSpace() + public function testWriteSpace(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeSpace(); $this::assertEquals(' ', $this->getStream()->getBinary()); } - public function testWriteSpaceClosedStream() + public function testWriteSpaceClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -311,14 +311,14 @@ public function testWriteSpaceClosedStream() $access->writeSpace(); } - public function testWriteVariable() + public function testWriteVariable(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeVariable('foobar'); $this::assertEquals('$foobar', $this->getStream()->getBinary()); } - public function testWriteVariableClosedStream() + public function testWriteVariableClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -330,14 +330,14 @@ public function testWriteVariableClosedStream() $access->writeVariable('foobar'); } - public function testWriteObjectOperator() + public function testWriteObjectOperator(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeObjectOperator(); $this::assertEquals('->', $this->getStream()->getBinary()); } - public function testWriteObjectOperatorClosedStream() + public function testWriteObjectOperatorClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -356,14 +356,14 @@ public function testWriteObjectOperatorClosedStream() * @param PhpArgumentCollection $arguments * @throws StreamAccessException */ - public function testWriteFunctionCall($expected, $funcname, PhpArgumentCollection $arguments = null) + public function testWriteFunctionCall($expected, $funcname, PhpArgumentCollection $arguments = null): void { $access = new PhpStreamAccess($this->getStream()); $access->writeFunctionCall($funcname, $arguments); $this::assertEquals($expected, $this->getStream()->getBinary()); } - public function testWriteFunctionCallClosedStream() + public function testWriteFunctionCallClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -375,7 +375,7 @@ public function testWriteFunctionCallClosedStream() $access->writeFunctionCall('callMe'); } - public function testWriteNew() + public function testWriteNew(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeNew(); @@ -386,7 +386,7 @@ public function testWriteNew() $this::assertEquals('new', $this->getStream()->getBinary()); } - public function testWriteNewClosedStream() + public function testWriteNewClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -398,14 +398,14 @@ public function testWriteNewClosedStream() $access->writeNew(); } - public function testWriteColon() + public function testWriteColon(): void { $access = new PhpStreamAccess($this->getStream()); $access->writeColon(); $this::assertEquals(':', $this->getStream()->getBinary()); } - public function testWriteColonClosedStream() + public function testWriteColonClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -424,14 +424,14 @@ public function testWriteColonClosedStream() * @param PhpArgumentCollection $arguments * @throws StreamAccessException */ - public function testWriteInstantiation($expected, $classname, PhpArgumentCollection $arguments = null) + public function testWriteInstantiation($expected, $classname, PhpArgumentCollection $arguments = null): void { $access = new PhpStreamAccess($this->getStream()); $access->writeInstantiation($classname, $arguments); $this::assertEquals($expected, $this->getStream()->getBinary()); } - public function testWriteInstantiationClosedStream() + public function testWriteInstantiationClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -443,14 +443,14 @@ public function testWriteInstantiationClosedStream() $access->writeInstantiation('stdClass'); } - public function testWritePaamayimNekudotayim() + public function testWritePaamayimNekudotayim(): void { $access = new PhpStreamAccess($this->getStream()); $access->writePaamayimNekudotayim(); $this::assertEquals('::', $this->getStream()->getBinary()); } - public function testWritePaamayimNekudotayimClosedStream() + public function testWritePaamayimNekudotayimClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -462,7 +462,7 @@ public function testWritePaamayimNekudotayimClosedStream() $access->writePaamayimNekudotayim(); } - public function testWriteStaticMethodCall() + public function testWriteStaticMethodCall(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -471,7 +471,7 @@ public function testWriteStaticMethodCall() $this::assertEquals('$foo::bar()', $stream->getBinary()); } - public function testWriteStaticMethodCallClosedStream() + public function testWriteStaticMethodCallClosedStream(): void { $stream = $this->getStream(); $access = new PhpStreamAccess($stream); @@ -483,7 +483,7 @@ public function testWriteStaticMethodCallClosedStream() $access->writeMethodCall('foo', 'bar', null, true); } - public function testWriteArgumentsCloseStream() + public function testWriteArgumentsCloseStream(): void { $arguments = new PhpArgumentCollection([new PhpArgument(10)]); $stream = $this->getStream(); @@ -499,7 +499,7 @@ public function testWriteArgumentsCloseStream() /** * @return array */ - public function writeScalarDataProvider() + public function writeScalarDataProvider(): array { return [ ['', '""'], @@ -525,7 +525,7 @@ public function writeScalarDataProvider() /** * @return array */ - public function writeFunctionCallDataProvider() + public function writeFunctionCallDataProvider(): array { return [ ['call_user_func()', 'call_user_func', null], @@ -537,7 +537,7 @@ public function writeFunctionCallDataProvider() /** * @return array */ - public function writeInstantiationDataProvider() + public function writeInstantiationDataProvider(): array { return [ ['new stdClass()', 'stdClass', null], diff --git a/test/qtismtest/data/storage/php/PhpUtilsTest.php b/test/qtismtest/data/storage/php/PhpUtilsTest.php index c5ea50810..062d8eede 100644 --- a/test/qtismtest/data/storage/php/PhpUtilsTest.php +++ b/test/qtismtest/data/storage/php/PhpUtilsTest.php @@ -15,7 +15,7 @@ class PhpUtilsTest extends QtiSmTestCase * @param string $input * @param string $expected */ - public function testDoubleQuotedPhpString($input, $expected) + public function testDoubleQuotedPhpString($input, $expected): void { $this::assertEquals($expected, PhpUtils::doubleQuotedPhpString($input)); } @@ -23,7 +23,7 @@ public function testDoubleQuotedPhpString($input, $expected) /** * @return array */ - public function doubleQuotedPhpStringDataProvider() + public function doubleQuotedPhpStringDataProvider(): array { return [ ['', '""'], diff --git a/test/qtismtest/data/storage/php/marshalling/PhpArrayMarshallerTest.php b/test/qtismtest/data/storage/php/marshalling/PhpArrayMarshallerTest.php index 34fa15a4a..f5f19c3e4 100644 --- a/test/qtismtest/data/storage/php/marshalling/PhpArrayMarshallerTest.php +++ b/test/qtismtest/data/storage/php/marshalling/PhpArrayMarshallerTest.php @@ -10,7 +10,7 @@ */ class PhpArrayMarshallerTest extends QtiSmPhpMarshallerTestCase { - public function testEmptyArray() + public function testEmptyArray(): void { $ctx = $this->createMarshallingContext(); $marshaller = new PhpArrayMarshaller($ctx, []); @@ -19,7 +19,7 @@ public function testEmptyArray() $this::assertEquals("\$array_0 = array();\n", $this->getStream()->getBinary()); } - public function testIntegerArray() + public function testIntegerArray(): void { $ctx = $this->createMarshallingContext(); $arrayMarshaller = new PhpArrayMarshaller($ctx, [0, 1, 2]); diff --git a/test/qtismtest/data/storage/php/marshalling/PhpCollectionMarshallerTest.php b/test/qtismtest/data/storage/php/marshalling/PhpCollectionMarshallerTest.php index 3ac9e24dc..64880b965 100644 --- a/test/qtismtest/data/storage/php/marshalling/PhpCollectionMarshallerTest.php +++ b/test/qtismtest/data/storage/php/marshalling/PhpCollectionMarshallerTest.php @@ -12,7 +12,7 @@ */ class PhpCollectionMarshallerTest extends QtiSmPhpMarshallerTestCase { - public function testEmptyCollection() + public function testEmptyCollection(): void { $collection = new IntegerCollection(); $marshaller = new PhpCollectionMarshaller($this->createMarshallingContext(), $collection); @@ -24,7 +24,7 @@ public function testEmptyCollection() $this::assertEquals($expected, $this->getStream()->getBinary()); } - public function testIntegerCollection() + public function testIntegerCollection(): void { $collection = new IntegerCollection([10, 11, 12]); $ctx = $this->createMarshallingContext(); diff --git a/test/qtismtest/data/storage/php/marshalling/PhpMarshallingContextTest.php b/test/qtismtest/data/storage/php/marshalling/PhpMarshallingContextTest.php index 538309d26..9fcf73a8d 100644 --- a/test/qtismtest/data/storage/php/marshalling/PhpMarshallingContextTest.php +++ b/test/qtismtest/data/storage/php/marshalling/PhpMarshallingContextTest.php @@ -27,15 +27,15 @@ class PhpMarshallingContextTest extends QtiSmTestCase /** * @param PhpStreamAccess $streamAccess */ - protected function setStreamAccess(PhpStreamAccess $streamAccess) + protected function setStreamAccess(PhpStreamAccess $streamAccess): void { $this->streamAccess = $streamAccess; } /** - * @return mixed + * @return PhpStreamAccess */ - protected function getStreamAccess() + protected function getStreamAccess(): ?PhpStreamAccess { return $this->streamAccess; } @@ -57,7 +57,7 @@ public function tearDown(): void unset($streamAccess); } - public function testPhpMarshallingContext() + public function testPhpMarshallingContext(): void { $ctx = new PhpMarshallingContext($this->getStreamAccess()); $this::assertFalse($ctx->mustFormatOutput()); @@ -74,7 +74,7 @@ public function testPhpMarshallingContext() $this::assertInstanceOf(PhpStreamAccess::class, $ctx->getStreamAccess()); } - public function testPhpMarshallingTooLargeQuantity() + public function testPhpMarshallingTooLargeQuantity(): void { $ctx = new PhpMarshallingContext($this->getStreamAccess()); $ctx->pushOnVariableStack(['foo', 'bar', '2000']); @@ -87,7 +87,7 @@ public function testPhpMarshallingTooLargeQuantity() } } - public function testPhpMarshallingEmptyStack() + public function testPhpMarshallingEmptyStack(): void { $ctx = new PhpMarshallingContext($this->getStreamAccess()); @@ -99,7 +99,7 @@ public function testPhpMarshallingEmptyStack() } } - public function testWrongQuantity() + public function testWrongQuantity(): void { $ctx = new PhpMarshallingContext($this->getStreamAccess()); $ctx->pushOnVariableStack('foo'); @@ -112,7 +112,7 @@ public function testWrongQuantity() } } - public function testGenerateVariableName() + public function testGenerateVariableName(): void { $ctx = new PhpMarshallingContext($this->getStreamAccess()); diff --git a/test/qtismtest/data/storage/php/marshalling/PhpMarshallingUtilsTest.php b/test/qtismtest/data/storage/php/marshalling/PhpMarshallingUtilsTest.php index b424f2f33..263d0e5cd 100644 --- a/test/qtismtest/data/storage/php/marshalling/PhpMarshallingUtilsTest.php +++ b/test/qtismtest/data/storage/php/marshalling/PhpMarshallingUtilsTest.php @@ -18,7 +18,7 @@ class PhpMarshallingUtilsTest extends QtiSmTestCase * @param int $occurence * @param string $expected */ - public function testVariableName($value, $occurence, $expected) + public function testVariableName($value, $occurence, $expected): void { $this::assertEquals($expected, PhpMarshallingUtils::variableName($value, $occurence)); } @@ -26,7 +26,7 @@ public function testVariableName($value, $occurence, $expected) /** * @return array */ - public function variableNameDataProvider() + public function variableNameDataProvider(): array { return [ [null, 0, 'scalarnullvalue_0'], diff --git a/test/qtismtest/data/storage/php/marshalling/PhpQtiComponentMarshallerTest.php b/test/qtismtest/data/storage/php/marshalling/PhpQtiComponentMarshallerTest.php index 836cf5e24..568e30bf0 100644 --- a/test/qtismtest/data/storage/php/marshalling/PhpQtiComponentMarshallerTest.php +++ b/test/qtismtest/data/storage/php/marshalling/PhpQtiComponentMarshallerTest.php @@ -14,7 +14,7 @@ */ class PhpQtiComponentMarshallerTest extends QtiSmPhpMarshallerTestCase { - public function testEmptyComponent() + public function testEmptyComponent(): void { $component = new ExitTest(); $ctx = $this->createMarshallingContext(); @@ -24,7 +24,7 @@ public function testEmptyComponent() $this::assertEquals('$exittest_0 = new ' . ExitTest::class . '();' . "\n", $this->getStream()->getBinary()); } - public function testOnlyScalarPropertiesComponentAllInConstructor() + public function testOnlyScalarPropertiesComponentAllInConstructor(): void { $component = new Weight('weight1', 1.1); $ctx = $this->createMarshallingContext(); @@ -44,7 +44,7 @@ public function testOnlyScalarPropertiesComponentAllInConstructor() $this::assertEquals($expected, $this->getStream()->getBinary()); } - public function testOnlyScalarPropertiesConstructorAndProperties() + public function testOnlyScalarPropertiesConstructorAndProperties(): void { $component = new ItemSessionControl(); $ctx = $this->createMarshallingContext(); diff --git a/test/qtismtest/data/storage/php/marshalling/PhpQtiDatatypeMarshallerTest.php b/test/qtismtest/data/storage/php/marshalling/PhpQtiDatatypeMarshallerTest.php index a60ad7d07..52aec71f0 100644 --- a/test/qtismtest/data/storage/php/marshalling/PhpQtiDatatypeMarshallerTest.php +++ b/test/qtismtest/data/storage/php/marshalling/PhpQtiDatatypeMarshallerTest.php @@ -28,7 +28,7 @@ class PhpQtiDatatypeMarshallerTest extends QtiSmPhpMarshallerTestCase * @param QtiDatatype $qtiDatatype * @throws PhpMarshallingException */ - public function testMarshall($expectedInStream, QtiDatatype $qtiDatatype) + public function testMarshall($expectedInStream, QtiDatatype $qtiDatatype): void { $ctx = $this->createMarshallingContext(); $marshaller = new PhpQtiDatatypeMarshaller($ctx, $qtiDatatype); @@ -37,7 +37,7 @@ public function testMarshall($expectedInStream, QtiDatatype $qtiDatatype) $this::assertEquals($expectedInStream, $this->getStream()->getBinary()); } - public function testMarshallWrongDataType() + public function testMarshallWrongDataType(): void { $this->expectException(InvalidArgumentException::class); $ctx = $this->createMarshallingContext(); @@ -47,7 +47,7 @@ public function testMarshallWrongDataType() /** * @return array */ - public function marshallDataProvider() + public function marshallDataProvider(): array { return [ ['$array_0 = array(10, 10, 5);' . "\n" . '$qticoords_0 = new ' . QtiCoords::class . '(2, $array_0);' . "\n", new QtiCoords(QtiShape::CIRCLE, [10, 10, 5])], @@ -59,7 +59,7 @@ public function marshallDataProvider() ]; } - public function testMarshallUnsupported() + public function testMarshallUnsupported(): void { $ctx = $this->createMarshallingContext(); $marshaller = new PhpQtiDatatypeMarshaller($ctx, new QtiInteger(1337)); @@ -70,7 +70,7 @@ public function testMarshallUnsupported() $marshaller->marshall(); } - public function testMarshallCoordsClosedStream() + public function testMarshallCoordsClosedStream(): void { $ctx = $this->createMarshallingContext(); $marshaller = new PhpQtiDatatypeMarshaller($ctx, new QtiCoords(QtiShape::CIRCLE, [10, 10, 5])); @@ -82,7 +82,7 @@ public function testMarshallCoordsClosedStream() $marshaller->marshall(); } - public function testMarshallPairClosedStream() + public function testMarshallPairClosedStream(): void { $ctx = $this->createMarshallingContext(); $marshaller = new PhpQtiDatatypeMarshaller($ctx, new QtiPair('A', 'B')); @@ -94,7 +94,7 @@ public function testMarshallPairClosedStream() $marshaller->marshall(); } - public function testMarshallDurationClosedStream() + public function testMarshallDurationClosedStream(): void { $ctx = $this->createMarshallingContext(); $marshaller = new PhpQtiDatatypeMarshaller($ctx, new QtiDuration('PT30S')); @@ -106,7 +106,7 @@ public function testMarshallDurationClosedStream() $marshaller->marshall(); } - public function testMarshallIdentifierClosedStream() + public function testMarshallIdentifierClosedStream(): void { $ctx = $this->createMarshallingContext(); $marshaller = new PhpQtiDatatypeMarshaller($ctx, new QtiIdentifier('MYID')); @@ -118,7 +118,7 @@ public function testMarshallIdentifierClosedStream() $marshaller->marshall(); } - public function testMarshallPointClosedStream() + public function testMarshallPointClosedStream(): void { $ctx = $this->createMarshallingContext(); $marshaller = new PhpQtiDatatypeMarshaller($ctx, new QtiPoint(9, 9)); diff --git a/test/qtismtest/data/storage/php/marshalling/PhpScalarMarshallerTest.php b/test/qtismtest/data/storage/php/marshalling/PhpScalarMarshallerTest.php index 18ec7c393..c5d7f8bf6 100644 --- a/test/qtismtest/data/storage/php/marshalling/PhpScalarMarshallerTest.php +++ b/test/qtismtest/data/storage/php/marshalling/PhpScalarMarshallerTest.php @@ -19,7 +19,7 @@ class PhpScalarMarshallerTest extends QtiSmPhpMarshallerTestCase * @param mixed $scalar * @throws PhpMarshallingException */ - public function testMarshall($expectedInStream, $scalar) + public function testMarshall($expectedInStream, $scalar): void { $ctx = $this->createMarshallingContext(); $marshaller = new PhpScalarMarshaller($ctx, $scalar); @@ -28,7 +28,7 @@ public function testMarshall($expectedInStream, $scalar) $this::assertEquals($expectedInStream, $this->getStream()->getBinary()); } - public function testMarshallWrongDataType() + public function testMarshallWrongDataType(): void { $this->expectException(InvalidArgumentException::class); $ctx = $this->createMarshallingContext(); @@ -38,7 +38,7 @@ public function testMarshallWrongDataType() /** * @return array */ - public function marshallDataProvider() + public function marshallDataProvider(): array { return [ ["\$scalarnullvalue_0 = null;\n", null], diff --git a/test/qtismtest/data/storage/xml/XmlAssessmentContentDocumentTest.php b/test/qtismtest/data/storage/xml/XmlAssessmentContentDocumentTest.php index b273f880c..5d79efa36 100644 --- a/test/qtismtest/data/storage/xml/XmlAssessmentContentDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlAssessmentContentDocumentTest.php @@ -11,7 +11,7 @@ */ class XmlAssessmentContentDocumentTest extends QtiSmTestCase { - public function testSimpleXmlBase() + public function testSimpleXmlBase(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'rendering/xmlbase_1.xml'); @@ -29,7 +29,7 @@ public function testSimpleXmlBase() $this::assertFalse($imgs[2]->hasXmlBase()); } - public function testModerateXmlBase() + public function testModerateXmlBase(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'rendering/xmlbase_2.xml'); diff --git a/test/qtismtest/data/storage/xml/XmlAssessmentDocumentQTIGuideTest.php b/test/qtismtest/data/storage/xml/XmlAssessmentDocumentQTIGuideTest.php index 3da049d5c..324e01f79 100644 --- a/test/qtismtest/data/storage/xml/XmlAssessmentDocumentQTIGuideTest.php +++ b/test/qtismtest/data/storage/xml/XmlAssessmentDocumentQTIGuideTest.php @@ -34,7 +34,7 @@ class XmlAssessmentDocumentQTIGuideTest extends QtiSmTestCase * @param string $uri The URI describing the file to load. * @throws XmlStorageException */ - public function testLoadNoSchemaValidate($uri) + public function testLoadNoSchemaValidate($uri): void { $doc = new XmlDocument('2.1'); $doc->load($uri); @@ -48,7 +48,7 @@ public function testLoadNoSchemaValidate($uri) * @param string $uri The URI describing the file to load. * @throws XmlStorageException */ - public function testLoadFromStringNoSchemaValidate($uri) + public function testLoadFromStringNoSchemaValidate($uri): void { $doc = new XmlDocument('2.1'); $doc->loadFromString(file_get_contents($uri)); @@ -63,7 +63,7 @@ public function testLoadFromStringNoSchemaValidate($uri) * @throws XmlStorageException * @throws MarshallingException */ - public function testLoadSaveSchemaValidate($uri) + public function testLoadSaveSchemaValidate($uri): void { $doc = new XmlDocument('2.1'); $doc->load($uri); @@ -89,7 +89,7 @@ public function testLoadSaveSchemaValidate($uri) * @throws XmlStorageException * @throws MarshallingException */ - public function testLoadSaveToStringSchemaValidate($uri) + public function testLoadSaveToStringSchemaValidate($uri): void { $doc = new XmlDocument('2.1'); $doc->load($uri); @@ -112,7 +112,7 @@ public function testLoadSaveToStringSchemaValidate($uri) /** * @return array */ - public function qtiImplementationGuideAssessmentTestFiles() + public function qtiImplementationGuideAssessmentTestFiles(): array { return [ [self::decorateUri('interaction_mix_sachsen/interaction_mix_sachsen.xml')], @@ -139,7 +139,7 @@ public function qtiImplementationGuideAssessmentTestFiles() * @param null $assessmentTest * @throws XmlStorageException */ - public function testLoadInteractionMixSachsen($assessmentTest = null) + public function testLoadInteractionMixSachsen($assessmentTest = null): void { if (empty($assessmentTest)) { $doc = new XmlDocument('2.1'); @@ -252,7 +252,7 @@ public function testLoadInteractionMixSachsen($assessmentTest = null) $this::assertEquals('SCORE', $testVariables->getVariableIdentifier()); } - public function testWriteInteractionMixSachsen() + public function testWriteInteractionMixSachsen(): void { $doc = new XmlDocument('2.1'); $doc->load(self::decorateUri('interaction_mix_sachsen/interaction_mix_sachsen.xml'), true); @@ -285,7 +285,7 @@ public function testWriteInteractionMixSachsen() * @param $uri * @return string */ - private static function decorateUri($uri) + private static function decorateUri($uri): string { return self::samplesDir() . 'ims/tests/' . $uri; } diff --git a/test/qtismtest/data/storage/xml/XmlAssessmentItemDocumentTest.php b/test/qtismtest/data/storage/xml/XmlAssessmentItemDocumentTest.php index 0bedba7be..a671c538f 100644 --- a/test/qtismtest/data/storage/xml/XmlAssessmentItemDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlAssessmentItemDocumentTest.php @@ -37,7 +37,7 @@ public function testLoad(string $uri, string $expectedVersion, bool $validate = * @param string $expectedVersion * @throws XmlStorageException */ - public function testLoadFromString($uri, $expectedVersion) + public function testLoadFromString($uri, $expectedVersion): void { $doc = new XmlDocument($expectedVersion); $doc->loadFromString(file_get_contents($uri)); @@ -77,7 +77,7 @@ public function testWrite(string $uri, string $expectedVersion): void * @throws XmlStorageException * @throws MarshallingException */ - public function testSaveToString($uri, $expectedVersion) + public function testSaveToString($uri, $expectedVersion): void { $doc = new XmlDocument(); $doc->load($uri); @@ -97,7 +97,7 @@ public function testSaveToString($uri, $expectedVersion) $this::assertFileDoesNotExist($file); } - public function testLoad224() + public function testLoad224(): void { $file = self::samplesDir() . 'ims/items/2_2_4/choice.xml'; $doc = new XmlDocument(); @@ -108,7 +108,7 @@ public function testLoad224() $this::assertEquals($doc->saveToString(), file_get_contents(self::samplesDir() . 'ims/items/2_2_4/choice.xml')); } - public function testLoad223() + public function testLoad223(): void { $file = self::samplesDir() . 'ims/items/2_2_3/choice.xml'; $doc = new XmlDocument(); @@ -119,7 +119,7 @@ public function testLoad223() $this::assertEquals($doc->saveToString(), file_get_contents(self::samplesDir() . 'ims/items/2_2_3/choice.xml')); } - public function testLoad222() + public function testLoad222(): void { $file = self::samplesDir() . 'ims/items/2_2_2/choice.xml'; $doc = new XmlDocument(); @@ -130,7 +130,7 @@ public function testLoad222() $this::assertEquals($doc->saveToString(), file_get_contents(self::samplesDir() . 'ims/items/2_2_2/choice.xml')); } - public function testLoad221() + public function testLoad221(): void { $file = self::samplesDir() . 'ims/items/2_2_1/choice_aria.xml'; $doc = new XmlDocument(); @@ -140,7 +140,7 @@ public function testLoad221() $this::assertEquals($doc->saveToString(), file_get_contents(self::samplesDir() . 'ims/items/2_2_1/choice_aria.xml')); } - public function testLoad22() + public function testLoad22(): void { $file = self::samplesDir() . 'ims/items/2_2/associate.xml'; $doc = new XmlDocument(); @@ -149,7 +149,7 @@ public function testLoad22() $this::assertEquals('2.2.0', $doc->getVersion()); } - public function testLoad22NoSchemaLocation() + public function testLoad22NoSchemaLocation(): void { $file = self::samplesDir() . 'custom/items/2_2/no_schema_location.xml'; $doc = new XmlDocument(); @@ -158,7 +158,7 @@ public function testLoad22NoSchemaLocation() $this::assertEquals('2.2.0', $doc->getVersion()); } - public function testLoad211() + public function testLoad211(): void { $file = self::samplesDir() . 'ims/items/2_1_1/associate.xml'; $doc = new XmlDocument(); @@ -167,7 +167,7 @@ public function testLoad211() $this::assertEquals('2.1.1', $doc->getVersion()); } - public function testLoad21() + public function testLoad21(): void { $file = self::samplesDir() . 'ims/items/2_1/associate.xml'; $doc = new XmlDocument(); @@ -176,7 +176,7 @@ public function testLoad21() $this::assertEquals('2.1.0', $doc->getVersion()); } - public function testLoad21NoSchemaLocation() + public function testLoad21NoSchemaLocation(): void { $file = self::samplesDir() . 'custom/items/2_1/no_schema_location.xml'; $doc = new XmlDocument(); @@ -185,7 +185,7 @@ public function testLoad21NoSchemaLocation() $this::assertEquals('2.1.0', $doc->getVersion()); } - public function testLoad20() + public function testLoad20(): void { $file = self::samplesDir() . 'ims/items/2_0/associate.xml'; $doc = new XmlDocument(); @@ -198,7 +198,7 @@ public function testLoad20() * @param string $uri * @throws XmlStorageException */ - public function testLoadTemplate($uri = '') + public function testLoadTemplate($uri = ''): void { $file = (empty($uri)) ? self::samplesDir() . 'ims/items/2_1/template.xml' : $uri; @@ -236,7 +236,7 @@ public function testLoadTemplate($uri = '') $this::assertFalse($templateDeclarations['MIN']->isParamVariable()); } - public function testWriteTemplate() + public function testWriteTemplate(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'ims/items/2_1/template.xml'); @@ -255,7 +255,7 @@ public function testWriteTemplate() * @param string $url * @throws XmlStorageException */ - public function testLoadPCIItem($url = '') + public function testLoadPCIItem($url = ''): void { $doc = new XmlDocument(); $doc->load((empty($url)) ? self::samplesDir() . 'custom/interactions/custom_interaction_pci.xml' : $url, true); @@ -332,7 +332,7 @@ public function testLoadPCIItem($url = '') $this::assertEquals('width:500px; height:500px;', $divElts->item(0)->getAttribute('style')); } - public function testWritePCIItem() + public function testWritePCIItem(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/interactions/custom_interaction_pci.xml'); @@ -347,7 +347,7 @@ public function testWritePCIItem() /** * @return array */ - public function validFileProvider() + public function validFileProvider(): array { return [ // -- 2.2.4 @@ -528,7 +528,7 @@ public function validFileProvider() ]; } - public function testRetrievePromptFromGraphicGapMatch() + public function testRetrievePromptFromGraphicGapMatch(): void { $doc = new XmlDocument(); $doc->load(self::decorateUri('graphic_gap_match.xml', '2.2')); @@ -585,7 +585,7 @@ public function invalidVersionForMultipleMimeTypesInUploadInteraction() * @param string $version * @return string */ - private static function decorateUri($uri, $version = '2.1') + private static function decorateUri($uri, $version = '2.1'): string { if ($version === '2.1' || $version === '2.1.0') { return self::samplesDir() . 'ims/items/2_1/' . $uri; diff --git a/test/qtismtest/data/storage/xml/XmlAssessmentSectionDocumentTest.php b/test/qtismtest/data/storage/xml/XmlAssessmentSectionDocumentTest.php index a9caf9c0e..a4594759f 100644 --- a/test/qtismtest/data/storage/xml/XmlAssessmentSectionDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlAssessmentSectionDocumentTest.php @@ -20,7 +20,7 @@ class XmlAssessmentSectionDocumentTest extends QtiSmTestCase * @param AssessmentSection|null $assessmentSection * @throws XmlStorageException */ - public function testLoad(AssessmentSection $assessmentSection = null) + public function testLoad(AssessmentSection $assessmentSection = null): void { if (empty($assessmentSection)) { $uri = self::samplesDir() . 'custom/standalone_assessmentsection.xml'; @@ -50,7 +50,7 @@ public function testLoad(AssessmentSection $assessmentSection = null) } } - public function testWrite() + public function testWrite(): void { $uri = self::samplesDir() . 'custom/standalone_assessmentsection.xml'; $doc = new XmlDocument(); diff --git a/test/qtismtest/data/storage/xml/XmlAssessmentTestDocumentTest.php b/test/qtismtest/data/storage/xml/XmlAssessmentTestDocumentTest.php index 59aace8f2..79bdbf786 100644 --- a/test/qtismtest/data/storage/xml/XmlAssessmentTestDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlAssessmentTestDocumentTest.php @@ -19,7 +19,7 @@ */ class XmlAssessmentTestDocumentTest extends QtiSmTestCase { - public function testLoad() + public function testLoad(): void { $uri = __DIR__ . '/../../../../samples/ims/tests/interaction_mix_sachsen/interaction_mix_sachsen.xml'; $doc = new XmlDocument('2.1'); @@ -29,7 +29,7 @@ public function testLoad() $this::assertInstanceOf(AssessmentTest::class, $doc->getDocumentComponent()); } - public function testLoadFileDoesNotExist() + public function testLoadFileDoesNotExist(): void { // This file does not exist. $uri = __DIR__ . '/../../../../samples/invalid/abcd.xml'; @@ -38,7 +38,7 @@ public function testLoadFileDoesNotExist() $doc->load($uri); } - public function testLoadFileMalformed() + public function testLoadFileMalformed(): void { // This file contains malformed xml markup. $uri = __DIR__ . '/../../../../samples/invalid/malformed.xml'; @@ -54,7 +54,7 @@ public function testLoadFileMalformed() } } - public function testLoadSimpleItemSessionControlOnTestPart() + public function testLoadSimpleItemSessionControlOnTestPart(): void { $doc = new XmlDocument('2.1'); $doc->load(self::samplesDir() . 'custom/simple_itemsessioncontrol_testpart.xml'); @@ -64,7 +64,7 @@ public function testLoadSimpleItemSessionControlOnTestPart() $this::assertEquals(0, $testParts['testPartId']->getItemSessionControl()->getMaxAttempts()); } - public function testSaveSimpleItemSessionControlOnTestPart() + public function testSaveSimpleItemSessionControlOnTestPart(): void { $doc = new XmlDocument('2.1'); $doc->load(self::samplesDir() . 'custom/simple_itemsessioncontrol_testpart.xml'); @@ -81,7 +81,7 @@ public function testSaveSimpleItemSessionControlOnTestPart() unlink($file); } - public function testFullyQualified() + public function testFullyQualified(): void { $uri = __DIR__ . '/../../../../samples/custom/fully_qualified_assessmenttest.xml'; $doc = new XmlDocument('2.1'); @@ -92,7 +92,7 @@ public function testFullyQualified() $this::assertInstanceOf(AssessmentTest::class, $doc->getDocumentComponent()); } - public function testItemSessionControls() + public function testItemSessionControls(): void { $doc = new XmlDocument('2.1'); $doc->load(self::samplesDir() . 'custom/runtime/routeitem_itemsessioncontrols.xml'); @@ -108,7 +108,7 @@ public function testItemSessionControls() $this::assertEquals(4, $p02->getItemSessionControl()->getMaxAttempts()); } - public function testAssessmentSectionRefsInTestParts() + public function testAssessmentSectionRefsInTestParts(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/tests/nested_assessment_section_refs/test_definition/test.xml', true); @@ -127,7 +127,7 @@ public function testAssessmentSectionRefsInTestParts() * @param bool $filesystem * @throws XmlStorageException */ - public function testIncludeAssessmentSectionRefsInTestParts($file, $filesystem) + public function testIncludeAssessmentSectionRefsInTestParts($file, $filesystem): void { $doc = new XmlDocument(); @@ -165,7 +165,7 @@ public function testIncludeAssessmentSectionRefsInTestParts($file, $filesystem) /** * @return array */ - public function includeAssessmentSectionRefsInTestPartsProvider() + public function includeAssessmentSectionRefsInTestPartsProvider(): array { return [ [self::samplesDir() . 'custom/tests/nested_assessment_section_refs/test_definition/test.xml', false], @@ -179,7 +179,7 @@ public function includeAssessmentSectionRefsInTestPartsProvider() * @param bool $filesystem * @throws XmlStorageException */ - public function testIncludeAssessmentSectionRefsMixed($file, $filesystem) + public function testIncludeAssessmentSectionRefsMixed($file, $filesystem): void { $doc = new XmlDocument(); @@ -226,7 +226,7 @@ public function testIncludeAssessmentSectionRefsMixed($file, $filesystem) /** * @return array */ - public function includeAssessmentSectionRefsMixedProvider() + public function includeAssessmentSectionRefsMixedProvider(): array { return [ [self::samplesDir() . 'custom/tests/mixed_assessment_section_refs/test_similar_ids.xml', false], @@ -254,7 +254,7 @@ public function testParseItemBodyWithDirAttr(): void * @param $uri * @return string */ - private static function decorateUri($uri) + private static function decorateUri($uri): string { return __DIR__ . '/../../../../samples/ims/tests/' . $uri; } diff --git a/test/qtismtest/data/storage/xml/XmlCompactAssessmentDocumentTest.php b/test/qtismtest/data/storage/xml/XmlCompactAssessmentDocumentTest.php index 9d086d014..e7d47aeb6 100644 --- a/test/qtismtest/data/storage/xml/XmlCompactAssessmentDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlCompactAssessmentDocumentTest.php @@ -28,7 +28,7 @@ class XmlCompactAssessmentDocumentTest extends QtiSmTestCase * @param XmlCompactDocument|null $doc * @throws XmlStorageException */ - public function testLoad(XmlCompactDocument $doc = null) + public function testLoad(XmlCompactDocument $doc = null): void { if ($doc === null) { $doc = new XmlCompactDocument('2.1'); @@ -74,7 +74,7 @@ public function testLoad(XmlCompactDocument $doc = null) * @dataProvider versionsToTest * @param string $version */ - public function testSave(string $version) + public function testSave(string $version): void { // Version 1.0 for XmlCompactDocuments was in use by legacy code. Let's make it BC. $doc = new XmlCompactDocument($version); @@ -104,7 +104,7 @@ public function versionsToTest() * @dataProvider schemaValidateProvider * @param string $path */ - public function testSchemaValidate($path) + public function testSchemaValidate($path): void { $doc = new DOMDocument('1.0', 'UTF-8'); $doc->load($path, LIBXML_COMPACT | LIBXML_NONET | LIBXML_XINCLUDE); @@ -136,7 +136,7 @@ public function schemaValidateProvider(): array * @throws MarshallingException * @throws ReflectionException */ - public function testCreateFromXmlAssessmentTestDocument($version, $file, $filesystem) + public function testCreateFromXmlAssessmentTestDocument($version, $file, $filesystem): void { $inputFilesystem = $filesystem ? $this->getFileSystem() : null; $outputFilesystem = $filesystem ? $this->getOutputFileSystem() : null; @@ -194,7 +194,7 @@ public function createFromXmlAssessmentTestDocumentProvider(): array * @throws XmlStorageException * @throws ReflectionException */ - public function testCreateFromWithUnresolvableAssessmentSectionRef($file, $filesystem) + public function testCreateFromWithUnresolvableAssessmentSectionRef($file, $filesystem): void { $doc = new XmlDocument('2.1'); @@ -213,7 +213,7 @@ public function testCreateFromWithUnresolvableAssessmentSectionRef($file, $files /** * @return array */ - public function createFromWithUnresolvableAssessmentSectionRefProvider() + public function createFromWithUnresolvableAssessmentSectionRefProvider(): array { return [ [self::samplesDir() . 'custom/interaction_mix_saschen_assessmentsectionref/interaction_mix_sachsen3.xml', false], @@ -229,7 +229,7 @@ public function createFromWithUnresolvableAssessmentSectionRefProvider() * @throws MarshallingException * @throws ReflectionException */ - public function testCreateFromExploded($version, $sectionCount) + public function testCreateFromExploded($version, $sectionCount): void { $doc = new XmlDocument('2.1'); $file = self::samplesDir() . 'custom/interaction_mix_saschen_assessmentsectionref/interaction_mix_sachsen' . $version . '.xml'; @@ -307,7 +307,7 @@ public function createFromExplodedProvider() * @throws XmlStorageException * @throws ReflectionException */ - public function testCreateFromTestWithShuffledInteractions($file, $filesystem) + public function testCreateFromTestWithShuffledInteractions($file, $filesystem): void { $doc = new XmlDocument('2.1'); @@ -404,7 +404,7 @@ public function testCreateFromTestWithShuffledInteractions($file, $filesystem) /** * @return array */ - public function createFromTestWithShuffledInteractionsProvider() + public function createFromTestWithShuffledInteractionsProvider(): array { return [ [self::samplesDir() . 'custom/tests/shufflings.xml', false], @@ -419,7 +419,7 @@ public function createFromTestWithShuffledInteractionsProvider() * @param XmlCompactDocument|null $doc * @throws XmlStorageException */ - public function testLoadRubricBlockRefs($file, $filesystem, XmlCompactDocument $doc = null) + public function testLoadRubricBlockRefs($file, $filesystem, XmlCompactDocument $doc = null): void { if ($doc === null) { $src = $file; @@ -452,7 +452,7 @@ public function testLoadRubricBlockRefs($file, $filesystem, XmlCompactDocument $ /** * @return array */ - public function loadRubricBlockRefsProvider() + public function loadRubricBlockRefsProvider(): array { return [ [self::samplesDir() . 'custom/runtime/rubricblockref.xml', false], @@ -460,7 +460,7 @@ public function loadRubricBlockRefsProvider() ]; } - public function testSaveRubricBlockRefs() + public function testSaveRubricBlockRefs(): void { $src = self::samplesDir() . 'custom/runtime/rubricblockref.xml'; $doc = new XmlCompactDocument(); @@ -476,7 +476,7 @@ public function testSaveRubricBlockRefs() $this::assertFileDoesNotExist($file); } - public function testExplodeRubricBlocks() + public function testExplodeRubricBlocks(): void { $src = self::samplesDir() . 'custom/runtime/rubricblockrefs_explosion.xml'; $doc = new XmlCompactDocument(); @@ -514,7 +514,7 @@ public function testExplodeRubricBlocks() $this::assertEquals('RB_S01_2', $rubricBlockRefs[2]->getIdentifier()); } - public function testExplodeTestFeedbacks() + public function testExplodeTestFeedbacks(): void { $src = self::samplesDir() . 'custom/runtime/testfeedbackrefs_explosion.xml'; $doc = new XmlCompactDocument(); @@ -552,7 +552,7 @@ public function testExplodeTestFeedbacks() $this::assertEquals(0, $doc->getDocumentComponent()->containsComponentWithClassName('testFeedback')); } - public function testModalFeedbackRuleLoad() + public function testModalFeedbackRuleLoad(): void { $src = self::samplesDir() . 'custom/runtime/modalfeedbackrules.xml'; $doc = new XmlCompactDocument(); @@ -579,7 +579,7 @@ public function testModalFeedbackRuleLoad() /** * @depends testModalFeedbackRuleLoad */ - public function testModalFeedbackRuleSave() + public function testModalFeedbackRuleSave(): void { $src = self::samplesDir() . 'custom/runtime/modalfeedbackrules.xml'; $doc = new XmlCompactDocument(); @@ -608,7 +608,7 @@ public function testModalFeedbackRuleSave() unlink($file); } - public function testTestFeedbackRefLoad() + public function testTestFeedbackRefLoad(): void { $src = self::samplesDir() . 'custom/runtime/test_feedback_refs.xml'; $doc = new XmlCompactDocument(); @@ -622,7 +622,7 @@ public function testTestFeedbackRefLoad() /** * @depends testTestFeedbackRefLoad */ - public function testFeedbackRefSave() + public function testFeedbackRefSave(): void { $src = self::samplesDir() . 'custom/runtime/test_feedback_refs.xml'; $doc = new XmlCompactDocument(); @@ -659,7 +659,7 @@ public function testFeedbackRefSave() $this::assertEquals('./TFMAIN.xml', $testFeedbackRefElt3->getAttribute('href')); } - public function testCreateFromAssessmentTestEndAttemptIdentifiers() + public function testCreateFromAssessmentTestEndAttemptIdentifiers(): void { $doc = new XmlDocument('2.1'); $file = self::samplesDir() . 'custom/test_contains_endattemptinteractions.xml'; @@ -683,7 +683,7 @@ public function testCreateFromAssessmentTestEndAttemptIdentifiers() $this::assertEquals('LOST2', $endAttemptIdentifiers[1]); } - public function testCreateFromAssessmentTestInvalidAssessmentItemRefResolution() + public function testCreateFromAssessmentTestInvalidAssessmentItemRefResolution(): void { $this->expectException(XmlStorageException::class); $this->expectExceptionMessage("An error occurred while unreferencing item reference with identifier 'Q01'."); @@ -695,7 +695,7 @@ public function testCreateFromAssessmentTestInvalidAssessmentItemRefResolution() XmlCompactDocument::createFromXmlAssessmentTestDocument($doc, new LocalFileResolver()); } - public function testCreateFromAssessmentTestResponseValidityConstraints() + public function testCreateFromAssessmentTestResponseValidityConstraints(): void { $doc = new XmlDocument('2.1'); $file = self::samplesDir() . 'custom/tests/response_validity_constraints.xml'; @@ -710,7 +710,7 @@ public function testCreateFromAssessmentTestResponseValidityConstraints() $this::assertEquals(1, $assessmentItemRefs[0]->getResponseValidityConstraints()[0]->getMaxConstraint()); } - public function testLoadResponseValidityConstraints() + public function testLoadResponseValidityConstraints(): void { $doc = new XmlCompactDocument('2.1'); $file = self::samplesDir() . 'custom/runtime/validate_response/nonlinear_simultaneous.xml'; @@ -742,7 +742,7 @@ public function testLoadResponseValidityConstraints() /** * @depends testLoadResponseValidityConstraints */ - public function testLoadAssociationValidityConstraints() + public function testLoadAssociationValidityConstraints(): void { $doc = new XmlCompactDocument('2.1'); $file = self::samplesDir() . 'custom/runtime/validate_response/association_constraints.xml'; @@ -763,7 +763,7 @@ public function testLoadAssociationValidityConstraints() $this::assertEquals(1, $associationValidityConstraints[1]->getMaxConstraint()); } - public function testLoadAssociationValidityConstraintsInvalidAgainstXsd() + public function testLoadAssociationValidityConstraintsInvalidAgainstXsd(): void { $this->expectException(XmlStorageException::class); @@ -778,7 +778,7 @@ public function testLoadAssociationValidityConstraintsInvalidAgainstXsd() * @throws XmlStorageException * @throws ReflectionException */ - public function testCreateFromAssessmentSectionRefs($file) + public function testCreateFromAssessmentSectionRefs($file): void { $doc = new XmlDocument(); $doc->load($file); @@ -822,7 +822,7 @@ public function testCreateFromAssessmentSectionRefs($file) /** * @return array */ - public function ceateFromAssessmentSectionRefsDataProvider() + public function ceateFromAssessmentSectionRefsDataProvider(): array { return [ [self::samplesDir() . 'custom/tests/mixed_assessment_section_refs/test_similar_ids.xml'], @@ -830,7 +830,7 @@ public function ceateFromAssessmentSectionRefsDataProvider() ]; } - public function testCreateFromAssessmentTestTitleAndLabels() + public function testCreateFromAssessmentTestTitleAndLabels(): void { $doc = new XmlDocument('2.1'); $file = self::samplesDir() . 'custom/extended_title_label.xml'; @@ -868,7 +868,7 @@ public function testCreateFromAssessmentTestTitleAndLabels() * @param string $expectedVersion * @throws XmlStorageException */ - public function testInferVersionAndSchemaValidate(string $testFile, string $expectedVersion) + public function testInferVersionAndSchemaValidate(string $testFile, string $expectedVersion): void { $doc = new XmlCompactDocument(); $doc->load($testFile, true); @@ -891,7 +891,7 @@ public function inferVersionAndSchemaValidateProvider(): array ]; } - public function testInferVersionWithMissingNamespaceReturnsDefaultVersion() + public function testInferVersionWithMissingNamespaceReturnsDefaultVersion(): void { $xmlDoc = new XmlCompactDocument(); @@ -900,7 +900,7 @@ public function testInferVersionWithMissingNamespaceReturnsDefaultVersion() $this::assertEquals('2.1.0', $xmlDoc->getVersion()); } - public function testInferVersionWithWrongNamespaceThrowsException() + public function testInferVersionWithWrongNamespaceThrowsException(): void { $xmlDoc = new XmlCompactDocument(); @@ -917,7 +917,7 @@ public function testInferVersionWithWrongNamespaceThrowsException() * @param string $toFile * @throws XmlStorageException */ - public function testChangeVersion($fromVersion, $fromFile, $toVersion, $toFile) + public function testChangeVersion($fromVersion, $fromFile, $toVersion, $toFile): void { $doc = new XmlCompactDocument($fromVersion); $doc->load($fromFile); @@ -942,7 +942,7 @@ public function changeVersionProvider(): array ]; } - public function testChangeVersionWithUnknownVersionThrowsException() + public function testChangeVersionWithUnknownVersionThrowsException(): void { $wrongVersion = '36.15'; $patchedWrongVersion = $wrongVersion . '.0'; diff --git a/test/qtismtest/data/storage/xml/XmlCustomOperatorDocumentTest.php b/test/qtismtest/data/storage/xml/XmlCustomOperatorDocumentTest.php index 624d043d8..161f6cf0a 100644 --- a/test/qtismtest/data/storage/xml/XmlCustomOperatorDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlCustomOperatorDocumentTest.php @@ -19,7 +19,7 @@ class XmlCustomOperatorDocumentTest extends QtiSmTestCase * @param string $url * @throws XmlStorageException */ - public function testReadNoLax($url = '') + public function testReadNoLax($url = ''): void { $doc = new XmlDocument(); $url = (empty($url)) ? (self::samplesDir() . 'custom/operators/custom_operator_1.xml') : $url; @@ -41,7 +41,7 @@ public function testReadNoLax($url = '') $this::assertEquals('Param1Data', $expressions[0]->getValue()); } - public function testWriteNoLax() + public function testWriteNoLax(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/operators/custom_operator_1.xml'); @@ -57,7 +57,7 @@ public function testWriteNoLax() * @param string $url * @throws XmlStorageException */ - public function testReadQTIOnly($url = '') + public function testReadQTIOnly($url = ''): void { $doc = new XmlDocument(); $url = (empty($url)) ? (self::samplesDir() . 'custom/operators/custom_operator_2.xml') : $url; @@ -73,7 +73,7 @@ public function testReadQTIOnly($url = '') $this::assertEquals('Param1Data', $expressions[0]->getValue()); } - public function testWriteQTIOnly() + public function testWriteQTIOnly(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/operators/custom_operator_2.xml'); @@ -89,7 +89,7 @@ public function testWriteQTIOnly() * @param string $url * @throws XmlStorageException */ - public function testReadFullLax($url = '') + public function testReadFullLax($url = ''): void { $doc = new XmlDocument(); $url = (empty($url)) ? (self::samplesDir() . 'custom/operators/custom_operator_3.xml') : $url; @@ -129,7 +129,7 @@ public function testReadFullLax($url = '') * @throws XmlStorageException * @throws MarshallingException */ - public function testWriteFullLax($url = '') + public function testWriteFullLax($url = ''): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/operators/custom_operator_3.xml'); @@ -145,7 +145,7 @@ public function testWriteFullLax($url = '') * @param string $url * @throws XmlStorageException */ - public function testReadNestedLax($url = '') + public function testReadNestedLax($url = ''): void { $doc = new XmlDocument(); $url = (empty($url)) ? (self::samplesDir() . 'custom/operators/custom_operator_nested_1.xml') : $url; @@ -198,7 +198,7 @@ public function testReadNestedLax($url = '') $this::assertEquals('Param1Data', $baseValue->getValue()); } - public function testWriteNestedLax() + public function testWriteNestedLax(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/operators/custom_operator_nested_1.xml'); diff --git a/test/qtismtest/data/storage/xml/XmlDocumentTemplateLocationTest.php b/test/qtismtest/data/storage/xml/XmlDocumentTemplateLocationTest.php index 65e9fb805..72a399642 100644 --- a/test/qtismtest/data/storage/xml/XmlDocumentTemplateLocationTest.php +++ b/test/qtismtest/data/storage/xml/XmlDocumentTemplateLocationTest.php @@ -18,7 +18,7 @@ class XmlDocumentTemplateLocationTest extends QtiSmTestCase * @throws XmlStorageException * @dataProvider correctlyFormedProvider */ - public function testCorrectlyFormed($file, $filesystem) + public function testCorrectlyFormed($file, $filesystem): void { $doc = new XmlDocument(); @@ -42,7 +42,7 @@ public function testCorrectlyFormed($file, $filesystem) /** * @return array */ - public function correctlyFormedProvider() + public function correctlyFormedProvider(): array { return [ [self::samplesDir() . 'custom/items/template_location/template_location_item.xml', false], @@ -50,7 +50,7 @@ public function correctlyFormedProvider() ]; } - public function testNotLoaded() + public function testNotLoaded(): void { $doc = new XmlDocument(); @@ -65,7 +65,7 @@ public function testNotLoaded() * @throws XmlStorageException * @dataProvider wrongTargetProvider */ - public function testWrongTarget($file, $filesystem) + public function testWrongTarget($file, $filesystem): void { $doc = new XmlDocument(); @@ -82,7 +82,7 @@ public function testWrongTarget($file, $filesystem) /** * @return array */ - public function wrongTargetProvider() + public function wrongTargetProvider(): array { return [ [self::samplesDir() . 'custom/items/template_location/template_location_item_wrong_target.xml', false], @@ -96,7 +96,7 @@ public function wrongTargetProvider() * @throws XmlStorageException * @dataProvider invalidTargetNoValidationProvider */ - public function testInvalidTargetNoValidation($file, $filesystem) + public function testInvalidTargetNoValidation($file, $filesystem): void { $doc = new XmlDocument(); @@ -115,7 +115,7 @@ public function testInvalidTargetNoValidation($file, $filesystem) /** * @return array */ - public function invalidTargetNoValidationProvider() + public function invalidTargetNoValidationProvider(): array { return [ [self::samplesDir() . 'custom/items/template_location/template_location_item_invalid_target.xml', false], @@ -129,7 +129,7 @@ public function invalidTargetNoValidationProvider() * @throws XmlStorageException * @dataProvider invalidTargetValidationProvider */ - public function testInvalidTargetValidation($file, $filesystem) + public function testInvalidTargetValidation($file, $filesystem): void { $doc = new XmlDocument(); @@ -147,7 +147,7 @@ public function testInvalidTargetValidation($file, $filesystem) /** * @return array */ - public function invalidTargetValidationProvider() + public function invalidTargetValidationProvider(): array { return [ [self::samplesDir() . 'custom/items/template_location/template_location_item_invalid_target.xml', false], diff --git a/test/qtismtest/data/storage/xml/XmlDocumentTest.php b/test/qtismtest/data/storage/xml/XmlDocumentTest.php index f5af94896..a4555ec2b 100644 --- a/test/qtismtest/data/storage/xml/XmlDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlDocumentTest.php @@ -25,7 +25,7 @@ */ class XmlDocumentTest extends QtiSmTestCase { - public function testRubricBlockRuptureNoValidation() + public function testRubricBlockRuptureNoValidation(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/paper_vs_xsd/rubricblock_other_content_than_block.xml'); @@ -55,7 +55,7 @@ public function testRubricBlockRuptureNoValidation() $this::assertEquals('Go to somewhere...', $aContent[0]->getContent()); } - public function testRubricBlockRuptureValidation() + public function testRubricBlockRuptureValidation(): void { $doc = new XmlDocument(); $file = self::samplesDir() . 'custom/paper_vs_xsd/rubricblock_other_content_than_block.xml'; @@ -76,7 +76,7 @@ public function testRubricBlockRuptureValidation() $this::assertTrue(true); } - public function testTemplateBlockRuptureNoValidation() + public function testTemplateBlockRuptureNoValidation(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/paper_vs_xsd/templateblock_other_content_than_block.xml'); @@ -106,7 +106,7 @@ public function testTemplateBlockRuptureNoValidation() $this::assertEquals('Go to somewhere...', $aContent[0]->getContent()); } - public function testTemplateBlockRuptureValidation() + public function testTemplateBlockRuptureValidation(): void { $doc = new XmlDocument(); $file = self::samplesDir() . 'custom/paper_vs_xsd/templateblock_other_content_than_block.xml'; @@ -124,7 +124,7 @@ public function testTemplateBlockRuptureValidation() $this::assertTrue(true); } - public function testFeedbackBlockRuptureNoValidation() + public function testFeedbackBlockRuptureNoValidation(): void { $doc = new XmlDocument(); $file = self::samplesDir() . 'custom/paper_vs_xsd/feedbackblock_other_content_than_block.xml'; @@ -158,7 +158,7 @@ public function testFeedbackBlockRuptureNoValidation() $this::assertEquals('Go to somewhere...', $aContent[0]->getContent()); } - public function testFeedbackBlockRuptureValidation() + public function testFeedbackBlockRuptureValidation(): void { $doc = new XmlDocument(); $file = self::samplesDir() . 'custom/paper_vs_xsd/feedbackblock_other_content_than_block.xml'; @@ -176,7 +176,7 @@ public function testFeedbackBlockRuptureValidation() $this::assertTrue(true); } - public function testPromptRuptureNoValidation() + public function testPromptRuptureNoValidation(): void { $doc = new XmlDocument(); $file = self::samplesDir() . 'custom/paper_vs_xsd/prompt_other_content_than_inlinestatic.xml'; @@ -203,7 +203,7 @@ public function testPromptRuptureNoValidation() $this::assertEquals('Resistance is futile!', $simpleChoiceContent[0]->getContent()); } - public function testPromptRuptureValidation() + public function testPromptRuptureValidation(): void { $doc = new XmlDocument(); $file = self::samplesDir() . 'custom/paper_vs_xsd/prompt_other_content_than_inlinestatic.xml'; @@ -221,7 +221,7 @@ public function testPromptRuptureValidation() $this::assertTrue(true); } - public function testAmps() + public function testAmps(): void { $file = self::samplesDir() . 'custom/amps.xml'; $doc = new XmlDocument(); @@ -236,13 +236,13 @@ public function testAmps() $this::assertEquals('Hello there & there! I am trying to make "crazy"', $divText->getcontent()); } - public function testWrongVersion() + public function testWrongVersion(): void { $this->expectException(InvalidArgumentException::class); new XMLDocument('2.2.1012'); } - public function testLoadFromString() + public function testLoadFromString(): void { $doc = new XmlDocument('2.1'); $doc->loadFromString(''); @@ -253,7 +253,7 @@ public function testLoadFromString() $this::assertEquals('./Q01.xml', $component->getHref()); } - public function testLoadFromEmptyString() + public function testLoadFromEmptyString(): void { $doc = new XmlDocument('2.1'); @@ -265,7 +265,7 @@ public function testLoadFromEmptyString() $doc->loadFromString(''); } - public function testLoadFromMalformedString() + public function testLoadFromMalformedString(): void { $doc = new XmlDocument('2.1'); @@ -287,7 +287,7 @@ public function testLoadFromMalformedString() $doc->loadFromString(''); } - public function testSerialization() + public function testSerialization(): void { $doc = new XmlDocument('2.1'); $doc->loadFromString(''); @@ -298,7 +298,7 @@ public function testSerialization() ); } - public function testOlderSerializedDataDeserialization() + public function testOlderSerializedDataDeserialization(): void { if (PHP_VERSION_ID >= 80100) { $this->markTestSkipped('DOM objects serialization is impossible in PHP 8.1 or higher.'); @@ -316,7 +316,7 @@ public function testOlderSerializedDataDeserialization() ); } - public function testLoadNoVersion() + public function testLoadNoVersion(): void { $doc = new XmlDocument('2.1'); @@ -324,7 +324,7 @@ public function testLoadNoVersion() $this::assertEquals('2.1.0', $doc->getVersion()); } - public function testLoadFromNonExistingFile() + public function testLoadFromNonExistingFile(): void { $doc = new XmlDocument('2.1'); // This path does not resolve anything. @@ -338,7 +338,7 @@ public function testLoadFromNonExistingFile() $doc->load($path); } - public function testLoadFromStringNotSupportedElement20() + public function testLoadFromStringNotSupportedElement20(): void { // Will throw an error because assessmentItemRef is not supported in QTI 2.0. $doc = new XmlDocument('2.0'); @@ -350,7 +350,7 @@ public function testLoadFromStringNotSupportedElement20() $doc->loadFromString(''); } - public function testSaveNoMarshaller20() + public function testSaveNoMarshaller20(): void { $doc = new XMLDocument('2.1.1'); $doc->loadFromString(''); @@ -363,7 +363,7 @@ public function testSaveNoMarshaller20() $doc->saveToString(); } - public function testVersionDoesNotChangeLoadFromString() + public function testVersionDoesNotChangeLoadFromString(): void { $doc = new XmlDocument('2.1.1'); $doc->loadFromString(''); @@ -371,7 +371,7 @@ public function testVersionDoesNotChangeLoadFromString() $this::assertEquals('2.1.1', $doc->getVersion()); } - public function testSaveUnknownLocation() + public function testSaveUnknownLocation(): void { $qtiPath = '/unknown/location/qti.xml'; @@ -389,7 +389,7 @@ public function testSaveUnknownLocation() $doc->save($qtiPath); } - public function testSaveWrongLocationFileSystem() + public function testSaveWrongLocationFileSystem(): void { $doc = new XmlDocument('2.1.1'); $doc->setFilesystem($this->getOutputFileSystem()); @@ -401,7 +401,7 @@ public function testSaveWrongLocationFileSystem() $doc->save('../../../../../../../../unknown/location.xml'); } - public function testUnknownClassWhileSavingBecauseOfVersion1() + public function testUnknownClassWhileSavingBecauseOfVersion1(): void { $doc = new XmlDocument('2.1.1'); $doc->loadFromString(' @@ -421,7 +421,7 @@ public function testUnknownClassWhileSavingBecauseOfVersion1() $doc->saveToString(); } - public function testUnknownClassWhileLoadingBecauseOfVersion1() + public function testUnknownClassWhileLoadingBecauseOfVersion1(): void { $expectedMsg = "'matchTable' components are not supported in QTI version '2.0.0'"; $this->expectException(XmlStorageException::class); @@ -438,7 +438,7 @@ public function testUnknownClassWhileLoadingBecauseOfVersion1() '); } - public function testUnknownClassWhileSavingBecauseOfVersion2() + public function testUnknownClassWhileSavingBecauseOfVersion2(): void { $doc = new XmlDocument('2.1.1'); $doc->loadFromString(' @@ -459,7 +459,7 @@ public function testUnknownClassWhileSavingBecauseOfVersion2() $doc->saveToString(); } - public function testUnknownClassWhileLoadingBecauseOfVersion2() + public function testUnknownClassWhileLoadingBecauseOfVersion2(): void { $expectedMsg = "'mathConstant' components are not supported in QTI version '2.0.0'"; $this->expectException(XmlStorageException::class); @@ -476,7 +476,7 @@ public function testUnknownClassWhileLoadingBecauseOfVersion2() '); } - public function testUnknownClassWhileSavingBecauseOfVersion3() + public function testUnknownClassWhileSavingBecauseOfVersion3(): void { $doc = new XmlDocument('2.2.0'); $doc->loadFromString(' @@ -494,7 +494,7 @@ public function testUnknownClassWhileSavingBecauseOfVersion3() $doc->saveToString(); } - public function testUnknownClassWhileLoadingBecauseOfVersion3() + public function testUnknownClassWhileLoadingBecauseOfVersion3(): void { $expectedMsg = "'bdo' components are not supported in QTI version '2.0.0'"; $this->expectException(XmlStorageException::class); @@ -508,7 +508,7 @@ public function testUnknownClassWhileLoadingBecauseOfVersion3() '); } - public function testInvalidAgainstXMLSchema() + public function testInvalidAgainstXMLSchema(): void { $xsdLocation = realpath( __DIR__ . '/../../../../../src/qtism/data/storage/xml/versions/../schemes/qtiv2p1/imsqti_v2p1.xsd' @@ -527,7 +527,7 @@ public function testInvalidAgainstXMLSchema() $doc->load($uri, true); } - public function testXIncludeNoComponent() + public function testXIncludeNoComponent(): void { $doc = new XmlDocument(); @@ -536,7 +536,7 @@ public function testXIncludeNoComponent() $doc->xInclude(); } - public function testResolveTemplateLocationNoComponent() + public function testResolveTemplateLocationNoComponent(): void { $doc = new XmlDocument(); @@ -545,7 +545,7 @@ public function testResolveTemplateLocationNoComponent() $doc->resolveTemplateLocation(); } - public function testIncludeAssessmentSectionRefsNoComponent() + public function testIncludeAssessmentSectionRefsNoComponent(): void { $doc = new XmlDocument(); @@ -561,7 +561,7 @@ public function testIncludeAssessmentSectionRefsNoComponent() * @throws XmlStorageException * @throws MarshallingException */ - public function testSaveNoComponent($file, $filesystem) + public function testSaveNoComponent($file, $filesystem): void { $doc = new XmlDocument(); @@ -578,7 +578,7 @@ public function testSaveNoComponent($file, $filesystem) /** * @return array */ - public function saveNoComponentProvider() + public function saveNoComponentProvider(): array { return [ ['path.xml', true], @@ -586,7 +586,7 @@ public function saveNoComponentProvider() ]; } - public function testLoadFromFileSystemNoValidation() + public function testLoadFromFileSystemNoValidation(): void { $fileSystem = $this->getFileSystem(); $doc = new XmlDocument(); @@ -596,7 +596,7 @@ public function testLoadFromFileSystemNoValidation() $this::assertInstanceOf(AssessmentItem::class, $doc->getDocumentComponent()); } - public function testLoadFromFileSystemPositiveValidation() + public function testLoadFromFileSystemPositiveValidation(): void { $fileSystem = $this->getFileSystem(); $doc = new XmlDocument(); @@ -606,7 +606,7 @@ public function testLoadFromFileSystemPositiveValidation() $this::assertInstanceOf(AssessmentItem::class, $doc->getDocumentComponent()); } - public function testLoadFromFileSystemNegativeValidation() + public function testLoadFromFileSystemNegativeValidation(): void { $fileSystem = $this->getFileSystem(); $doc = new XmlDocument(); @@ -618,7 +618,7 @@ public function testLoadFromFileSystemNegativeValidation() $doc->load('invalid/xsdinvalid.xml', true); } - public function testLoadFromFileSystemNotExistingFile() + public function testLoadFromFileSystemNotExistingFile(): void { $fileSystem = $this->getFileSystem(); $doc = new XmlDocument(); @@ -631,7 +631,7 @@ public function testLoadFromFileSystemNotExistingFile() $doc->load($path); } - public function testLoadFromFileSystemEmptyFile() + public function testLoadFromFileSystemEmptyFile(): void { $fileSystem = $this->getFileSystem(); $doc = new XmlDocument(); @@ -644,7 +644,7 @@ public function testLoadFromFileSystemEmptyFile() $doc->load($path); } - public function testSaveFileSystem() + public function testSaveFileSystem(): void { $filesystem = $this->getFileSystem(); $doc = new XmlDocument(); @@ -668,7 +668,7 @@ public function testSaveFileSystem() * @param string $expectedVersion * @throws XmlStorageException */ - public function testInferQTIVersionValid($file, $expectedVersion) + public function testInferQTIVersionValid($file, $expectedVersion): void { $dom = new XmlDocument(); $dom->load($file); @@ -678,7 +678,7 @@ public function testInferQTIVersionValid($file, $expectedVersion) /** * @return array */ - public function validInferQTIVersionProvider() + public function validInferQTIVersionProvider(): array { return [ [self::samplesDir() . 'ims/items/2_2/choice_multiple.xml', '2.2.0'], @@ -698,7 +698,7 @@ public function validInferQTIVersionProvider() ]; } - public function testInferVersionWithMissingNamespaceReturnsDefaultVersion() + public function testInferVersionWithMissingNamespaceReturnsDefaultVersion(): void { $xmlDoc = new XmlDocument(); @@ -707,7 +707,7 @@ public function testInferVersionWithMissingNamespaceReturnsDefaultVersion() $this::assertEquals('2.1.0', $xmlDoc->getVersion()); } - public function testInferVersionWithWrongNamespaceThrowsException() + public function testInferVersionWithWrongNamespaceThrowsException(): void { $xmlDoc = new XmlDocument(); @@ -724,7 +724,7 @@ public function testInferVersionWithWrongNamespaceThrowsException() * @param string $toFile * @throws XmlStorageException */ - public function testChangeVersion($fromVersion, $fromFile, $toVersion, $toFile) + public function testChangeVersion($fromVersion, $fromFile, $toVersion, $toFile): void { $doc = new XmlDocument($fromVersion); $doc->load($fromFile); @@ -754,7 +754,7 @@ public function changeVersionProvider(): array ]; } - public function testChangeVersionWithUnknownVersionThrowsException() + public function testChangeVersionWithUnknownVersionThrowsException(): void { $wrongVersion = '36.15'; $patchedWrongVersion = $wrongVersion . '.0'; diff --git a/test/qtismtest/data/storage/xml/XmlDocumentXIncludeTest.php b/test/qtismtest/data/storage/xml/XmlDocumentXIncludeTest.php index 7f470db73..78704ff57 100644 --- a/test/qtismtest/data/storage/xml/XmlDocumentXIncludeTest.php +++ b/test/qtismtest/data/storage/xml/XmlDocumentXIncludeTest.php @@ -12,7 +12,7 @@ */ class XmlDocumentXIncludeTest extends QtiSmTestCase { - public function testLoadAndSaveXIncludeNsInTag() + public function testLoadAndSaveXIncludeNsInTag(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/items/xinclude/xinclude_ns_in_tag.xml', true); @@ -42,7 +42,7 @@ public function testLoadAndSaveXIncludeNsInTag() * @throws XmlStorageException * @throws ReflectionException */ - public function testLoadAndResolveXIncludeSameBase($file, $filesystem) + public function testLoadAndResolveXIncludeSameBase($file, $filesystem): void { $doc = new XmlDocument(); @@ -78,7 +78,7 @@ public function testLoadAndResolveXIncludeSameBase($file, $filesystem) /** * @return array */ - public function loadAndResolveXIncludeSameBaseProvider() + public function loadAndResolveXIncludeSameBaseProvider(): array { return [ [self::samplesDir() . 'custom/items/xinclude/xinclude_ns_in_tag.xml', false], @@ -89,7 +89,7 @@ public function loadAndResolveXIncludeSameBaseProvider() /** * @depends testLoadAndResolveXIncludeSameBase */ - public function testLoadAndResolveXIncludeDifferentBase() + public function testLoadAndResolveXIncludeDifferentBase(): void { $doc = new XmlDocument(); $doc->load(self::samplesDir() . 'custom/items/xinclude/xinclude_ns_in_tag_subfolder.xml', true); diff --git a/test/qtismtest/data/storage/xml/XmlResponseProcessingDocumentTest.php b/test/qtismtest/data/storage/xml/XmlResponseProcessingDocumentTest.php index c67df4b4d..7d485df1e 100644 --- a/test/qtismtest/data/storage/xml/XmlResponseProcessingDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlResponseProcessingDocumentTest.php @@ -16,7 +16,7 @@ */ class XmlResponseProcessingDocumentTest extends QtiSmTestCase { - public function testLoadMatchCorrect() + public function testLoadMatchCorrect(): void { $xml = new XmlDocument('2.1'); $xml->load(self::getTemplatesPath() . '2_1/match_correct.xml'); @@ -51,7 +51,7 @@ public function testLoadMatchCorrect() * @param string $url * @throws XmlStorageException */ - public function testLoad($url) + public function testLoad($url): void { $xml = new XmlDocument(); $xml->load($url, true); @@ -64,7 +64,7 @@ public function testLoad($url) * * @return string */ - public static function getTemplatesPath() + public static function getTemplatesPath(): string { return __DIR__ . '/../../../../../src/qtism/runtime/processing/templates/'; } @@ -72,7 +72,7 @@ public static function getTemplatesPath() /** * @return array */ - public function loadProvider() + public function loadProvider(): array { return [ [self::getTemplatesPath() . '2_1/match_correct.xml'], diff --git a/test/qtismtest/data/storage/xml/XmlResultDocumentTest.php b/test/qtismtest/data/storage/xml/XmlResultDocumentTest.php index f0ee186d4..b81ef38db 100644 --- a/test/qtismtest/data/storage/xml/XmlResultDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlResultDocumentTest.php @@ -38,7 +38,7 @@ */ class XmlResultDocumentTest extends QtiSmTestCase { - public function testLoad() + public function testLoad(): void { $xmlDoc = new XmlResultDocument(); $xmlDoc->load(self::samplesDir() . 'results/simple-assessment-result.xml', true); @@ -72,7 +72,7 @@ public function testLoad() $this::assertCount(2, $testResult->getItemVariables()); } - public function testLoadMissingData() + public function testLoadMissingData(): void { $this->expectException(XmlStorageException::class); $this->expectExceptionMessage('The document could not be validated with XML Schema'); @@ -81,7 +81,7 @@ public function testLoadMissingData() $xmlDoc->load(self::samplesDir() . 'results/simple-assessment-result-missing-data.xml', true); } - public function testSaveToString() + public function testSaveToString(): void { $xmlDoc = new XmlResultDocument(); $xmlDoc->load(self::samplesDir() . 'results/simple-assessment-result.xml', true); @@ -97,7 +97,7 @@ public function testSaveToString() * @param string $expectedVersion * @throws XmlStorageException */ - public function testInferVersionAndSchemaValidate(string $testFile, string $expectedVersion) + public function testInferVersionAndSchemaValidate(string $testFile, string $expectedVersion): void { $xmlDoc = new XmlResultDocument(); $xmlDoc->load($testFile, true); @@ -116,7 +116,7 @@ public function inferVersionAndSchemaValidateProvider(): array ]; } - public function testInferVersionWithMissingNamespaceReturnsDefaultVersion() + public function testInferVersionWithMissingNamespaceReturnsDefaultVersion(): void { $xmlDoc = new XmlResultDocument(); @@ -125,7 +125,7 @@ public function testInferVersionWithMissingNamespaceReturnsDefaultVersion() $this::assertEquals('2.1.0', $xmlDoc->getVersion()); } - public function testInferVersionWithWrongNamespaceThrowsException() + public function testInferVersionWithWrongNamespaceThrowsException(): void { $xmlDoc = new XmlResultDocument(); @@ -142,7 +142,7 @@ public function testInferVersionWithWrongNamespaceThrowsException() * @param string $toFile * @throws XmlStorageException */ - public function testChangeVersion($fromVersion, $fromFile, $toVersion, $toFile) + public function testChangeVersion($fromVersion, $fromFile, $toVersion, $toFile): void { $doc = new XmlResultDocument($fromVersion); $doc->load($fromFile, true); @@ -167,7 +167,7 @@ public function changeVersionProvider(): array ]; } - public function testChangeVersionWithUnknownVersionThrowsException() + public function testChangeVersionWithUnknownVersionThrowsException(): void { $wrongVersion = '36.15'; $patchedWrongVersion = $wrongVersion . '.0'; diff --git a/test/qtismtest/data/storage/xml/XmlUtilsTest.php b/test/qtismtest/data/storage/xml/XmlUtilsTest.php index c1aa9bc91..3e81f84cf 100644 --- a/test/qtismtest/data/storage/xml/XmlUtilsTest.php +++ b/test/qtismtest/data/storage/xml/XmlUtilsTest.php @@ -19,7 +19,7 @@ class XmlUtilsTest extends QtiSmTestCase * @param string $expectedXmlString * @dataProvider anonimizeElementProvider */ - public function testAnonimizeElement($originalXmlString, $expectedXmlString) + public function testAnonimizeElement($originalXmlString, $expectedXmlString): void { $elt = $this->createDOMElement($originalXmlString); $newElt = Utils::anonimizeElement($elt); @@ -30,7 +30,7 @@ public function testAnonimizeElement($originalXmlString, $expectedXmlString) /** * @return array */ - public function anonimizeElementProvider() + public function anonimizeElementProvider(): array { return [ [ @@ -57,7 +57,7 @@ public function anonimizeElementProvider() * @param string $namespaceUri * @param bool|string $expectedLocation */ - public function testGetXsdLocation($file, $namespaceUri, $expectedLocation) + public function testGetXsdLocation($file, $namespaceUri, $expectedLocation): void { $document = new DOMDocument('1.0', 'UTF-8'); $document->load($file); @@ -69,7 +69,7 @@ public function testGetXsdLocation($file, $namespaceUri, $expectedLocation) /** * @return array */ - public function getXsdLocationProvider() + public function getXsdLocationProvider(): array { return [ // Valid. @@ -133,7 +133,7 @@ public function getXsdLocationProvider() ]; } - public function testChangeNamespaceElementName() + public function testChangeNamespaceElementName(): void { $foo = $this->createDOMElement(''); $foo = Utils::changeElementName($foo, 'bar'); @@ -147,7 +147,7 @@ public function testChangeNamespaceElementName() * @param bool $isAttribute * @param string $expected */ - public function testEscapeXmlSpecialChars($str, $isAttribute, $expected) + public function testEscapeXmlSpecialChars($str, $isAttribute, $expected): void { $this::assertEquals($expected, Utils::escapeXmlSpecialChars($str, $isAttribute)); } @@ -155,7 +155,7 @@ public function testEscapeXmlSpecialChars($str, $isAttribute, $expected) /** * @return array */ - public function escapeXmlSpecialCharsProvider() + public function escapeXmlSpecialCharsProvider(): array { return [ ['\'"&<>', false, ''"&<>'], @@ -171,7 +171,7 @@ public function escapeXmlSpecialCharsProvider() * @param string $qtiName * @param string $expected */ - public function testWebComponentFriendlyAttributeName($qtiName, $expected) + public function testWebComponentFriendlyAttributeName($qtiName, $expected): void { $this::assertEquals($expected, Utils::webComponentFriendlyAttributeName($qtiName)); } @@ -179,7 +179,7 @@ public function testWebComponentFriendlyAttributeName($qtiName, $expected) /** * @return array */ - public function webComponentFriendlyAttributeNameProvider() + public function webComponentFriendlyAttributeNameProvider(): array { return [ ['minChoices', 'min-choices'], @@ -192,7 +192,7 @@ public function webComponentFriendlyAttributeNameProvider() * @param string $qtiName * @param string $expected */ - public function testWebComponentFriendlyClassName($qtiName, $expected) + public function testWebComponentFriendlyClassName($qtiName, $expected): void { $this::assertEquals($expected, Utils::webComponentFriendlyClassName($qtiName)); } @@ -200,7 +200,7 @@ public function testWebComponentFriendlyClassName($qtiName, $expected) /** * @return array */ - public function webComponentFriendlyClassNameProvider() + public function webComponentFriendlyClassNameProvider(): array { return [ ['choiceInteraction', 'qti-choice-interaction'], @@ -214,7 +214,7 @@ public function webComponentFriendlyClassNameProvider() * @param string $wcName * @param string $expected */ - public function testQtiFriendlyName($wcName, $expected) + public function testQtiFriendlyName($wcName, $expected): void { $this::assertEquals($expected, Utils::qtiFriendlyName($wcName)); } @@ -222,7 +222,7 @@ public function testQtiFriendlyName($wcName, $expected) /** * @return array */ - public function qtiFriendlyNameProvider() + public function qtiFriendlyNameProvider(): array { return [ ['qti-choice-interaction', 'choiceInteraction'], @@ -238,7 +238,7 @@ public function qtiFriendlyNameProvider() * @param string $datatype * @param mixed $expected */ - public function testGetDOMElementAttributeAs(DOMElement $element, $attribute, $datatype, $expected) + public function testGetDOMElementAttributeAs(DOMElement $element, $attribute, $datatype, $expected): void { $result = Utils::getDOMElementAttributeAs($element, $attribute, $datatype); $this::assertSame($expected, $result); @@ -247,7 +247,7 @@ public function testGetDOMElementAttributeAs(DOMElement $element, $attribute, $d /** * @return array */ - public function getDOMElementAttributeAsProvider() + public function getDOMElementAttributeAsProvider(): array { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -272,7 +272,7 @@ public function getDOMElementAttributeAsProvider() * @param string $value * @param mixed $expected */ - public function testSetDOMElementAttribute($attribute, $value, $expected) + public function testSetDOMElementAttribute($attribute, $value, $expected): void { $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->createElement('foo'); @@ -287,7 +287,7 @@ public function testSetDOMElementAttribute($attribute, $value, $expected) /** * @return array */ - public function setDOMElementAttributeProvider() + public function setDOMElementAttributeProvider(): array { return [ ['string', 'str&str', ''], @@ -299,7 +299,7 @@ public function setDOMElementAttributeProvider() ]; } - public function testGetChildElementsByTagName() + public function testGetChildElementsByTagName(): void { $dom = new DOMDocument('1.0', 'UTF-8'); @@ -311,7 +311,7 @@ public function testGetChildElementsByTagName() $this::assertCount(2, Utils::getChildElementsByTagName($element, 'child')); } - public function testGetChildElementsByTagNameMultiple() + public function testGetChildElementsByTagNameMultiple(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -320,7 +320,7 @@ public function testGetChildElementsByTagNameMultiple() $this::assertCount(3, Utils::getChildElementsByTagName($element, ['child', 'grandChild'])); } - public function testGetChildElementsByTagNameEmpty() + public function testGetChildElementsByTagNameEmpty(): void { $dom = new DOMDocument('1.0', 'UTF-8'); @@ -332,7 +332,7 @@ public function testGetChildElementsByTagNameEmpty() $this::assertCount(0, Utils::getChildElementsByTagName($element, 'child')); } - public function testFindCustomNamespaces() + public function testFindCustomNamespaces(): void { $xml = (' getElementsByTagName('baseValue')->length); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/AreaMapEntryMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AreaMapEntryMarshallerTest.php index 58249c08b..b6c954d14 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AreaMapEntryMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AreaMapEntryMarshallerTest.php @@ -15,7 +15,7 @@ */ class AreaMapEntryMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $mappedValue = 1.337; $shape = QtiShape::RECT; @@ -32,7 +32,7 @@ public function testMarshall() $this::assertEquals('1.337', $element->getAttribute('mappedValue')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -52,7 +52,7 @@ public function testUnmarshall() /** * @depends testUnmarshall */ - public function testUnmarshallNoMappedValue() + public function testUnmarshallNoMappedValue(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -69,7 +69,7 @@ public function testUnmarshallNoMappedValue() /** * @depends testUnmarshall */ - public function testUnmarshallWrongCoords() + public function testUnmarshallWrongCoords(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -86,7 +86,7 @@ public function testUnmarshallWrongCoords() /** * @depends testUnmarshall */ - public function testUnmarshallNoCoords() + public function testUnmarshallNoCoords(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -103,7 +103,7 @@ public function testUnmarshallNoCoords() /** * @depends testUnmarshall */ - public function testUnmarshallInvalidShape() + public function testUnmarshallInvalidShape(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -120,7 +120,7 @@ public function testUnmarshallInvalidShape() /** * @depends testUnmarshall */ - public function testUnmarshallNoShape() + public function testUnmarshallNoShape(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/AreaMappingMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AreaMappingMarshallerTest.php index 60fea6508..b6a465b7c 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AreaMappingMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AreaMappingMarshallerTest.php @@ -16,7 +16,7 @@ */ class AreaMappingMarshallerTest extends QtiSmTestCase { - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $defaultValue = 6.66; $areaMapEntries = new AreaMapEntryCollection(); @@ -35,7 +35,7 @@ public function testMarshallMinimal() $this::assertEquals('areaMapping', $element->nodeName); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/AssessmentItemMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AssessmentItemMarshallerTest.php index 8670a1799..6b514c806 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AssessmentItemMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AssessmentItemMarshallerTest.php @@ -19,7 +19,7 @@ */ class AssessmentItemMarshallerTest extends QtiSmTestCase { - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $identifier = 'Q01'; $timeDependent = false; @@ -50,7 +50,7 @@ public function testMarshallMinimal() $this::assertEquals($toolVersion, $element->getAttribute('toolVersion')); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -77,7 +77,7 @@ public function testUnmarshallMinimal() $this::assertEquals('0.6.0', $component->getToolVersion()); } - public function testMarshallMaximal() + public function testMarshallMaximal(): void { $identifier = 'Q01'; $title = 'Test Item'; @@ -123,7 +123,7 @@ public function testMarshallMaximal() $this::assertEquals('out2', $outcomeDeclarationElts->item(1)->getAttribute('identifier')); } - public function testUnmarshallMaximal() + public function testUnmarshallMaximal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -159,7 +159,7 @@ public function testUnmarshallMaximal() /** * @depends testUnmarshallMinimal */ - public function testUnmarshallDecorate() + public function testUnmarshallDecorate(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -179,7 +179,7 @@ public function testUnmarshallDecorate() /** * @testUnmarshallMinimal */ - public function testUnmarshallNoTitle() + public function testUnmarshallNoTitle(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -200,7 +200,7 @@ public function testUnmarshallNoTitle() /** * @testUnmarshallMinimal */ - public function testUnmarshallNoTimeDependent() + public function testUnmarshallNoTimeDependent(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -221,7 +221,7 @@ public function testUnmarshallNoTimeDependent() /** * @testUnmarshallMinimal */ - public function testUnmarshallNoIdentifier() + public function testUnmarshallNoIdentifier(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/AssessmentItemRefMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AssessmentItemRefMarshallerTest.php index c7db66fec..b6197f6fa 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AssessmentItemRefMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AssessmentItemRefMarshallerTest.php @@ -28,7 +28,7 @@ */ class AssessmentItemRefMarshallerTest extends QtiSmTestCase { - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $identifier = 'question1'; $href = '../../question1.xml'; @@ -43,7 +43,7 @@ public function testMarshallMinimal() $this::assertEquals($identifier, $element->getAttribute('identifier')); } - public function testMarshallMaximal() + public function testMarshallMaximal(): void { $identifier = 'question1'; $href = '../../question1.xml'; @@ -119,7 +119,7 @@ public function testMarshallMaximal() $this::assertEquals(1, $timeLimitsElts->length); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -135,7 +135,7 @@ public function testUnmarshallMinimal() $this::assertFalse($component->isRequired()); } - public function testUnmarshallMaximal() + public function testUnmarshallMaximal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/AssessmentResultMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AssessmentResultMarshallerTest.php index 860dec7fc..32fc7482a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AssessmentResultMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AssessmentResultMarshallerTest.php @@ -48,7 +48,7 @@ */ class AssessmentResultMarshallerTest extends QtiSmTestCase { - public function testValidMinimalXml() + public function testValidMinimalXml(): void { $xml = ' @@ -70,7 +70,7 @@ public function testValidMinimalXml() $this::assertNull($assessmentResult->getItemResults()); } - public function testUnmarshall() + public function testUnmarshall(): void { $xml = ' @@ -182,7 +182,7 @@ public function testUnmarshall() $this::assertInstanceOf(AssessmentResult::class, $assessmentResult); } - public function testUnmarshallWithoutTestResult() + public function testUnmarshallWithoutTestResult(): void { $xml = ' @@ -229,7 +229,7 @@ public function testUnmarshallWithoutTestResult() $this::assertInstanceOf(AssessmentResult::class, $assessmentResult); } - public function testMarshall() + public function testMarshall(): void { $component = new AssessmentResult( new Context( @@ -338,7 +338,7 @@ public function testMarshall() $this::assertEquals(2, $element->getElementsByTagName('itemResult')->length); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { $component = new AssessmentResult( new Context() diff --git a/test/qtismtest/data/storage/xml/marshalling/AssessmentSectionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AssessmentSectionMarshallerTest.php index 445616fe7..d58799e2d 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AssessmentSectionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AssessmentSectionMarshallerTest.php @@ -23,7 +23,7 @@ */ class AssessmentSectionMarshallerTest extends QtiSmTestCase { - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $identifier = 'myAssessmentSection'; $title = 'A Minimal Assessment Section'; @@ -43,7 +43,7 @@ public function testMarshallMinimal() $this::assertEquals(0, $element->getElementsByTagName('assessmentItemRef')->length); } - public function testMarshallNotRecursive() + public function testMarshallNotRecursive(): void { $identifier = 'myAssessmentSection'; $title = 'A non Recursive Assessment Section'; @@ -100,7 +100,7 @@ public function testMarshallNotRecursive() $this::assertEquals('S01', $element->getElementsByTagName('assessmentSectionRef')->item(0)->getAttribute('identifier')); } - public function testMarshallRecursive() + public function testMarshallRecursive(): void { // sub1 $identifier = 'sub1AssessmentSection'; @@ -172,7 +172,7 @@ public function testMarshallRecursive() $this::assertSame($sub2Elt, $sub22Elt->parentNode); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -192,7 +192,7 @@ public function testUnmarshallMinimal() $this::assertCount(0, $component->getSectionParts()); } - public function testUnmarshallNotRecursive() + public function testUnmarshallNotRecursive(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -254,7 +254,7 @@ public function testUnmarshallNotRecursive() /** * @depends testUnmarshallNotRecursive */ - public function testUnmarshallNotRecursiveZeroSelection() + public function testUnmarshallNotRecursiveZeroSelection(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -283,7 +283,7 @@ public function testUnmarshallNotRecursiveZeroSelection() $this::assertFalse($component->hasSelection()); } - public function testUnmarshallRecursive() + public function testUnmarshallRecursive(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -336,7 +336,7 @@ public function testUnmarshallRecursive() $this::assertEquals('S01', $subSectionParts['S01']->getIdentifier()); } - public function testUnmarshallOneSectionAssessmentItemRefOnly() + public function testUnmarshallOneSectionAssessmentItemRefOnly(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -359,7 +359,7 @@ public function testUnmarshallOneSectionAssessmentItemRefOnly() $this::assertCount(3, $assessmentItemRefs); } - public function testUnmarshallDecorated() + public function testUnmarshallDecorated(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -377,7 +377,7 @@ public function testUnmarshallDecorated() $this::assertFalse($decorated->isVisible()); } - public function testUnmarshallMissingVisibleAttribute() + public function testUnmarshallMissingVisibleAttribute(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -395,7 +395,7 @@ public function testUnmarshallMissingVisibleAttribute() $marshaller->unmarshall($element); } - public function testUnmarshallMissingTitleAttribute() + public function testUnmarshallMissingTitleAttribute(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/AssessmentSectionRefMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AssessmentSectionRefMarshallerTest.php index 2f6964949..5fd0c0da6 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AssessmentSectionRefMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AssessmentSectionRefMarshallerTest.php @@ -12,7 +12,7 @@ */ class AssessmentSectionRefMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $identifier = 'mySectionRef'; $href = 'http://www.rdfabout.com'; @@ -27,7 +27,7 @@ public function testMarshall() $this::assertEquals($href, $element->getAttribute('href')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/AssessmentTestMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AssessmentTestMarshallerTest.php index 385a9e6cb..4415d4910 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AssessmentTestMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AssessmentTestMarshallerTest.php @@ -29,7 +29,7 @@ */ class AssessmentTestMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $identifier = 'myAssessmentTest'; $title = 'My Assessment Test'; @@ -93,7 +93,7 @@ public function testMarshall() $this::assertSame($element, $element->getElementsByTagName('outcomeProcessing')->item(0)->parentNode); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/AssociableHotspotMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AssociableHotspotMarshallerTest.php index 3e79ca3b7..9fc211f0f 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AssociableHotspotMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AssociableHotspotMarshallerTest.php @@ -18,7 +18,7 @@ */ class AssociableHotspotMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $shape = QtiShape::RECT; $coords = new QtiCoords($shape, [92, 19, 261, 66]); @@ -42,7 +42,7 @@ public function testMarshall21() /** * @depends testMarshall21 */ - public function testMarshallNoOutputForDefaultMatchMinFixedShowHide21() + public function testMarshallNoOutputForDefaultMatchMinFixedShowHide21(): void { // Aims at testing that fixed, matchMin, showHide attributes are not // in the output if default values are set. @@ -61,7 +61,7 @@ public function testMarshallNoOutputForDefaultMatchMinFixedShowHide21() /** * @depends testMarshall21 */ - public function testMarshallNoOutputForMatchGroup21() + public function testMarshallNoOutputForMatchGroup21(): void { // Aims that testing that matchGroup is never in the output // in a QTI 2.1 context. @@ -79,7 +79,7 @@ public function testMarshallNoOutputForMatchGroup21() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' @@ -101,7 +101,7 @@ public function testUnmarshall21() $this::assertFalse($component->hasHotspotLabel()); } - public function testUnmarshall21NoMatchMax() + public function testUnmarshall21NoMatchMax(): void { $element = $this->createDOMElement(' @@ -113,7 +113,7 @@ public function testUnmarshall21NoMatchMax() $component = $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testMarshall20() + public function testMarshall20(): void { $shape = QtiShape::RECT; $coords = new QtiCoords($shape, [92, 19, 261, 66]); @@ -134,7 +134,7 @@ public function testMarshall20() /** * @depends testMarshall20 */ - public function testMarshallMatchGroup20() + public function testMarshallMatchGroup20(): void { $shape = QtiShape::RECT; $coords = new QtiCoords($shape, [92, 19, 261, 66]); @@ -155,7 +155,7 @@ public function testMarshallMatchGroup20() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshall20() + public function testUnmarshall20(): void { $element = $this->createDOMElement(' @@ -176,7 +176,7 @@ public function testUnmarshall20() /** * @depends testUnmarshall20 */ - public function testUnmarshallMatchMinNoInfluenceMatchMinTemplateIdentifierShowHide20() + public function testUnmarshallMatchMinNoInfluenceMatchMinTemplateIdentifierShowHide20(): void { // Aims at testing that matchMin, templateIdentifier and showHide attributes have no influence // in a QTI 2.0 context. @@ -195,7 +195,7 @@ public function testUnmarshallMatchMinNoInfluenceMatchMinTemplateIdentifierShowH /** * @depends testUnmarshall20 */ - public function testUnmarshallMatchGroup20() + public function testUnmarshallMatchGroup20(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/AssociateInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AssociateInteractionMarshallerTest.php index 4100880e2..7cebc2a27 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AssociateInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AssociateInteractionMarshallerTest.php @@ -17,7 +17,7 @@ */ class AssociateInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $choice1 = new SimpleAssociableChoice('choice_1', 1); $choice1->setContent(new FlowStaticCollection([new TextRun('Choice #1')])); @@ -45,7 +45,7 @@ public function testMarshall21() ); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' @@ -74,7 +74,7 @@ public function testUnmarshall21() $this::assertCount(2, $simpleChoices); } - public function testUnmarshall21NoResponseIdentifier() + public function testUnmarshall21NoResponseIdentifier(): void { $element = $this->createDOMElement(' @@ -92,7 +92,7 @@ public function testUnmarshall21NoResponseIdentifier() $marshaller->unmarshall($element); } - public function testMarshallSimple20() + public function testMarshallSimple20(): void { $choice1 = new SimpleAssociableChoice('choice_1', 1); $choice1->setContent(new FlowStaticCollection([new TextRun('Choice #1')])); @@ -116,7 +116,7 @@ public function testMarshallSimple20() /** * @depends testMarshallSimple20 */ - public function testMarshallMinAssociationAvoided20() + public function testMarshallMinAssociationAvoided20(): void { // Aims at testing that minAssociation is not in the output // in a QTI 2.0 context. @@ -134,7 +134,7 @@ public function testMarshallMinAssociationAvoided20() $this::assertEquals('Choice #1', $dom->saveXML($element)); } - public function testUnmarshall20() + public function testUnmarshall20(): void { $element = $this->createDOMElement(' @@ -156,7 +156,7 @@ public function testUnmarshall20() /** * @depends testUnmarshall20 */ - public function testUnmarshallAvoidMinAssociations20() + public function testUnmarshallAvoidMinAssociations20(): void { // Aims at testing that minAssociations has no influence // in a QTI 2.0 context. @@ -177,7 +177,7 @@ public function testUnmarshallAvoidMinAssociations20() /** * @depends testUnmarshall20 */ - public function testUnmarshallExceptionWhenNoMaxAssociations20() + public function testUnmarshallExceptionWhenNoMaxAssociations20(): void { // Aims at testing that minAssociations has no influence // in a QTI 2.0 context. @@ -197,7 +197,7 @@ public function testUnmarshallExceptionWhenNoMaxAssociations20() /** * @depends testUnmarshall20 */ - public function testUnmarshallExceptionWhenNoShuffle20() + public function testUnmarshallExceptionWhenNoShuffle20(): void { // Aims at testing that minAssociations has no influence // in a QTI 2.0 context. diff --git a/test/qtismtest/data/storage/xml/marshalling/AssociationValidityConstraintMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AssociationValidityConstraintMarshallerTest.php index 610bcdc95..480ed00b4 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AssociationValidityConstraintMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AssociationValidityConstraintMarshallerTest.php @@ -13,7 +13,7 @@ */ class AssociationValidityConstraintMarshallerTest extends QtiSmTestCase { - public function testUnmarshallSimple() + public function testUnmarshallSimple(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -27,7 +27,7 @@ public function testUnmarshallSimple() $this::assertEquals(1, $component->getMaxConstraint()); } - public function testUnmarshallNoIdentifier() + public function testUnmarshallNoIdentifier(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -39,7 +39,7 @@ public function testUnmarshallNoIdentifier() $component = $factory->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallNoMinConstraint() + public function testUnmarshallNoMinConstraint(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -51,7 +51,7 @@ public function testUnmarshallNoMinConstraint() $component = $factory->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallNoMaxConstraint() + public function testUnmarshallNoMaxConstraint(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -63,7 +63,7 @@ public function testUnmarshallNoMaxConstraint() $component = $factory->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallInvalidMaxConstraintOne() + public function testUnmarshallInvalidMaxConstraintOne(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -75,7 +75,7 @@ public function testUnmarshallInvalidMaxConstraintOne() $component = $factory->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallInvalidMaxConstraintTwo() + public function testUnmarshallInvalidMaxConstraintTwo(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -87,7 +87,7 @@ public function testUnmarshallInvalidMaxConstraintTwo() $component = $factory->createMarshaller($element)->unmarshall($element); } - public function testMarshallSimple() + public function testMarshallSimple(): void { $component = new AssociationValidityConstraint('IDENTIFIER', 0, 1); $factory = new Compact21MarshallerFactory(); diff --git a/test/qtismtest/data/storage/xml/marshalling/AtomicBlockMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/AtomicBlockMarshallerTest.php index 9e39edbb5..25966e448 100644 --- a/test/qtismtest/data/storage/xml/marshalling/AtomicBlockMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/AtomicBlockMarshallerTest.php @@ -17,7 +17,7 @@ */ class AtomicBlockMarshallerTest extends QtiSmTestCase { - public function testMarshallP() + public function testMarshallP(): void { $p = new P('my-p'); $em = new Em(); @@ -32,7 +32,7 @@ public function testMarshallP() $this::assertEquals('

This text is a simple test.

', $dom->saveXML($element)); } - public function testUnmarshallP() + public function testUnmarshallP(): void { $p = $this->createComponentFromXml('

@@ -54,7 +54,7 @@ public function testUnmarshallP() $this::assertEquals(" test.\n ", $content[2]->getContent()); } - public function testUnmarshallP30() + public function testUnmarshallP30(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(' @@ -86,7 +86,7 @@ public function testUnmarshallP30() $this::assertEquals('lessons once a week. Her house on Maple Dr. is a 2 kilometre walk to her teacher\'s house on Chestnut St.', trim($component->getContent()[4]->getContent())); } - public function testUnmarshallP30SsmlSub() + public function testUnmarshallP30SsmlSub(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(' @@ -133,7 +133,7 @@ public function testUnmarshallP30SsmlSub() $this::assertEquals('', trim($component->getContent()[9]->getContent())); } - public function testMarshallP30SsmlSub() + public function testMarshallP30SsmlSub(): void { $span1 = new Span(); $span1->setContent(new InlineCollection([new TextRun('Grace')])); diff --git a/test/qtismtest/data/storage/xml/marshalling/BaseValueMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/BaseValueMarshallerTest.php index 9b83dadc9..ae160c01f 100644 --- a/test/qtismtest/data/storage/xml/marshalling/BaseValueMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/BaseValueMarshallerTest.php @@ -13,7 +13,7 @@ */ class BaseValueMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $baseType = BaseType::FLOAT; $value = 27.11; @@ -28,7 +28,7 @@ public function testMarshall() $this::assertEquals($value . '', $element->nodeValue); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML('27.11'); @@ -43,7 +43,7 @@ public function testUnmarshall() $this::assertEquals(27.11, $component->getValue()); } - public function testUnmarshallCDATA() + public function testUnmarshallCDATA(): void { $element = $this->createDOMElement(''); $component = $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); diff --git a/test/qtismtest/data/storage/xml/marshalling/BlockquoteMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/BlockquoteMarshallerTest.php index 9bd8833bc..8d995831b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/BlockquoteMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/BlockquoteMarshallerTest.php @@ -17,7 +17,7 @@ */ class BlockquoteMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { $blockquote = $this->createComponentFromXml('

@@ -48,7 +48,7 @@ public function testUnmarshall() $this::assertEquals('An old Physicist.', $divContent[0]->getContent()); } - public function testMarshall() + public function testMarshall(): void { $div = new Div(); $div->setClass('description'); diff --git a/test/qtismtest/data/storage/xml/marshalling/BranchRuleMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/BranchRuleMarshallerTest.php index 44bf78b8d..face2c2b2 100644 --- a/test/qtismtest/data/storage/xml/marshalling/BranchRuleMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/BranchRuleMarshallerTest.php @@ -14,7 +14,7 @@ */ class BranchRuleMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $target = 'target1'; @@ -28,7 +28,7 @@ public function testMarshall() $this::assertEquals($target, $element->getAttribute('target')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/CandidateResponseMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/CandidateResponseMarshallerTest.php index c8b8f6a43..5d621fea1 100644 --- a/test/qtismtest/data/storage/xml/marshalling/CandidateResponseMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/CandidateResponseMarshallerTest.php @@ -34,7 +34,7 @@ */ class CandidateResponseMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { /** @var CandidateResponse $candidateResponse */ $candidateResponse = $this->createComponentFromXml(' @@ -51,7 +51,7 @@ public function testUnmarshall() $this::assertEquals(2, $candidateResponse->getValues()->count()); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { /** @var CandidateResponse $candidateResponse */ $candidateResponse = $this->createComponentFromXml(' @@ -64,7 +64,7 @@ public function testUnmarshallMinimal() $this::assertNull($candidateResponse->getValues()); } - public function testMarshall() + public function testMarshall(): void { $component = new CandidateResponse( new ValueCollection([ @@ -87,7 +87,7 @@ public function testMarshall() } } - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $component = new CandidateResponse(); @@ -101,7 +101,7 @@ public function testMarshallMinimal() $this::assertFalse($element->hasChildNodes()); } - public function testGetExpectedQtiClassName() + public function testGetExpectedQtiClassName(): void { $component = new CandidateResponse(); $marshaller = $this->getMarshallerFactory()->createMarshaller($component); diff --git a/test/qtismtest/data/storage/xml/marshalling/ChoiceInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ChoiceInteractionMarshallerTest.php index 395076a43..53ef81e4c 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ChoiceInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ChoiceInteractionMarshallerTest.php @@ -20,7 +20,7 @@ */ class ChoiceInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $choice1 = new SimpleChoice('choice_1'); $choice1->setContent(new FlowStaticCollection([new TextRun('Choice #1')])); @@ -42,7 +42,7 @@ public function testMarshall21() $this::assertEquals('Prompt...Choice #1Choice #2', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' @@ -75,7 +75,7 @@ public function testUnmarshall21() /** * @depends testUnmarshall21 */ - public function testUnmarshallNoResponseIdentifier21() + public function testUnmarshallNoResponseIdentifier21(): void { $element = $this->createDOMElement(' @@ -94,7 +94,7 @@ public function testUnmarshallNoResponseIdentifier21() /** * @depends testUnmarshall21 */ - public function testUnmarshallMaxChoicesUnlimited21() + public function testUnmarshallMaxChoicesUnlimited21(): void { $element = $this->createDOMElement(' @@ -115,7 +115,7 @@ public function testUnmarshallMaxChoicesUnlimited21() /** * @depends testUnmarshall21 */ - public function testUnmarshallMinChoicesOnly21() + public function testUnmarshallMinChoicesOnly21(): void { $element = $this->createDOMElement(' @@ -133,7 +133,7 @@ public function testUnmarshallMinChoicesOnly21() $this::assertSame(1, $component->getMinChoices()); } - public function testMarshallMinChoicesNoOutput20() + public function testMarshallMinChoicesNoOutput20(): void { // Aims at testing that minChoices is not output when QTI 2.0 is in force. $choice1 = new SimpleChoice('choice_1'); @@ -151,7 +151,7 @@ public function testMarshallMinChoicesNoOutput20() $this::assertEquals('Choice #1', $dom->saveXML($element)); } - public function testMarshallOrientationNoOutput20() + public function testMarshallOrientationNoOutput20(): void { // Aims at testing that orientation is not output in a QTI 2.0 context. $choice1 = new SimpleChoice('choice_1'); @@ -170,7 +170,7 @@ public function testMarshallOrientationNoOutput20() $this::assertEquals('Choice #1', $dom->saveXML($element)); } - public function testUnmarshallMinChoicesAvoided20() + public function testUnmarshallMinChoicesAvoided20(): void { // Aims at testing that minChoices is not taken into account when unmarshalling // in a QTI 2.0 context. @@ -190,7 +190,7 @@ public function testUnmarshallMinChoicesAvoided20() $this::assertSame(0, $component->getMinChoices()); } - public function testUnmarshallOrientationAvoided20() + public function testUnmarshallOrientationAvoided20(): void { // Aims at testing that orientation is not taken into account when unmarshalling // in a QTI 2.0 context. @@ -212,7 +212,7 @@ public function testUnmarshallOrientationAvoided20() $this::assertSame(Orientation::VERTICAL, $component->getOrientation()); } - public function testUnmarshallMandatoryShuffle20() + public function testUnmarshallMandatoryShuffle20(): void { // Aims at testing that shuffle attribute is mandatory in a QTI 2.0 context. // in a QTI 2.0 context. @@ -233,7 +233,7 @@ public function testUnmarshallMandatoryShuffle20() $marshaller->unmarshall($element); } - public function testUnmarshallNoMaxChoices() + public function testUnmarshallNoMaxChoices(): void { $element = $this->createDOMElement(' @@ -250,7 +250,7 @@ public function testUnmarshallNoMaxChoices() $this->getMarshallerFactory('2.0.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshall30() + public function testUnmarshall30(): void { $element = $this->createDOMElement(' @@ -288,7 +288,7 @@ public function testUnmarshall30() $this::assertCount(2, $simpleChoices); } - public function testMarshall30() + public function testMarshall30(): void { $choice1 = new SimpleChoice('choice_1'); $div1 = new Div('div_1'); diff --git a/test/qtismtest/data/storage/xml/marshalling/CompactMarshallerFactoryTest.php b/test/qtismtest/data/storage/xml/marshalling/CompactMarshallerFactoryTest.php index 0c70c81d4..7dcf0143e 100644 --- a/test/qtismtest/data/storage/xml/marshalling/CompactMarshallerFactoryTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/CompactMarshallerFactoryTest.php @@ -13,7 +13,7 @@ */ class CompactMarshallerFactoryTest extends QtiSmTestCase { - public function testInstantiation() + public function testInstantiation(): void { $factory = new Compact21MarshallerFactory(); $this::assertInstanceOf(Compact21MarshallerFactory::class, $factory); @@ -22,7 +22,7 @@ public function testInstantiation() $this::assertEquals(ExtendedAssessmentItemRefMarshaller::class, $factory->getMappingEntry('assessmentItemRef')); } - public function testFromDomElement() + public function testFromDomElement(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -33,7 +33,7 @@ public function testFromDomElement() $this::assertInstanceOf(ExtendedAssessmentItemRefMarshaller::class, $marshaller); } - public function testFromComponent() + public function testFromComponent(): void { $component = new ExtendedAssessmentItemRef('Q01', './q01.xml'); $this::assertTrue(true); diff --git a/test/qtismtest/data/storage/xml/marshalling/ContextMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ContextMarshallerTest.php index d7680c6bb..ccf67f77c 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ContextMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ContextMarshallerTest.php @@ -36,7 +36,7 @@ */ class ContextMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { /** @var Context $context */ $context = $this->createComponentFromXml(' @@ -58,7 +58,7 @@ public function testUnmarshall() $this::assertEquals(2, $context->getSessionIdentifiers()->count()); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { /** @var Context $context */ $context = $this->createComponentFromXml(' @@ -72,7 +72,7 @@ public function testUnmarshallMinimal() $this::assertFalse($context->hasSessionIdentifiers()); } - public function testMarshall() + public function testMarshall(): void { $sourcedId = 'fixture-sourcedId'; @@ -99,7 +99,7 @@ public function testMarshall() } } - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $component = new Context(); @@ -113,7 +113,7 @@ public function testMarshallMinimal() $this::assertFalse($element->hasChildNodes()); } - public function testGetExpectedQtiClassName() + public function testGetExpectedQtiClassName(): void { $component = new Context(); $marshaller = $this->getMarshallerFactory()->createMarshaller($component); diff --git a/test/qtismtest/data/storage/xml/marshalling/CorrectMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/CorrectMarshallerTest.php index 0e5a8e510..5ac50803b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/CorrectMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/CorrectMarshallerTest.php @@ -12,7 +12,7 @@ */ class CorrectMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $identifier = 'myCorrect1'; @@ -25,7 +25,7 @@ public function testMarshall() $this::assertEquals($identifier, $element->getAttribute('identifier')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/CorrectResponseMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/CorrectResponseMarshallerTest.php index 05c83e79d..f1365ff1d 100644 --- a/test/qtismtest/data/storage/xml/marshalling/CorrectResponseMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/CorrectResponseMarshallerTest.php @@ -17,7 +17,7 @@ */ class CorrectResponseMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $interpretation = 'It is up to you to interpret...'; $pair = new QtiPair('id1', 'id2'); @@ -39,7 +39,7 @@ public function testMarshall() $this::assertEquals('', $valueElement->getAttribute('baseType')); // no baseType attribute because not part of a record. } - public function testUnmarshallOne() + public function testUnmarshallOne(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -64,7 +64,7 @@ public function testUnmarshallOne() $this::assertFalse($values[0]->isPartOfRecord()); } - public function testUnmarshallTwo() + public function testUnmarshallTwo(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/CustomOperatorMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/CustomOperatorMarshallerTest.php index f6a2717a7..dee31148d 100644 --- a/test/qtismtest/data/storage/xml/marshalling/CustomOperatorMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/CustomOperatorMarshallerTest.php @@ -16,7 +16,7 @@ */ class CustomOperatorMarshallerTest extends QtiSmTestCase { - public function testMarshallNoLaxContent() + public function testMarshallNoLaxContent(): void { $int1 = new BaseValue(BaseType::INTEGER, 1); $int2 = new BaseValue(BaseType::INTEGER, 1); @@ -29,7 +29,7 @@ public function testMarshallNoLaxContent() $this::assertEquals('11', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement('11'); diff --git a/test/qtismtest/data/storage/xml/marshalling/DefaultValMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/DefaultValMarshallerTest.php index f9968293b..776f56196 100644 --- a/test/qtismtest/data/storage/xml/marshalling/DefaultValMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/DefaultValMarshallerTest.php @@ -12,7 +12,7 @@ */ class DefaultValMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $identifier = 'myDefault1'; @@ -25,7 +25,7 @@ public function testMarshall() $this::assertEquals($identifier, $element->getAttribute('identifier')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/DefaultValueMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/DefaultValueMarshallerTest.php index b0c08c4f0..880ae7a5b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/DefaultValueMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/DefaultValueMarshallerTest.php @@ -17,7 +17,7 @@ */ class DefaultValueMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $interpretation = 'It is up to you to interpret...'; $pair = new QtiPair('id1', 'id2'); @@ -39,7 +39,7 @@ public function testMarshall() $this::assertEquals('', $valueElement->getAttribute('baseType')); // no baseType attribute because not part of a record. } - public function testUnmarshallOne() + public function testUnmarshallOne(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -64,7 +64,7 @@ public function testUnmarshallOne() $this::assertFalse($values[0]->isPartOfRecord()); } - public function testUnmarshallTwo() + public function testUnmarshallTwo(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -92,7 +92,7 @@ public function testUnmarshallTwo() } } - public function testUnmarshallThree() + public function testUnmarshallThree(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/DivMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/DivMarshallerTest.php index f2536dc51..ec64b3376 100644 --- a/test/qtismtest/data/storage/xml/marshalling/DivMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/DivMarshallerTest.php @@ -20,7 +20,7 @@ */ class DivMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { $div = $this->createComponentFromXml('
@@ -115,7 +115,7 @@ public function testUnmarshall() $this::assertEquals('incredible', $strongContent[0]->getContent()); } - public function testMarshall() + public function testMarshall(): void { $li1 = new Li(); $li1->setContent(new FlowCollection([new TextRun('Start the Game')])); diff --git a/test/qtismtest/data/storage/xml/marshalling/DlMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/DlMarshallerTest.php index a5c2cd9c2..970b2abd6 100644 --- a/test/qtismtest/data/storage/xml/marshalling/DlMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/DlMarshallerTest.php @@ -17,7 +17,7 @@ */ class DlMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { $dl = $this->createComponentFromXml('
@@ -60,7 +60,7 @@ public function testUnmarshall() $this::assertEquals('Hot water with something.', $dd2Content[0]->getContent()); } - public function testMarshall() + public function testMarshall(): void { $dt1 = new Dt(); $dt1->setContent(new InlineCollection([new TextRun('Cola')])); diff --git a/test/qtismtest/data/storage/xml/marshalling/DrawingInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/DrawingInteractionMarshallerTest.php index 0113a85c5..092af360a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/DrawingInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/DrawingInteractionMarshallerTest.php @@ -16,7 +16,7 @@ */ class DrawingInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $object = new ObjectElement('my-canvas.png', 'image/png'); $drawingInteraction = new DrawingInteraction('RESPONSE', $object, 'my-drawings', 'draw-it'); @@ -32,7 +32,7 @@ public function testMarshall() $this::assertEquals('Prompt...', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' @@ -59,7 +59,7 @@ public function testUnmarshall() /** * @depends testUnmarshall */ - public function testUnmarshallNoObject() + public function testUnmarshallNoObject(): void { $element = $this->createDOMElement(' @@ -73,7 +73,7 @@ public function testUnmarshallNoObject() $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallMissingResponseIdentifier() + public function testUnmarshallMissingResponseIdentifier(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/EndAttemptInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/EndAttemptInteractionMarshallerTest.php index 538064d9a..cd0b456c1 100644 --- a/test/qtismtest/data/storage/xml/marshalling/EndAttemptInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/EndAttemptInteractionMarshallerTest.php @@ -12,7 +12,7 @@ */ class EndAttemptInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $endAttemptInteraction = new EndAttemptInteraction('BOOL_RESP', 'End the attempt now!', 'my-end', 'ending'); $endAttemptInteraction->setXmlBase('/home/jerome'); @@ -23,7 +23,7 @@ public function testMarshall() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' @@ -41,7 +41,7 @@ public function testUnmarshall() /** * @depends testUnmarshall */ - public function testUnmarshallNoTitle() + public function testUnmarshallNoTitle(): void { $element = $this->createDOMElement(' @@ -54,7 +54,7 @@ public function testUnmarshallNoTitle() /** * @depends testUnmarshall */ - public function testUnmarshallNoResponseIdentifier() + public function testUnmarshallNoResponseIdentifier(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/EqualMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/EqualMarshallerTest.php index d6ee58faf..d349abf5f 100644 --- a/test/qtismtest/data/storage/xml/marshalling/EqualMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/EqualMarshallerTest.php @@ -16,7 +16,7 @@ */ class EqualMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $subs = new ExpressionCollection(); $subs[] = new BaseValue(BaseType::INTEGER, 1); @@ -42,7 +42,7 @@ public function testMarshall() $this::assertEquals(2, $element->getElementsByTagName('baseValue')->length); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/EqualRoundedMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/EqualRoundedMarshallerTest.php index 5c675b96c..9bc64ab9a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/EqualRoundedMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/EqualRoundedMarshallerTest.php @@ -16,7 +16,7 @@ */ class EqualRoundedMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $subs = new ExpressionCollection(); $subs[] = new BaseValue(BaseType::FLOAT, 3.175); @@ -36,7 +36,7 @@ public function testMarshall() $this::assertEquals(2, $element->getElementsByTagName('baseValue')->length); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/ExitResponseMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ExitResponseMarshallerTest.php index afd24d76b..a60e28c65 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ExitResponseMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ExitResponseMarshallerTest.php @@ -12,7 +12,7 @@ */ class ExitResponseMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $component = new ExitResponse(); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component); @@ -22,7 +22,7 @@ public function testMarshall() $this::assertEquals('exitResponse', $element->nodeName); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/ExitTemplateMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ExitTemplateMarshallerTest.php index 5e877dd31..6e593472b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ExitTemplateMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ExitTemplateMarshallerTest.php @@ -11,7 +11,7 @@ */ class ExitTemplateMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $exitTemplate = new ExitTemplate(); $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($exitTemplate)->marshall($exitTemplate); @@ -21,7 +21,7 @@ public function testMarshall() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/ExitTestMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ExitTestMarshallerTest.php index 4bb614bea..f627c996d 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ExitTestMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ExitTestMarshallerTest.php @@ -12,7 +12,7 @@ */ class ExitTestMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $component = new ExitTest(); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component); @@ -22,7 +22,7 @@ public function testMarshall() $this::assertEquals('exitTest', $element->nodeName); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentItemRefMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentItemRefMarshallerTest.php index 533e11c33..23b6dc73d 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentItemRefMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentItemRefMarshallerTest.php @@ -36,7 +36,7 @@ */ class ExtendedAssessmentItemRefMarshallerTest extends QtiSmTestCase { - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $factory = new Compact21MarshallerFactory(); $component = new ExtendedAssessmentItemRef('Q01', './q01.xml'); @@ -52,7 +52,7 @@ public function testMarshallMinimal() $this::assertFalse($element->hasAttribute('label')); } - public function testMarshallMinimalWithTitle() + public function testMarshallMinimalWithTitle(): void { $factory = new Compact21MarshallerFactory(); $component = new ExtendedAssessmentItemRef('Q01', './q01.xml'); @@ -67,7 +67,7 @@ public function testMarshallMinimalWithTitle() $this::assertFalse($element->hasAttribute('label')); } - public function testMarshallMinimalWithLabel() + public function testMarshallMinimalWithLabel(): void { $factory = new Compact21MarshallerFactory(); $component = new ExtendedAssessmentItemRef('Q01', './q01.xml'); @@ -81,7 +81,7 @@ public function testMarshallMinimalWithLabel() $this::assertEquals('A label', $element->getAttribute('label')); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { $factory = new Compact21MarshallerFactory(); $dom = new DOMDocument('1.0', 'UTF-8'); @@ -102,7 +102,7 @@ public function testUnmarshallMinimal() $this::assertFalse($component->hasLabel()); } - public function testUnmarshallMinimalWithTitle() + public function testUnmarshallMinimalWithTitle(): void { $factory = new Compact21MarshallerFactory(); $dom = new DOMDocument('1.0', 'UTF-8'); @@ -116,7 +116,7 @@ public function testUnmarshallMinimalWithTitle() $this::assertEquals('A title', $component->getTitle()); } - public function testUnmarshallMinimalWithLabel() + public function testUnmarshallMinimalWithLabel(): void { $factory = new Compact21MarshallerFactory(); $dom = new DOMDocument('1.0', 'UTF-8'); @@ -133,7 +133,7 @@ public function testUnmarshallMinimalWithLabel() /** * @depends testMarshallMinimal */ - public function testMarshallModerate() + public function testMarshallModerate(): void { $factory = new Compact21MarshallerFactory(); $component = new ExtendedAssessmentItemRef('Q01', './q01.xml'); @@ -198,7 +198,7 @@ public function testMarshallModerate() /** * @depends testMarshallMinimal */ - public function testMarshallTemplateDeclarations() + public function testMarshallTemplateDeclarations(): void { $factory = new Compact21MarshallerFactory(); $component = new ExtendedAssessmentItemRef('Q01', './q01.xml'); @@ -223,7 +223,7 @@ public function testMarshallTemplateDeclarations() /** * @depends testUnmarshallMinimal */ - public function testUnmarshallModerate() + public function testUnmarshallModerate(): void { $factory = new Compact21MarshallerFactory(); $dom = new DOMDocument('1.0', 'UTF-8'); @@ -283,7 +283,7 @@ public function testUnmarshallModerate() /** * @depends testUnmarshallMinimal */ - public function testUnmarshallTemplateDeclarations() + public function testUnmarshallTemplateDeclarations(): void { $factory = new Compact21MarshallerFactory(); $dom = new DOMDocument('1.0', 'UTF-8'); @@ -302,7 +302,7 @@ public function testUnmarshallTemplateDeclarations() $this::assertEquals('T02', $templateDeclarations['T02']->getIdentifier()); } - public function testMarshallMultipleEndAttemptIdentifiers() + public function testMarshallMultipleEndAttemptIdentifiers(): void { $factory = new Compact21MarshallerFactory(); $component = new ExtendedAssessmentItemRef('Q01', './q01.xml'); @@ -317,7 +317,7 @@ public function testMarshallMultipleEndAttemptIdentifiers() $this::assertEquals('HINT1 HINT2 HINT3', $element->getAttribute('endAttemptIdentifiers')); } - public function testMarshallSingleEndAttemptIdentifiers() + public function testMarshallSingleEndAttemptIdentifiers(): void { $factory = new Compact21MarshallerFactory(); $component = new ExtendedAssessmentItemRef('Q01', './q01.xml'); @@ -332,7 +332,7 @@ public function testMarshallSingleEndAttemptIdentifiers() $this::assertEquals('HINT1', $element->getAttribute('endAttemptIdentifiers')); } - public function testMarshallNoEndAttemptIdentifiers() + public function testMarshallNoEndAttemptIdentifiers(): void { $factory = new Compact21MarshallerFactory(); $component = new ExtendedAssessmentItemRef('Q01', './q01.xml'); @@ -347,7 +347,7 @@ public function testMarshallNoEndAttemptIdentifiers() $this::assertEquals('', $element->getAttribute('endAttemptIdentifiers')); } - public function testUnmarshallMultipleEndAttemptIdentifiers() + public function testUnmarshallMultipleEndAttemptIdentifiers(): void { $factory = new Compact21MarshallerFactory(); $dom = new DOMDocument('1.0', 'UTF-8'); @@ -371,7 +371,7 @@ public function testUnmarshallMultipleEndAttemptIdentifiers() /** * @depends testUnmarshallMultipleEndAttemptIdentifiers */ - public function testUnmarshallSingleEndAttemptIdentifier() + public function testUnmarshallSingleEndAttemptIdentifier(): void { $factory = new Compact21MarshallerFactory(); $dom = new DOMDocument('1.0', 'UTF-8'); @@ -388,7 +388,7 @@ public function testUnmarshallSingleEndAttemptIdentifier() /** * @depends testUnmarshallMultipleEndAttemptIdentifiers */ - public function testUnmarshallNoEndAttemptIdentifier() + public function testUnmarshallNoEndAttemptIdentifier(): void { $factory = new Compact21MarshallerFactory(); $dom = new DOMDocument('1.0', 'UTF-8'); @@ -404,7 +404,7 @@ public function testUnmarshallNoEndAttemptIdentifier() /** * @depends testMarshallMinimal */ - public function testMarshallShufflingGroups() + public function testMarshallShufflingGroups(): void { $factory = new Compact21MarshallerFactory(); $component = new ExtendedAssessmentItemRef('Q01', './q01.xml'); @@ -436,7 +436,7 @@ public function testMarshallShufflingGroups() /** * @depends testUnmarshallMinimal */ - public function testUnmarshallShufflingGroups() + public function testUnmarshallShufflingGroups(): void { $factory = new Compact21MarshallerFactory(); $dom = new DOMDocument('1.0', 'UTF-8'); @@ -465,7 +465,7 @@ public function testUnmarshallShufflingGroups() /** * @depends testMarshallMinimal */ - public function testMarshallResponseValidityConstraints() + public function testMarshallResponseValidityConstraints(): void { $factory = new Compact21MarshallerFactory(); $component = new ExtendedAssessmentItemRef('Q01', './q01.xml'); @@ -502,7 +502,7 @@ public function testMarshallResponseValidityConstraints() /** * @depends testUnmarshallMinimal */ - public function testUnmarshallResponseValidityConstraints() + public function testUnmarshallResponseValidityConstraints(): void { $factory = new Compact21MarshallerFactory(); $dom = new DOMDocument('1.0', 'UTF-8'); diff --git a/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentSectionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentSectionMarshallerTest.php index 014c8f686..4a97b45b8 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentSectionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentSectionMarshallerTest.php @@ -15,7 +15,7 @@ */ class ExtendedAssessmentSectionMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { $elt = $this->createDOMElement(' @@ -48,7 +48,7 @@ public function testUnmarshall() $this::assertCount(0, $section->getRubricBlocks()); } - public function testMarshall() + public function testMarshall(): void { $section = new ExtendedAssessmentSection('S01', 'Section 01', true); $section->setSectionParts(new SectionPartCollection([new AssessmentSectionRef('SR01', './SR01.xml')])); diff --git a/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentTestMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentTestMarshallerTest.php index b7d8e3db4..d9d92f97b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentTestMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ExtendedAssessmentTestMarshallerTest.php @@ -41,7 +41,7 @@ */ class ExtendedAssessmentTestMarshallerTest extends QtiSmTestCase { - public function testMarshallMaximal() + public function testMarshallMaximal(): void { $assessmentSection1 = new ExtendedAssessmentSection('section1', 'My Section 1', true); $assessmentSection2 = new ExtendedAssessmentSection('section2', 'My Section 2', true); @@ -117,7 +117,7 @@ public function testMarshallMaximal() ); } - public function testUnmarshallMaximal() + public function testUnmarshallMaximal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/ExtendedTestPartMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ExtendedTestPartMarshallerTest.php index 67019c3fd..5b2dda34e 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ExtendedTestPartMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ExtendedTestPartMarshallerTest.php @@ -33,7 +33,7 @@ */ class ExtendedTestPartMarshallerTest extends QtiSmTestCase { - public function testMarshallMaximal() + public function testMarshallMaximal(): void { $assessmentSection1 = new ExtendedAssessmentSection('section1', 'My Section 1', true); $assessmentSection2 = new ExtendedAssessmentSection('section2', 'My Section 2', true); @@ -80,7 +80,7 @@ public function testMarshallMaximal() ); } - public function testUnmarshallMaximal() + public function testUnmarshallMaximal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/ExtendedTextInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ExtendedTextInteractionMarshallerTest.php index 889168d5f..2ddda0125 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ExtendedTextInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ExtendedTextInteractionMarshallerTest.php @@ -12,7 +12,7 @@ */ class ExtendedTextInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshallMinimal21() + public function testMarshallMinimal21(): void { $extendedTextInteraction = new ExtendedTextInteraction('RESPONSE'); $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($extendedTextInteraction)->marshall($extendedTextInteraction); @@ -22,7 +22,7 @@ public function testMarshallMinimal21() $this::assertEquals('', $dom->saveXML($element)); } - public function testMarshallMaximal21() + public function testMarshallMaximal21(): void { $extendedTextInteraction = new ExtendedTextInteraction('RESPONSE'); $extendedTextInteraction->setBase(2); @@ -41,7 +41,7 @@ public function testMarshallMaximal21() $this::assertEquals('', $dom->saveXML($element)); } - public function testMarshallNoOutputMinStringsFormat20() + public function testMarshallNoOutputMinStringsFormat20(): void { // Make sure minStrings and format attributes are never // in the output in a QTI 2.0 context. @@ -55,7 +55,7 @@ public function testMarshallNoOutputMinStringsFormat20() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshallMinimal21() + public function testUnmarshallMinimal21(): void { $element = $this->createDOMElement(''); $extendedTextInteraction = $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); @@ -69,7 +69,7 @@ public function testUnmarshallMinimal21() $this::assertFalse($extendedTextInteraction->hasPlaceholderText()); } - public function testUnmarshallMaximal21() + public function testUnmarshallMaximal21(): void { $element = $this->createDOMElement(''); $extendedTextInteraction = $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); @@ -92,7 +92,7 @@ public function testUnmarshallMaximal21() $this::assertEquals(TextFormat::PRE_FORMATTED, $extendedTextInteraction->getFormat()); } - public function testUnmarshallNoInfluenceMinStringsFormat20() + public function testUnmarshallNoInfluenceMinStringsFormat20(): void { // Make sure minStrings and format have no influcence // in a QTI 2.0 context. diff --git a/test/qtismtest/data/storage/xml/marshalling/FeedbackBlockMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/FeedbackBlockMarshallerTest.php index 7e29d6f00..7f9ca3fa5 100644 --- a/test/qtismtest/data/storage/xml/marshalling/FeedbackBlockMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/FeedbackBlockMarshallerTest.php @@ -16,7 +16,7 @@ */ class FeedbackBlockMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $div = new Div(); $div->setContent(new FlowCollection([new TextRun('This is text...')])); @@ -35,7 +35,7 @@ public function testMarshall() /** * @depends testMarshall */ - public function testMarshallXmlBase() + public function testMarshallXmlBase(): void { $div = new Div(); $div->setContent(new FlowCollection([new TextRun('This is text...')])); @@ -52,7 +52,7 @@ public function testMarshallXmlBase() $this::assertEquals('
This is text...
', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement('
This is text...
@@ -77,7 +77,7 @@ public function testUnmarshall() /** * @depends testUnmarshall */ - public function testUnmarshallInvalidShowHide() + public function testUnmarshallInvalidShowHide(): void { $element = $this->createDOMElement('
This is text...
@@ -92,7 +92,7 @@ public function testUnmarshallInvalidShowHide() /** * @depends testUnmarshall */ - public function testUnmarshallInvalidContent1() + public function testUnmarshallInvalidContent1(): void { $element = $this->createDOMElement(' @@ -107,7 +107,7 @@ public function testUnmarshallInvalidContent1() /** * @depends testUnmarshall */ - public function testUnmarshallInvalidContent2() + public function testUnmarshallInvalidContent2(): void { $element = $this->createDOMElement(' @@ -122,7 +122,7 @@ public function testUnmarshallInvalidContent2() /** * @depends testUnmarshall */ - public function testUnmarshallXmlBase() + public function testUnmarshallXmlBase(): void { $element = $this->createDOMElement('
This is text...
@@ -135,7 +135,7 @@ public function testUnmarshallXmlBase() /** * @depends testUnmarshall */ - public function testUnmarshallNoIdentifier() + public function testUnmarshallNoIdentifier(): void { $element = $this->createDOMElement('
This is text...
@@ -150,7 +150,7 @@ public function testUnmarshallNoIdentifier() /** * @depends testUnmarshall */ - public function testUnmarshallNoOutcomeIdentifier() + public function testUnmarshallNoOutcomeIdentifier(): void { $element = $this->createDOMElement('
This is text...
diff --git a/test/qtismtest/data/storage/xml/marshalling/FeedbackInlineMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/FeedbackInlineMarshallerTest.php index c60cfcf50..82ec40411 100644 --- a/test/qtismtest/data/storage/xml/marshalling/FeedbackInlineMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/FeedbackInlineMarshallerTest.php @@ -14,7 +14,7 @@ */ class FeedbackInlineMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $content = new InlineCollection([new TextRun('This is text...')]); $feedback = new FeedbackInline('outcome1', 'please_hide_me', ShowHide::HIDE, 'my-feedback', 'super feedback'); @@ -27,7 +27,7 @@ public function testMarshall() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/FieldValueMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/FieldValueMarshallerTest.php index 9665e4655..f6481ef8f 100644 --- a/test/qtismtest/data/storage/xml/marshalling/FieldValueMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/FieldValueMarshallerTest.php @@ -14,7 +14,7 @@ */ class FieldValueMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $fieldIdentifier = 'myField'; @@ -30,7 +30,7 @@ public function testMarshall() $this::assertEquals('recordVar', $sub1->getAttribute('identifier')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/GapImgMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/GapImgMarshallerTest.php index d76329848..eec38d32e 100644 --- a/test/qtismtest/data/storage/xml/marshalling/GapImgMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/GapImgMarshallerTest.php @@ -15,7 +15,7 @@ */ class GapImgMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $object = new ObjectElement('http://imagine.us/myimg.png', 'image/png'); $gapImg = new GapImg('gapImg1', 1, $object, 'my-gap', 'gaps'); @@ -37,7 +37,7 @@ public function testMarshall21() /** * @depends testMarshall21 */ - public function testMarshallNoMatchGroup21() + public function testMarshallNoMatchGroup21(): void { // Aims am testing that matchGroup attribute is ignore in // a QTI 2.1 context. @@ -56,7 +56,7 @@ public function testMarshallNoMatchGroup21() /* * @depends testMarshall21 */ - public function testMarshallFixed() + public function testMarshallFixed(): void { $object = new ObjectElement('http://imagine.us/myimg.png', 'image/png'); $gapImg = new GapImg('gapImg1', 0, $object); @@ -71,7 +71,7 @@ public function testMarshallFixed() /* * @depends testMarshall21 */ - public function testMarshallObjectLabel() + public function testMarshallObjectLabel(): void { $object = new ObjectElement('http://imagine.us/myimg.png', 'image/png'); $gapImg = new GapImg('gapImg1', 0, $object); @@ -83,7 +83,7 @@ public function testMarshallObjectLabel() $this::assertEquals('My Label', $element->getAttribute('objectLabel')); } - public function testMarshall20() + public function testMarshall20(): void { $object = new ObjectElement('http://imagine.us/myimg.png', 'image/png'); $gapImg = new GapImg('gapImg1', 2, $object); @@ -103,7 +103,7 @@ public function testMarshall20() /** * @depends testMarshall20 */ - public function testMarshallTemplateIdentifier20() + public function testMarshallTemplateIdentifier20(): void { $object = new ObjectElement('http://imagine.us/myimg.png', 'image/png'); $gapImg = new GapImg('gapImg1', 2, $object); @@ -115,7 +115,7 @@ public function testMarshallTemplateIdentifier20() $this::assertFalse($element->hasAttribute('templateIdentifier')); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' @@ -144,7 +144,7 @@ public function testUnmarshall21() /** * @depends testUnmarshall21 */ - public function testUnmarshallNoMatchGroup21() + public function testUnmarshallNoMatchGroup21(): void { $element = $this->createDOMElement(' @@ -157,7 +157,7 @@ public function testUnmarshallNoMatchGroup21() $this::assertCount(0, $gapImg->getMatchGroup()); } - public function testUnmarshall20() + public function testUnmarshall20(): void { $element = $this->createDOMElement(' @@ -186,7 +186,7 @@ public function testUnmarshall20() /** * @depends testUnmarshall21 */ - public function testUnmarshalMultipleObjects() + public function testUnmarshalMultipleObjects(): void { $element = $this->createDOMElement(' @@ -206,7 +206,7 @@ public function testUnmarshalMultipleObjects() /** * @depends testUnmarshall21 */ - public function testUnmarshalFixed() + public function testUnmarshalFixed(): void { $element = $this->createDOMElement(' @@ -223,7 +223,7 @@ public function testUnmarshalFixed() /** * @depends testUnmarshall21 */ - public function testUnmarshallMissingMatchMax() + public function testUnmarshallMissingMatchMax(): void { $element = $this->createDOMElement(' @@ -242,7 +242,7 @@ public function testUnmarshallMissingMatchMax() /** * @depends testUnmarshall21 */ - public function testUnmarshallMissingIdentifier() + public function testUnmarshallMissingIdentifier(): void { $element = $this->createDOMElement(' @@ -258,7 +258,7 @@ public function testUnmarshallMissingIdentifier() $gapImg = $marshaller->unmarshall($element); } - public function testUnmarshallMatchMin20() + public function testUnmarshallMatchMin20(): void { $element = $this->createDOMElement(' @@ -273,7 +273,7 @@ public function testUnmarshallMatchMin20() $this::assertEquals(0, $gapImg->getMatchMin()); } - public function testUnmarshallTemplateIdentifier20() + public function testUnmarshallTemplateIdentifier20(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/GapMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/GapMarshallerTest.php index 9d4d3d08e..181a72fab 100644 --- a/test/qtismtest/data/storage/xml/marshalling/GapMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/GapMarshallerTest.php @@ -13,7 +13,7 @@ */ class GapMarshallerTest extends QtiSmTestCase { - public function testMarshall20() + public function testMarshall20(): void { $gap = new Gap('gap1', true, 'my-gap', 'gaps'); $gap->setFixed(true); @@ -29,7 +29,7 @@ public function testMarshall20() /** * @depends testMarshall20 */ - public function testMarshallNoTemplateIdentifierShowHideRequiredNoOutput20() + public function testMarshallNoTemplateIdentifierShowHideRequiredNoOutput20(): void { $gap = new Gap('gap1'); $gap->setTemplateIdentifier('XTEMPLATE'); @@ -47,7 +47,7 @@ public function testMarshallNoTemplateIdentifierShowHideRequiredNoOutput20() /** * @depends testMarshall20 */ - public function testMarshallMatchGroup20() + public function testMarshallMatchGroup20(): void { $gap = new Gap('gap1'); $gap->setMatchGroup(new IdentifierCollection(['identifier1', 'identifier2'])); @@ -60,7 +60,7 @@ public function testMarshallMatchGroup20() $this::assertEquals('', $dom->saveXML($element)); } - public function testMarshall21() + public function testMarshall21(): void { $gap = new Gap('gap1', true, 'my-gap', 'gaps'); $gap->setFixed(false); @@ -81,7 +81,7 @@ public function testMarshall21() /** * @depends testMarshall21 */ - public function testMarshallNoMatchGroup21() + public function testMarshallNoMatchGroup21(): void { // Aims at testing that no matchGroup attribute is in // the output in a QTI 2.1 context. @@ -96,7 +96,7 @@ public function testMarshallNoMatchGroup21() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' @@ -117,7 +117,7 @@ public function testUnmarshall21() /** * @depends testUnmarshall21 */ - public function testUnmarshallMatchGroupNoInfluence21() + public function testUnmarshallMatchGroupNoInfluence21(): void { // Aims at testing that no matchGroup is in output in a QTI 2.1 context. $element = $this->createDOMElement(' @@ -129,7 +129,7 @@ public function testUnmarshallMatchGroupNoInfluence21() $this::assertSame(0, count($gap->getMatchGroup())); } - public function testUnmarshall20() + public function testUnmarshall20(): void { $element = $this->createDOMElement(' @@ -152,7 +152,7 @@ public function testUnmarshall20() /** * @depends testUnmarshall20 */ - public function testUnmarshallNoNoInfluenceRequiredTemplateIdentifierShowHide20() + public function testUnmarshallNoNoInfluenceRequiredTemplateIdentifierShowHide20(): void { // Aims at testing that required, templateIdentifier, showHide // attributes are not in output in a QTI 2.0 context. diff --git a/test/qtismtest/data/storage/xml/marshalling/GapMatchInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/GapMatchInteractionMarshallerTest.php index bc78501bd..027ff0d5e 100644 --- a/test/qtismtest/data/storage/xml/marshalling/GapMatchInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/GapMatchInteractionMarshallerTest.php @@ -22,7 +22,7 @@ */ class GapMatchInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $gapText = new GapText('gapText1', 1); $gapText->setContent(new TextOrVariableCollection([new TextRun('This is gapText1')])); @@ -50,7 +50,7 @@ public function testMarshall() ); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' This is gapText1

A text... and an image...

@@ -75,7 +75,7 @@ public function testUnmarshall() $this::assertEquals('G2', $gaps[1]->getIdentifier()); } - public function testUnmarshallNoGapChoice() + public function testUnmarshallNoGapChoice(): void { $element = $this->createDOMElement('

A text... and an image...

@@ -89,7 +89,7 @@ public function testUnmarshallNoGapChoice() $marshaller->unmarshall($element); } - public function testUnmarshallNoResponseIdentifier() + public function testUnmarshallNoResponseIdentifier(): void { $element = $this->createDOMElement(' This is gapText1

A text... and an image...

diff --git a/test/qtismtest/data/storage/xml/marshalling/GapTextMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/GapTextMarshallerTest.php index 70d861ddb..fd5668a0e 100644 --- a/test/qtismtest/data/storage/xml/marshalling/GapTextMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/GapTextMarshallerTest.php @@ -17,7 +17,7 @@ */ class GapTextMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $gapText = new GapText('gapText1', 1); $gapText->setContent(new TextOrVariableCollection([new TextRun('My var is '), new PrintedVariable('var1')])); @@ -33,7 +33,7 @@ public function testMarshall21() $this::assertEquals('My var is ', $dom->saveXML($element)); } - public function testMarshall20() + public function testMarshall20(): void { $gapText = new GapText('gapText1', 3); @@ -56,7 +56,7 @@ public function testMarshall20() $this::assertEquals('Some text...', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' My var is @@ -81,7 +81,7 @@ public function testUnmarshall21() $this::assertEquals('var1', $content[1]->getIdentifier()); } - public function testUnmarshall20() + public function testUnmarshall20(): void { $element = $this->createDOMElement(' Some text... @@ -103,7 +103,7 @@ public function testUnmarshall20() /** * @depends testUnmarshall20 */ - public function testUnmarshall20NotOnlyTextContent() + public function testUnmarshall20NotOnlyTextContent(): void { // Aims at testing that an error is thrown when trying // to unmarshall a gapText containing other stuff than plain/text @@ -119,7 +119,7 @@ public function testUnmarshall20NotOnlyTextContent() $gapText = $marshaller->unmarshall($element); } - public function testUnmarshallInvalid21() + public function testUnmarshallInvalid21(): void { // Only textRun and/or printedVariable. $this->expectException(UnmarshallingException::class); diff --git a/test/qtismtest/data/storage/xml/marshalling/GraphicAssociateInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/GraphicAssociateInteractionMarshallerTest.php index eaa3a201a..1870e77d1 100644 --- a/test/qtismtest/data/storage/xml/marshalling/GraphicAssociateInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/GraphicAssociateInteractionMarshallerTest.php @@ -20,7 +20,7 @@ */ class GraphicAssociateInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection([new TextRun('Prompt...')])); @@ -52,7 +52,7 @@ public function testMarshall21() /** * @depends testMarshall21 */ - public function testMarshall21XmlBase() + public function testMarshall21XmlBase(): void { $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection([new TextRun('Prompt...')])); @@ -85,7 +85,7 @@ public function testMarshall21XmlBase() /** * @depends testMarshall21 */ - public function testMarshall20() + public function testMarshall20(): void { // Make sure that maxAssociations is always in the output but never minAssociations. $object = new ObjectElement('myimg.png', 'image/png'); @@ -111,7 +111,7 @@ public function testMarshall20() ); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' @@ -160,7 +160,7 @@ public function testUnmarshall21() $this::assertTrue($choices[2]->getCoords()->equals(new QtiCoords(QtiShape::CIRCLE, [4, 4, 15]))); } - public function testUnmarshall21NoAssociableHotspot() + public function testUnmarshall21NoAssociableHotspot(): void { $element = $this->createDOMElement(' @@ -175,7 +175,7 @@ public function testUnmarshall21NoAssociableHotspot() $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshall21InvalidContentIgnored() + public function testUnmarshall21InvalidContentIgnored(): void { $element = $this->createDOMElement(' @@ -193,7 +193,7 @@ public function testUnmarshall21InvalidContentIgnored() $this::assertCount(2, $choices); } - public function testUnmarshall20() + public function testUnmarshall20(): void { // Make sure minAssociations is not taken into account // in a QTI 2.0 context. @@ -215,7 +215,7 @@ public function testUnmarshall20() /** * @depends testUnmarshall20 */ - public function testUnmarshall20NoMaxAssociations() + public function testUnmarshall20NoMaxAssociations(): void { $element = $this->createDOMElement(' @@ -235,7 +235,7 @@ public function testUnmarshall20NoMaxAssociations() /** * @depends testUnmarshall20 */ - public function testUnmarshall20NoAssociableHotspot() + public function testUnmarshall20NoAssociableHotspot(): void { // Make sure minAssociations is not taken into account // in a QTI 2.0 context. @@ -254,7 +254,7 @@ public function testUnmarshall20NoAssociableHotspot() /** * @depends testUnmarshall20 */ - public function testUnmarshall20NoObject() + public function testUnmarshall20NoObject(): void { $element = $this->createDOMElement(' @@ -273,7 +273,7 @@ public function testUnmarshall20NoObject() /** * @depends testUnmarshall20 */ - public function testUnmarshall20XmlBase() + public function testUnmarshall20XmlBase(): void { // Make sure minAssociations is not taken into account // in a QTI 2.0 context. @@ -293,7 +293,7 @@ public function testUnmarshall20XmlBase() /** * @depends testUnmarshall20 */ - public function testUnmarshall20NoResponseIdentifier() + public function testUnmarshall20NoResponseIdentifier(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/GraphicGapMatchInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/GraphicGapMatchInteractionMarshallerTest.php index 73c4c7157..151897e97 100644 --- a/test/qtismtest/data/storage/xml/marshalling/GraphicGapMatchInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/GraphicGapMatchInteractionMarshallerTest.php @@ -22,7 +22,7 @@ */ class GraphicGapMatchInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection([new TextRun('Prompt...')])); @@ -57,7 +57,7 @@ public function testMarshall() ); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' Prompt... @@ -93,7 +93,7 @@ public function testUnmarshall() /** * @depends testUnmarshall */ - public function testUnmarshallNoGapImgs() + public function testUnmarshallNoGapImgs(): void { $element = $this->createDOMElement(' Prompt... @@ -108,7 +108,7 @@ public function testUnmarshallNoGapImgs() /** * @depends testUnmarshall */ - public function testUnmarshallNoObject() + public function testUnmarshallNoObject(): void { $element = $this->createDOMElement(' Prompt... @@ -123,7 +123,7 @@ public function testUnmarshallNoObject() /** * @depends testUnmarshall */ - public function testUnmarshallNoAssociableHotspots() + public function testUnmarshallNoAssociableHotspots(): void { $element = $this->createDOMElement(' Prompt... @@ -138,7 +138,7 @@ public function testUnmarshallNoAssociableHotspots() /** * @depends testUnmarshall */ - public function testUnmarshallNoResponseIdentifier() + public function testUnmarshallNoResponseIdentifier(): void { $element = $this->createDOMElement(' Prompt... diff --git a/test/qtismtest/data/storage/xml/marshalling/GraphicOrderInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/GraphicOrderInteractionMarshallerTest.php index d995f2204..9ee1ed393 100644 --- a/test/qtismtest/data/storage/xml/marshalling/GraphicOrderInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/GraphicOrderInteractionMarshallerTest.php @@ -20,7 +20,7 @@ */ class GraphicOrderInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection([new TextRun('Prompt...')])); @@ -51,7 +51,7 @@ public function testMarshall21() /** * @depends testMarshall21 */ - public function testMarshall20() + public function testMarshall20(): void { // make sure minChoices and maxChoices attributes // are not in the output in a QTI 2.0 context. @@ -76,7 +76,7 @@ public function testMarshall20() ); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' @@ -111,7 +111,7 @@ public function testUnmarshall21() $this::assertEquals('choice3', $choices[2]->getIdentifier()); } - public function testUnmarshall21SomethingElseThanHotspotChoice() + public function testUnmarshall21SomethingElseThanHotspotChoice(): void { $element = $this->createDOMElement(' @@ -129,7 +129,7 @@ public function testUnmarshall21SomethingElseThanHotspotChoice() $this::assertTrue(true); } - public function testUnmarshall21NoHotspotChoice() + public function testUnmarshall21NoHotspotChoice(): void { $element = $this->createDOMElement(' @@ -144,7 +144,7 @@ public function testUnmarshall21NoHotspotChoice() $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshall21NoObject() + public function testUnmarshall21NoObject(): void { $element = $this->createDOMElement(' @@ -160,7 +160,7 @@ public function testUnmarshall21NoObject() $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshall21NoResponseIdentifier() + public function testUnmarshall21NoResponseIdentifier(): void { $element = $this->createDOMElement(' @@ -181,7 +181,7 @@ public function testUnmarshall21NoResponseIdentifier() /** * @depends testUnmarshall21 */ - public function testUnmarshall21MinChoicesIs0() + public function testUnmarshall21MinChoicesIs0(): void { // graphicOrderInteraction->minChoices = 0 is an endless debate: // The Information models says: If specfied, minChoices must be 1 or greater but ... @@ -211,7 +211,7 @@ public function testUnmarshall21MinChoicesIs0() /** * @depends testUnmarshall21 */ - public function testUnmarshall20() + public function testUnmarshall20(): void { // Make sure minChoices and maxChoices attributes are not taken into account in a QTI 2.0 context. $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/HotspotChoiceMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/HotspotChoiceMarshallerTest.php index fc4130381..3126d7a2d 100644 --- a/test/qtismtest/data/storage/xml/marshalling/HotspotChoiceMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/HotspotChoiceMarshallerTest.php @@ -17,7 +17,7 @@ */ class HotspotChoiceMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $shape = QtiShape::CIRCLE; $coords = new QtiCoords($shape, [0, 0, 5]); @@ -35,7 +35,7 @@ public function testMarshall() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' @@ -61,7 +61,7 @@ public function testUnmarshall() /** * @depends testUnmarshall */ - public function testUnmarshallFloatCoords() + public function testUnmarshallFloatCoords(): void { // Example taken from a TAO migration issue. Coordinates contain "string-float" values. $element = $this->createDOMElement(' @@ -79,7 +79,7 @@ public function testUnmarshallFloatCoords() /** * @depends testUnmarshall */ - public function testUnmarshallUnknownShape() + public function testUnmarshallUnknownShape(): void { $element = $this->createDOMElement(' @@ -94,7 +94,7 @@ public function testUnmarshallUnknownShape() /** * @depends testUnmarshall */ - public function testUnmarshallCoordsDoNotSatisfyShape() + public function testUnmarshallCoordsDoNotSatisfyShape(): void { $element = $this->createDOMElement(' @@ -109,7 +109,7 @@ public function testUnmarshallCoordsDoNotSatisfyShape() /** * @depends testUnmarshall */ - public function testUnmarshallWrongShowHideValue() + public function testUnmarshallWrongShowHideValue(): void { $element = $this->createDOMElement(' @@ -124,7 +124,7 @@ public function testUnmarshallWrongShowHideValue() /** * @depends testUnmarshall */ - public function testUnmarshallMissingCoords() + public function testUnmarshallMissingCoords(): void { $element = $this->createDOMElement(' @@ -139,7 +139,7 @@ public function testUnmarshallMissingCoords() /** * @depends testUnmarshall */ - public function testUnmarshallMissingShape() + public function testUnmarshallMissingShape(): void { $element = $this->createDOMElement(' @@ -154,7 +154,7 @@ public function testUnmarshallMissingShape() /** * @depends testUnmarshall */ - public function testUnmarshallMissingIdentifier() + public function testUnmarshallMissingIdentifier(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/HotspotInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/HotspotInteractionMarshallerTest.php index e669609db..a2c47ab06 100644 --- a/test/qtismtest/data/storage/xml/marshalling/HotspotInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/HotspotInteractionMarshallerTest.php @@ -20,7 +20,7 @@ */ class HotspotInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection([new TextRun('Prompt...')])); @@ -46,7 +46,7 @@ public function testMarshall21() ); } - public function testMarshall21XmlBase() + public function testMarshall21XmlBase(): void { $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection([new TextRun('Prompt...')])); @@ -76,7 +76,7 @@ public function testMarshall21XmlBase() /** * @depends testMarshall21 */ - public function testMarshall20() + public function testMarshall20(): void { // minChoices must be ignored. $choice1 = new HotspotChoice('hotspotchoice1', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, [77, 115, 8])); @@ -94,7 +94,7 @@ public function testMarshall20() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' Prompt... @@ -125,7 +125,7 @@ public function testUnmarshall21() /** * @depends testUnmarshall21 */ - public function testUnmarshall21XmlBase() + public function testUnmarshall21XmlBase(): void { $element = $this->createDOMElement(' Prompt... @@ -139,7 +139,7 @@ public function testUnmarshall21XmlBase() /** * @depends testUnmarshall21 */ - public function testUnmarshall21InvalidContentIgnored() + public function testUnmarshall21InvalidContentIgnored(): void { $element = $this->createDOMElement(' Prompt... @@ -152,7 +152,7 @@ public function testUnmarshall21InvalidContentIgnored() /** * @depends testUnmarshall21 */ - public function testUnmarshall21NoChoices() + public function testUnmarshall21NoChoices(): void { $element = $this->createDOMElement(' Prompt... @@ -167,7 +167,7 @@ public function testUnmarshall21NoChoices() /** * @depends testUnmarshall21 */ - public function testUnmarshall21NoObject() + public function testUnmarshall21NoObject(): void { $element = $this->createDOMElement(' Prompt... @@ -182,7 +182,7 @@ public function testUnmarshall21NoObject() /** * @depends testUnmarshall21 */ - public function testUnmarshall21NoResponseIdentifier() + public function testUnmarshall21NoResponseIdentifier(): void { $element = $this->createDOMElement(' Prompt... @@ -194,7 +194,7 @@ public function testUnmarshall21NoResponseIdentifier() $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshall20MissingMaxChoices() + public function testUnmarshall20MissingMaxChoices(): void { $element = $this->createDOMElement(' Prompt... diff --git a/test/qtismtest/data/storage/xml/marshalling/HottextInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/HottextInteractionMarshallerTest.php index 7a1e854af..c300e278e 100644 --- a/test/qtismtest/data/storage/xml/marshalling/HottextInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/HottextInteractionMarshallerTest.php @@ -20,7 +20,7 @@ */ class HottextInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $hottext = new Hottext('hottext1'); $hottext->setContent(new InlineStaticCollection([new TextRun('hot')])); @@ -55,7 +55,7 @@ public function testMarshall21() /** * @depends testMarshall21 */ - public function testMarshallNoOutputMinStrings20() + public function testMarshallNoOutputMinStrings20(): void { // Make sure no output for minStrings in a QTI 2.0 context. $hottext = new Hottext('hottext1'); @@ -74,7 +74,7 @@ public function testMarshallNoOutputMinStrings20() $this::assertEquals('
This is a text...
', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' @@ -109,7 +109,7 @@ public function testUnmarshall21() $this::assertEquals(' text...', $divContent[2]->getContent()); } - public function testUnmarshall21InvalidContent() + public function testUnmarshall21InvalidContent(): void { $element = $this->createDOMElement(' @@ -126,7 +126,7 @@ public function testUnmarshall21InvalidContent() $component = $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshall21InvalidResponseIdentifier() + public function testUnmarshall21InvalidResponseIdentifier(): void { $element = $this->createDOMElement(' @@ -144,7 +144,7 @@ public function testUnmarshall21InvalidResponseIdentifier() /** * @depends testUnmarshall21 */ - public function testNoInfluenceMinStrings20() + public function testNoInfluenceMinStrings20(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/HottextMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/HottextMarshallerTest.php index 7b299636d..244769237 100644 --- a/test/qtismtest/data/storage/xml/marshalling/HottextMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/HottextMarshallerTest.php @@ -14,7 +14,7 @@ */ class HottextMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $hottext = new Hottext('choice1', 'my-hottext1', 'so hot'); $hottext->setFixed(true); @@ -29,7 +29,7 @@ public function testMarshall() $this::assertEquals('Choice1', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' Choice1 diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php index 3753b093b..3133e25c5 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php @@ -6,7 +6,6 @@ use DOMElement; use qtism\data\content\enums\Role; use qtism\data\content\xhtml\html5\Html5Element; -use qtism\data\QtiComponent; use qtism\data\QtiComponentCollection; use qtism\data\storage\xml\marshalling\Html5ElementMarshaller; use qtism\data\storage\xml\marshalling\Marshaller; @@ -240,17 +239,18 @@ public function __call($method, $args) /** * @param DOMElement $element - * @return QtiComponent + * @return FakeHtml5Element * @throws UnmarshallingException */ - protected function unmarshall(DOMElement $element) + protected function unmarshall(DOMElement $element): FakeHtml5Element { $component = new FakeHtml5Element(); $this->fillBodyElement($component, $element); return $component; } - public function getExpectedQtiClassName() + public function getExpectedQtiClassName(): string { + return ''; } } diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5FigcaptionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5FigcaptionMarshallerTest.php index 7ea7dac01..4aac64a77 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Html5FigcaptionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Html5FigcaptionMarshallerTest.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtismtest\data\storage\xml\marshalling; use qtism\data\content\InlineCollection; diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5FigureMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5FigureMarshallerTest.php index dd5f87032..669750911 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Html5FigureMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Html5FigureMarshallerTest.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtismtest\data\storage\xml\marshalling; use qtism\data\content\FlowCollection; diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5RbMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5RbMarshallerTest.php index 0e3ee0d7f..f572f515e 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Html5RbMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Html5RbMarshallerTest.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtismtest\data\storage\xml\marshalling; use qtism\data\content\InlineCollection; @@ -30,7 +28,7 @@ class Html5RbMarshallerTest extends Html5ElementMarshallerTest { - const SUBJECT_QTI_CLASS_NAME = 'rb'; + private const SUBJECT_QTI_CLASS_NAME = 'rb'; /** * @throws MarshallerNotFoundException diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5RpMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5RpMarshallerTest.php index 26c02fed1..96df28925 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Html5RpMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Html5RpMarshallerTest.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtismtest\data\storage\xml\marshalling; use qtism\data\content\InlineCollection; @@ -30,7 +28,7 @@ class Html5RpMarshallerTest extends Html5ElementMarshallerTest { - const SUBJECT_QTI_CLASS_NAME = 'rp'; + private const SUBJECT_QTI_CLASS_NAME = 'rp'; /** * @throws MarshallerNotFoundException diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5RtMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5RtMarshallerTest.php index d3c1f16d2..ca71029e8 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Html5RtMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Html5RtMarshallerTest.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtismtest\data\storage\xml\marshalling; use qtism\data\content\InlineCollection; @@ -30,7 +28,7 @@ class Html5RtMarshallerTest extends Html5ElementMarshallerTest { - const SUBJECT_QTI_CLASS_NAME = 'rt'; + private const SUBJECT_QTI_CLASS_NAME = 'rt'; /** * @throws MarshallerNotFoundException diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php index fe344cbf3..93d11ee17 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php @@ -18,8 +18,6 @@ * Copyright (c) 2022 (original work) Open Assessment Technologies SA; */ -declare(strict_types=1); - namespace qtismtest\data\storage\xml\marshalling; use qtism\data\content\FlowCollection; @@ -34,7 +32,7 @@ class Html5RubyMarshallerTest extends Html5ElementMarshallerTest { - const SUBJECT_QTI_CLASS_NAME = 'ruby'; + private const SUBJECT_QTI_CLASS_NAME = 'ruby'; /** * @throws MarshallerNotFoundException diff --git a/test/qtismtest/data/storage/xml/marshalling/ImgMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ImgMarshallerTest.php index 3923f7e23..6f3f73677 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ImgMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ImgMarshallerTest.php @@ -33,7 +33,7 @@ */ class ImgMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $img = new Img('my/image.png', 'An Image...', 'my-img'); $img->setClass('beautiful'); @@ -54,7 +54,7 @@ public function testMarshall21() $this::assertEquals('An Image...', $dom->saveXML($element)); } - public function testMarshall22() + public function testMarshall22(): void { $img = new Img('my/image.png', 'An Image...', 'my-img'); @@ -80,7 +80,7 @@ public function testMarshall22() $this::assertEquals('An Image...', $dom->saveXML($element)); } - public function testMarshall223() + public function testMarshall223(): void { $img = new Img('my/image.png', 'An Image...', 'my-img'); @@ -106,7 +106,7 @@ public function testMarshall223() $this::assertEquals('An Image...', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' @@ -134,7 +134,7 @@ public function testUnmarshall21() $this::assertFalse($img->hasAriaHidden()); } - public function testUnmarshall22() + public function testUnmarshall22(): void { $element = $this->createDOMElement(' @@ -152,7 +152,7 @@ public function testUnmarshall22() $this::assertTrue($img->getAriaHidden()); } - public function testUnmarshall22PreferFlowsTo() + public function testUnmarshall22PreferFlowsTo(): void { $element = $this->createDOMElement(' An Image... @@ -167,7 +167,7 @@ public function testUnmarshall22PreferFlowsTo() $this::assertEquals('IDREF2', $img->getAriaFlowTo()); } - public function testUnmarshall22FallbackFlowTo() + public function testUnmarshall22FallbackFlowTo(): void { $element = $this->createDOMElement(' An Image... @@ -186,7 +186,7 @@ public function testUnmarshall22FallbackFlowTo() /** * @depends testUnmarshall21 */ - public function testUnmarshallPercentage() + public function testUnmarshallPercentage(): void { $element = $this->createDOMElement(' An Image... @@ -202,7 +202,7 @@ public function testUnmarshallPercentage() /** * @depends testUnmarshall21 */ - public function testUnmarshallMissingSrc() + public function testUnmarshallMissingSrc(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/IndexMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/IndexMarshallerTest.php index 411f744e1..679e0fa9a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/IndexMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/IndexMarshallerTest.php @@ -14,7 +14,7 @@ */ class IndexMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $component = new Index(new ExpressionCollection([new Variable('orderedVar')]), 3); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component); @@ -28,7 +28,7 @@ public function testMarshall() $this::assertEquals('orderedVar', $sub1->getAttribute('identifier')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/InfoControlMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/InfoControlMarshallerTest.php index c33468f1d..b938c165b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/InfoControlMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/InfoControlMarshallerTest.php @@ -16,7 +16,7 @@ */ class InfoControlMarshallerTest extends QtiSmTestCase { - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $component = new InfoControl(); $component->setXmlBase('/home/jerome'); @@ -32,7 +32,7 @@ public function testMarshallMinimal() $this::assertEquals('/home/jerome', $element->getAttribute('xml:base')); } - public function testMarshallMinimalWithAttributes() + public function testMarshallMinimalWithAttributes(): void { $component = new InfoControl('myControl', 'myInfo elt', 'en-US', 'A label...'); $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($component)->marshall($component); @@ -45,7 +45,7 @@ public function testMarshallMinimalWithAttributes() $this::assertEquals('A label...', $element->getAttribute('label')); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { $element = $this->createDOMElement(''); $component = $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); @@ -58,7 +58,7 @@ public function testUnmarshallMinimal() $this::assertFalse($component->hasLabel()); } - public function testUnmarshallMinimalWithAttributes() + public function testUnmarshallMinimalWithAttributes(): void { $element = $this->createDOMElement(''); $component = $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); @@ -71,7 +71,7 @@ public function testUnmarshallMinimalWithAttributes() $this::assertEquals('A label...', $component->getLabel()); } - public function testUnmarshallComplex() + public function testUnmarshallComplex(): void { $element = $this->createDOMElement(' @@ -98,7 +98,7 @@ public function testUnmarshallComplex() $this::assertEquals(' !', rtrim($content[2]->getContent())); } - public function testMarshallComplex() + public function testMarshallComplex(): void { $component = new InfoControl('controlMePlease'); $component->setId('controlMePlease'); diff --git a/test/qtismtest/data/storage/xml/marshalling/InlineChoiceInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/InlineChoiceInteractionMarshallerTest.php index b70c39ef8..77097f088 100644 --- a/test/qtismtest/data/storage/xml/marshalling/InlineChoiceInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/InlineChoiceInteractionMarshallerTest.php @@ -16,7 +16,7 @@ */ class InlineChoiceInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $inlineChoices = new InlineChoiceCollection(); @@ -48,7 +48,7 @@ public function testMarshall21() ); } - public function testMarshall20() + public function testMarshall20(): void { // check that suffled systematically out and no required attribute. $inlineChoices = new InlineChoiceCollection(); @@ -69,7 +69,7 @@ public function testMarshall20() $this::assertEquals('Option1', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' @@ -91,7 +91,7 @@ public function testUnmarshall21() /** * @depends testUnmarshall21 */ - public function testUnmarshall21NoInlineChoices() + public function testUnmarshall21NoInlineChoices(): void { $element = $this->createDOMElement(' @@ -107,7 +107,7 @@ public function testUnmarshall21NoInlineChoices() /** * @depends testUnmarshall21 */ - public function testUnmarshall21InvalidResponseIdentifier() + public function testUnmarshall21InvalidResponseIdentifier(): void { $element = $this->createDOMElement(' @@ -126,7 +126,7 @@ public function testUnmarshall21InvalidResponseIdentifier() /** * @depends testUnmarshall21 */ - public function testUnmarshall21NoResponseIdentifier() + public function testUnmarshall21NoResponseIdentifier(): void { $element = $this->createDOMElement(' @@ -142,7 +142,7 @@ public function testUnmarshall21NoResponseIdentifier() $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshall20() + public function testUnmarshall20(): void { // Check required is not taken into account. // Check shuffle is always in the output. @@ -165,7 +165,7 @@ public function testUnmarshall20() /** * @depends testUnmarshall20 */ - public function testUnmarshallErrorIfoShuffle20() + public function testUnmarshallErrorIfoShuffle20(): void { $expectedMsg = "The mandatory 'shuffle' attribute is missing from the 'inlineChoiceInteraction' element."; $this->expectException(UnmarshallingException::class); diff --git a/test/qtismtest/data/storage/xml/marshalling/InlineChoiceMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/InlineChoiceMarshallerTest.php index efef40c53..33a3601c5 100644 --- a/test/qtismtest/data/storage/xml/marshalling/InlineChoiceMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/InlineChoiceMarshallerTest.php @@ -16,7 +16,7 @@ */ class InlineChoiceMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $choice = new InlineChoice('choice1', 'my-choice1'); $choice->setContent(new TextOrVariableCollection([new TextRun('var: '), new PrintedVariable('pr1')])); @@ -31,7 +31,7 @@ public function testMarshall21() $this::assertEquals('var: ', $dom->saveXML($element)); } - public function testMarshall20() + public function testMarshall20(): void { $choice = new InlineChoice('choice1'); $choice->setContent(new TextOrVariableCollection([new TextRun('var: '), new PrintedVariable('pr1')])); @@ -47,7 +47,7 @@ public function testMarshall20() $this::assertEquals('var: ', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(''); $component = $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); @@ -64,7 +64,7 @@ public function testUnmarshall21() $this::assertInstanceOf(PrintedVariable::class, $content[0]); } - public function testUnmarshall20() + public function testUnmarshall20(): void { // Make sure no values for templateIdentifier and showHide are // retrieved in a QTI 2.0 context. @@ -87,7 +87,7 @@ public function testUnmarshall20() /** * @depends testUnmarshall20 */ - public function testUnmarshallErrorIfPrintedVariable20() + public function testUnmarshallErrorIfPrintedVariable20(): void { $expectedMsg = "An 'inlineChoice' element must only contain text. Children elements found."; $this->expectException(UnmarshallingException::class); diff --git a/test/qtismtest/data/storage/xml/marshalling/InsideMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/InsideMarshallerTest.php index 79f562cd5..761e0f0c6 100644 --- a/test/qtismtest/data/storage/xml/marshalling/InsideMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/InsideMarshallerTest.php @@ -16,7 +16,7 @@ */ class InsideMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $subs = new ExpressionCollection(); $subs[] = new Variable('pointVariable'); @@ -35,7 +35,7 @@ public function testMarshall() $this::assertEquals(1, $element->getElementsByTagName('variable')->length); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/InterpolationTableEntryMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/InterpolationTableEntryMarshallerTest.php index ad7ff22dc..918e659d8 100644 --- a/test/qtismtest/data/storage/xml/marshalling/InterpolationTableEntryMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/InterpolationTableEntryMarshallerTest.php @@ -13,7 +13,7 @@ */ class InterpolationTableEntryMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $sourceValue = 23.445; $baseType = BaseType::INTEGER; // fake baseType of a container variableDeclaration element. @@ -31,7 +31,7 @@ public function testMarshall() $this::assertEquals('true', $element->getAttribute('includeBoundary')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/InterpolationTableMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/InterpolationTableMarshallerTest.php index d1430451e..b26d62f22 100644 --- a/test/qtismtest/data/storage/xml/marshalling/InterpolationTableMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/InterpolationTableMarshallerTest.php @@ -17,7 +17,7 @@ */ class InterpolationTableMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $baseType = BaseType::BOOLEAN; $entries = new InterpolationTableEntryCollection(); // Simulate that the variableDeclaration baseType is boolean. @@ -47,7 +47,7 @@ public function testMarshall() $this::assertEquals(2.0, $element->getAttribute('defaultValue')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -79,7 +79,7 @@ public function testUnmarshall() $this::assertTrue($entry->doesIncludeBoundary()); } - public function testUnmarshallNonFloatDefaultValue() + public function testUnmarshallNonFloatDefaultValue(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -101,7 +101,7 @@ public function testUnmarshallNonFloatDefaultValue() $marshaller->unmarshall($element); } - public function testUnmarshallNoInterpolationTableEntries() + public function testUnmarshallNoInterpolationTableEntries(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -120,7 +120,7 @@ public function testUnmarshallNoInterpolationTableEntries() $marshaller->unmarshall($element); } - public function testInvalidBaseType() + public function testInvalidBaseType(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/ItemBodyMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ItemBodyMarshallerTest.php index c1767b954..3b3f3cf97 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ItemBodyMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ItemBodyMarshallerTest.php @@ -17,7 +17,7 @@ */ class ItemBodyMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { $itemBody = $this->createComponentFromXml(' @@ -44,7 +44,7 @@ public function testUnmarshall() $this::assertEquals('This is some stimulus.', $divContent[0]->getContent()); } - public function testMarshall() + public function testMarshall(): void { $h1 = new H1(); $h1->setContent(new InlineCollection([new TextRun('Super Item')])); diff --git a/test/qtismtest/data/storage/xml/marshalling/ItemResultMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ItemResultMarshallerTest.php index e165da36d..8d7aa0834 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ItemResultMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ItemResultMarshallerTest.php @@ -41,7 +41,7 @@ */ class ItemResultMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { /** @var ItemResult $itemResult */ $itemResult = $this->createComponentFromXml(' @@ -77,7 +77,7 @@ public function testUnmarshall() $this::assertEquals(2, $itemResult->getItemVariables()->count()); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { /** @var ItemResult $itemResult */ $itemResult = $this->createComponentFromXml(' @@ -101,7 +101,7 @@ public function testUnmarshallMinimal() $this::assertNull($itemResult->getItemVariables()); } - public function testMarshall() + public function testMarshall(): void { $component = new ItemResult( new QtiIdentifier('fixture-identifier'), @@ -140,7 +140,7 @@ public function testMarshall() $this::assertEquals(1, $element->getElementsByTagName('templateVariable')->length); } - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $component = new ItemResult( new QtiIdentifier('fixture-identifier'), @@ -164,7 +164,7 @@ public function testMarshallMinimal() $this::assertFalse($element->hasChildNodes()); } - public function testGetExpectedQtiClassName() + public function testGetExpectedQtiClassName(): void { $component = new ItemResult( new QtiIdentifier('fixture-identifier'), diff --git a/test/qtismtest/data/storage/xml/marshalling/ItemSessionControlMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ItemSessionControlMarshallerTest.php index 4630be055..e16408782 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ItemSessionControlMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ItemSessionControlMarshallerTest.php @@ -12,7 +12,7 @@ */ class ItemSessionControlMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $component = new ItemSessionControl(); $component->setAllowComment(true); @@ -32,7 +32,7 @@ public function testMarshall() $this::assertEquals('true', $element->getAttribute('allowSkipping')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/ItemSubsetMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ItemSubsetMarshallerTest.php index 4ce9fc7b7..0563a6420 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ItemSubsetMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ItemSubsetMarshallerTest.php @@ -13,7 +13,7 @@ */ class ItemSubsetMarshallerTest extends QtiSmTestCase { - public function testMarshallNoCategories() + public function testMarshallNoCategories(): void { $sectionIdentifier = 'mySection1'; @@ -27,7 +27,7 @@ public function testMarshallNoCategories() $this::assertEquals($sectionIdentifier, $element->getAttribute('sectionIdentifier')); } - public function testMarshallIncludeCategories() + public function testMarshallIncludeCategories(): void { $sectionIdentifier = 'mySection1'; $includeCategories = new IdentifierCollection(['cat1', 'cat2']); @@ -44,7 +44,7 @@ public function testMarshallIncludeCategories() $this::assertEquals(implode("\x20", $includeCategories->getArrayCopy()), $element->getAttribute('includeCategory')); } - public function testMarshallIncludeExcludeCategories() + public function testMarshallIncludeExcludeCategories(): void { $sectionIdentifier = 'mySection1'; $includeCategories = new IdentifierCollection(['cat1', 'cat2']); @@ -64,7 +64,7 @@ public function testMarshallIncludeExcludeCategories() $this::assertEquals(implode("\x20", $excludeCategories->getArrayCopy()), $element->getAttribute('excludeCategory')); } - public function testUnmarshallNoCategories() + public function testUnmarshallNoCategories(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -77,7 +77,7 @@ public function testUnmarshallNoCategories() $this::assertEquals('mySection1', $component->getSectionIdentifier()); } - public function testUnmarshallIncludeCategories() + public function testUnmarshallIncludeCategories(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -91,7 +91,7 @@ public function testUnmarshallIncludeCategories() $this::assertEquals('cat1 cat2', implode("\x20", $component->getIncludeCategories()->getArrayCopy())); } - public function testUnmarshallIncludeExcludeCategories() + public function testUnmarshallIncludeExcludeCategories(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/ListMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ListMarshallerTest.php index 2ff8471d7..3ead4292d 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ListMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ListMarshallerTest.php @@ -20,7 +20,7 @@ */ class ListMarshallerTest extends QtiSmTestCase { - public function testUnmarshallUl() + public function testUnmarshallUl(): void { $ul = $this->createComponentFromXml('
    @@ -80,7 +80,7 @@ public function testUnmarshallUl() $this::assertInstanceOf(P::class, $liContent[3]); } - public function testMarshallUl() + public function testMarshallUl(): void { $strong = new Strong(); $strong->setContent(new InlineCollection([new TextRun('text')])); diff --git a/test/qtismtest/data/storage/xml/marshalling/LookupOutcomeValueMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/LookupOutcomeValueMarshallerTest.php index f5e6542a4..f32a310de 100644 --- a/test/qtismtest/data/storage/xml/marshalling/LookupOutcomeValueMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/LookupOutcomeValueMarshallerTest.php @@ -14,7 +14,7 @@ */ class LookupOutcomeValueMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $component = new LookupOutcomeValue('myVariable1', new BaseValue(BaseType::STRING, 'a value')); @@ -29,7 +29,7 @@ public function testMarshall() $this::assertEquals('string', $element->getElementsByTagName('baseValue')->item(0)->getAttribute('baseType')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/MapEntryMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MapEntryMarshallerTest.php index bcdee6344..0c7b443c9 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MapEntryMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MapEntryMarshallerTest.php @@ -14,7 +14,7 @@ */ class MapEntryMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $component = new MapEntry(1337, 1.377, true); @@ -28,7 +28,7 @@ public function testMarshall21() $this::assertEquals('true', $element->getAttribute('caseSensitive')); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -46,7 +46,7 @@ public function testUnmarshall21() $this::assertTrue($component->isCaseSensitive()); } - public function testUnmarshall21EmptyMapKeyForString() + public function testUnmarshall21EmptyMapKeyForString(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -60,7 +60,7 @@ public function testUnmarshall21EmptyMapKeyForString() $this::assertEquals(-1.0, $component->getMappedValue()); } - public function testUnmarshall21EmptyMapKeyForInteger() + public function testUnmarshall21EmptyMapKeyForInteger(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -73,7 +73,7 @@ public function testUnmarshall21EmptyMapKeyForInteger() $component = $marshaller->unmarshall($element); } - public function testUnmarshall21EmptyMapKeyForIdentifier() + public function testUnmarshall21EmptyMapKeyForIdentifier(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -86,7 +86,7 @@ public function testUnmarshall21EmptyMapKeyForIdentifier() $marshaller->unmarshall($element); } - public function testMarshall20() + public function testMarshall20(): void { // No caseSensitive attribute in QTI 2.0. Check that no caseSensitive attribute goes out. $component = new MapEntry(1337, 1.377, true); @@ -103,7 +103,7 @@ public function testMarshall20() $this::assertSame('', $element->getAttribute('caseSensitive')); } - public function testUnmarshall20() + public function testUnmarshall20(): void { // Make sure the caseSensitive attribute is not taken into account. $dom = new DOMDocument('1.0', 'UTF-8'); diff --git a/test/qtismtest/data/storage/xml/marshalling/MapResponseMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MapResponseMarshallerTest.php index fc0c8e778..839a8ce35 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MapResponseMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MapResponseMarshallerTest.php @@ -12,7 +12,7 @@ */ class MapResponseMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $identifier = 'myMapResponse1'; @@ -25,7 +25,7 @@ public function testMarshall() $this::assertEquals($identifier, $element->getAttribute('identifier')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/MapResponsePointMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MapResponsePointMarshallerTest.php index 6ca191f29..119b98845 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MapResponsePointMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MapResponsePointMarshallerTest.php @@ -12,7 +12,7 @@ */ class MapResponsePointMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $identifier = 'myMapResponsePoint1'; @@ -25,7 +25,7 @@ public function testMarshall() $this::assertEquals($identifier, $element->getAttribute('identifier')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/MappingMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MappingMarshallerTest.php index 97750feb8..4d3ab09b6 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MappingMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MappingMarshallerTest.php @@ -15,7 +15,7 @@ */ class MappingMarshallerTest extends QtiSmTestCase { - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $defaultValue = 6.66; $mapEntries = new MapEntryCollection(); @@ -40,7 +40,7 @@ public function testMarshallMinimal() $this::assertEquals('false', $mapEntryElt->getAttribute('caseSensitive')); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/MarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MarshallerTest.php index 1c029f5e5..f87354c2c 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MarshallerTest.php @@ -7,7 +7,6 @@ use qtism\common\enums\BaseType; use qtism\data\expressions\BaseValue; use qtism\data\ItemSessionControl; -use qtism\data\QtiComponent; use qtism\data\storage\xml\marshalling\ItemSessionControlMarshaller; use qtism\data\storage\xml\marshalling\Marshaller; use qtismtest\QtiSmTestCase; @@ -20,7 +19,7 @@ */ class MarshallerTest extends QtiSmTestCase { - public function testCradle() + public function testCradle(): void { // Set cradle method accessible $class = new ReflectionClass(Marshaller::class); @@ -30,14 +29,14 @@ public function testCradle() $this::assertInstanceOf(DOMDocument::class, $method->invoke(null)); } - public function testGetMarshaller() + public function testGetMarshaller(): void { $component = new ItemSessionControl(); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component); $this::assertInstanceOf(ItemSessionControlMarshaller::class, $marshaller); } - public function testGetUnmarshaller() + public function testGetUnmarshaller(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -45,7 +44,7 @@ public function testGetUnmarshaller() $this::assertInstanceOf(ItemSessionControlMarshaller::class, $marshaller); } - public function testGetFirstChildElement() + public function testGetFirstChildElement(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML('some text '); @@ -56,7 +55,7 @@ public function testGetFirstChildElement() $this::assertEquals('child', $child->nodeName); } - public function testGetFirstChildElementNotFound() + public function testGetFirstChildElementNotFound(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML('some text '); @@ -65,7 +64,7 @@ public function testGetFirstChildElementNotFound() $this::assertFalse(Marshaller::getFirstChildElement($element)); } - public function testGetChildElements() + public function testGetChildElements(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML('some text '); @@ -79,7 +78,7 @@ public function testGetChildElements() $this::assertEquals('anotherChild', $childElements[1]->nodeName); } - public function testGetChildElementsByTagName() + public function testGetChildElementsByTagName(): void { $dom = new DOMDocument('1.0', 'UTF-8'); @@ -87,22 +86,22 @@ public function testGetChildElementsByTagName() // We should find only 2 direct child elements. $dom->loadXML(''); $element = $dom->documentElement; - $marshaller = new FakeMarshaller('2.1.0'); + $marshaller = $this->createMarshaller(); $this::assertCount(2, $marshaller->getChildElementsByTagName($element, 'child')); } - public function testGetChildElementsByTagNameMultiple() + public function testGetChildElementsByTagNameMultiple(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); $element = $dom->documentElement; - $marshaller = new FakeMarshaller('2.1.0'); + $marshaller = $this->createMarshaller(); $this::assertCount(3, $marshaller->getChildElementsByTagName($element, ['child', 'grandChild'])); } - public function testGetChildElementsByTagNameEmpty() + public function testGetChildElementsByTagNameEmpty(): void { $dom = new DOMDocument('1.0', 'UTF-8'); @@ -110,12 +109,12 @@ public function testGetChildElementsByTagNameEmpty() // should be found. $dom->loadXML(''); $element = $dom->documentElement; - $marshaller = new FakeMarshaller('2.1.0'); + $marshaller = $this->createMarshaller(); $this::assertCount(0, $marshaller->getChildElementsByTagName($element, 'child')); } - public function testGetXmlBase() + public function testGetXmlBase(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML('2000fucked up beyond all recognition'); @@ -132,7 +131,7 @@ public function testGetXmlBase() /** * @depends testGetXmlBase */ - public function testSetXmlBase() + public function testSetXmlBase(): void { $dom = new DOMDocument('1.0'); $dom->loadXML('2000fucked up beyond all recognition'); @@ -152,7 +151,7 @@ public function testSetXmlBase() $this::assertFalse(Marshaller::getXmlBase($baz)); } - public function testNoSuchMarshallerWhileUnmarshalling() + public function testNoSuchMarshallerWhileUnmarshalling(): void { $dom = new DOMDocument('1.0'); $dom->loadXML('2000fucked up beyond all recognition'); @@ -167,7 +166,7 @@ public function testNoSuchMarshallerWhileUnmarshalling() $marshaller->unmarshall($dom->documentElement); } - public function testNoSuchMarshallerWhileMarshalling() + public function testNoSuchMarshallerWhileMarshalling(): void { $component1 = new BaseValue(BaseType::BOOLEAN, true); $component2 = new stdClass(); @@ -179,7 +178,7 @@ public function testNoSuchMarshallerWhileMarshalling() $marshaller->marshall($component2); } - public function testNoSuchMagicMethod() + public function testNoSuchMagicMethod(): void { $component1 = new BaseValue(BaseType::BOOLEAN, true); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component1); @@ -189,28 +188,16 @@ public function testNoSuchMagicMethod() $marshaller->hello('blah'); } -} - -class FakeMarshaller extends Marshaller -{ - /** - * @inheritDoc - */ - protected function marshall(QtiComponent $component) - { - } - /** - * @inheritDoc - */ - protected function unmarshall(DOMElement $element) - { - } - - /** - * @inheritDoc - */ - public function getExpectedQtiClassName() + private function createMarshaller(): Marshaller { + return $this->getMockBuilder(Marshaller::class) + ->setConstructorArgs(['2.1.0']) + ->onlyMethods([ + 'marshall', + 'unmarshall', + 'getExpectedQtiClassName' + ]) + ->getMock(); } } diff --git a/test/qtismtest/data/storage/xml/marshalling/MatchInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MatchInteractionMarshallerTest.php index 28cf2d2db..6704ebf54 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MatchInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MatchInteractionMarshallerTest.php @@ -19,7 +19,7 @@ */ class MatchInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $choice1A = new SimpleAssociableChoice('choice1A', 1); $choice1A->setContent(new FlowStaticCollection([new TextRun('choice1A')])); @@ -55,7 +55,7 @@ public function testMarshall21() ); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' @@ -92,7 +92,7 @@ public function testUnmarshall21() $this::assertEquals('choice2B', $associableChoices[1]->getIdentifier()); } - public function testUnmarshall21NoResponseIdentifier() + public function testUnmarshall21NoResponseIdentifier(): void { $element = $this->createDOMElement(' @@ -116,7 +116,7 @@ public function testUnmarshall21NoResponseIdentifier() $marshaller->unmarshall($element); } - public function testUnmarshall21SingleMatchSet() + public function testUnmarshall21SingleMatchSet(): void { $element = $this->createDOMElement(' @@ -136,7 +136,7 @@ public function testUnmarshall21SingleMatchSet() $marshaller->unmarshall($element); } - public function testMarshall20() + public function testMarshall20(): void { $choice1A = new SimpleAssociableChoice('choice1A', 1); $choice1A->setContent(new FlowStaticCollection([new TextRun('choice1A')])); @@ -165,7 +165,7 @@ public function testMarshall20() /** * @depends testMarshall20 */ - public function testMarshallMaxAssociationsShuffleInOutput20() + public function testMarshallMaxAssociationsShuffleInOutput20(): void { // Aims at testing that maxAssociations and shuffle attributes // are always in the output while in a QTI 2.0 context. @@ -195,7 +195,7 @@ public function testMarshallMaxAssociationsShuffleInOutput20() /** * @depends testMarshall20 */ - public function testMarshallNoMinAssociations() + public function testMarshallNoMinAssociations(): void { // Aims at testing that minAssociations is never in the output // in a QTI 2.0 context. @@ -223,7 +223,7 @@ public function testMarshallNoMinAssociations() ); } - public function testUnmarshall20() + public function testUnmarshall20(): void { $element = $this->createDOMElement(' @@ -262,7 +262,7 @@ public function testUnmarshall20() /** * @depends testUnmarshall20 */ - public function testUnmarshallMandatoryShuffle20() + public function testUnmarshallMandatoryShuffle20(): void { // This test aims at testing that shuffle // is a mandatory attribute in a QTI 2.0 context. @@ -287,7 +287,7 @@ public function testUnmarshallMandatoryShuffle20() /** * @depends testUnmarshall20 */ - public function testUnmarshallMandatoryMaxAssociations20() + public function testUnmarshallMandatoryMaxAssociations20(): void { // Aims at testing that the maxAssociations attribute is // mandatory in a QTI 2.0 context. @@ -312,7 +312,7 @@ public function testUnmarshallMandatoryMaxAssociations20() /** * @depends testUnmarshall20 */ - public function testUnmarshallNoMinAssociationsInfluence20() + public function testUnmarshallNoMinAssociationsInfluence20(): void { // Aims at testing that the maxAssociations attribute is // mandatory in a QTI 2.0 context. diff --git a/test/qtismtest/data/storage/xml/marshalling/MatchTableEntryMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MatchTableEntryMarshallerTest.php index 1f32b5363..417fa3154 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MatchTableEntryMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MatchTableEntryMarshallerTest.php @@ -13,7 +13,7 @@ */ class MatchTableEntryMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $sourceValue = 2; $targetValue = 'http://www.rdfabout.com'; @@ -28,7 +28,7 @@ public function testMarshall() $this::assertEquals($targetValue, $element->getAttribute('targetValue')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/MatchTableMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MatchTableMarshallerTest.php index 65787ea87..16401373c 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MatchTableMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MatchTableMarshallerTest.php @@ -17,7 +17,7 @@ */ class MatchTableMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $matchTableEntryCollection = new MatchTableEntryCollection(); $matchTableEntryCollection[] = new MatchTableEntry(1, new QtiPair('A', 'B')); @@ -38,7 +38,7 @@ public function testMarshall() $this::assertEquals('1', $entry->getAttribute('sourceValue')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/MathConstantMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MathConstantMarshallerTest.php index baf5c4642..3d0a4963a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MathConstantMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MathConstantMarshallerTest.php @@ -13,7 +13,7 @@ */ class MathConstantMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $name = MathEnumeration::PI; @@ -26,7 +26,7 @@ public function testMarshall() $this::assertEquals('pi', $element->getAttribute('name')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/MathMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MathMarshallerTest.php index ba4fbd874..9bd7c554b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MathMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MathMarshallerTest.php @@ -13,7 +13,7 @@ */ class MathMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $math = new Math('E=mc2'); $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($math)->marshall($math); @@ -23,7 +23,7 @@ public function testMarshall() $this::assertEquals('E=mc2', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' @@ -48,7 +48,7 @@ public function testUnmarshall() $this::assertEquals('http://www.w3.org/1998/Math/MathML', $mathElement->namespaceURI); } - public function testGetXmlWrongNamespace() + public function testGetXmlWrongNamespace(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/MathOperatorMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MathOperatorMarshallerTest.php index ea1105e63..2a4659109 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MathOperatorMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MathOperatorMarshallerTest.php @@ -16,7 +16,7 @@ */ class MathOperatorMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $subExpr = new ExpressionCollection([new BaseValue(BaseType::FLOAT, 1.57)]); // 90° $name = MathFunctions::SIN; @@ -34,7 +34,7 @@ public function testMarshall() $this::assertEquals('1.57', $subExprElts->item(0)->nodeValue); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/MediaInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MediaInteractionMarshallerTest.php index ea016405c..43b72990a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MediaInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MediaInteractionMarshallerTest.php @@ -16,7 +16,7 @@ */ class MediaInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $object = new ObjectElement('my-video.mp4', 'video/mp4'); $object->setWidth('400'); @@ -42,7 +42,7 @@ public function testMarshall() ); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement( ' @@ -71,7 +71,7 @@ public function testUnmarshall() $this::assertEquals('Prompt...', $promptContent[0]->getContent()); } - public function testUnmarshallNoObject() + public function testUnmarshallNoObject(): void { $element = $this->createDOMElement(' Prompt... @@ -83,7 +83,7 @@ public function testUnmarshallNoObject() $component = $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallMissingAutoStart() + public function testUnmarshallMissingAutoStart(): void { $element = $this->createDOMElement(' Prompt... @@ -95,7 +95,7 @@ public function testUnmarshallMissingAutoStart() $component = $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallMissingResponseIdentifier() + public function testUnmarshallMissingResponseIdentifier(): void { $element = $this->createDOMElement(' Prompt... diff --git a/test/qtismtest/data/storage/xml/marshalling/ModalFeedbackMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ModalFeedbackMarshallerTest.php index 803ff51a5..749ebeea6 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ModalFeedbackMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ModalFeedbackMarshallerTest.php @@ -15,7 +15,7 @@ */ class ModalFeedbackMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $content = new FlowStaticCollection([new TextRun('Please show me!')]); $modalFeedback = new ModalFeedback('outcome1', 'hello', $content, 'Modal Feedback Example'); @@ -28,7 +28,7 @@ public function testMarshall() $this::assertEquals('Please show me!', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' Please show me! @@ -46,7 +46,7 @@ public function testUnmarshall() $this::assertEquals('Please show me!', $content[0]->getContent()); } - public function testUnmarshallShowHideInvalid() + public function testUnmarshallShowHideInvalid(): void { $element = $this->createDOMElement(' Please show me! @@ -58,7 +58,7 @@ public function testUnmarshallShowHideInvalid() $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallInvalidContent() + public function testUnmarshallInvalidContent(): void { $element = $this->createDOMElement(' @@ -74,7 +74,7 @@ public function testUnmarshallInvalidContent() $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallNoShowHide() + public function testUnmarshallNoShowHide(): void { $element = $this->createDOMElement(' Please show me! @@ -86,7 +86,7 @@ public function testUnmarshallNoShowHide() $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallNoOutcomeIdentifier() + public function testUnmarshallNoOutcomeIdentifier(): void { $element = $this->createDOMElement(' Please show me! @@ -98,7 +98,7 @@ public function testUnmarshallNoOutcomeIdentifier() $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallNoIdentifier() + public function testUnmarshallNoIdentifier(): void { $element = $this->createDOMElement(' Please show me! diff --git a/test/qtismtest/data/storage/xml/marshalling/ModalFeedbackRuleMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ModalFeedbackRuleMarshallerTest.php index 82058a7a2..73f785cb1 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ModalFeedbackRuleMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ModalFeedbackRuleMarshallerTest.php @@ -13,7 +13,7 @@ */ class ModalFeedbackRuleMarshallerTest extends QtiSmTestCase { - public function testUnmarshallNoTitle() + public function testUnmarshallNoTitle(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -29,7 +29,7 @@ public function testUnmarshallNoTitle() $this::assertSame('', $mf->getTitle()); } - public function testMarshallNoTitle() + public function testMarshallNoTitle(): void { $mf = new ModalFeedbackRule('SHOW_HIM', ShowHide::SHOW, 'SHOW_MEH'); $factory = new Compact21MarshallerFactory(); @@ -46,7 +46,7 @@ public function testMarshallNoTitle() /** * @depends testUnmarshallNoTitle */ - public function testUnmarshallTitle() + public function testUnmarshallTitle(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -61,7 +61,7 @@ public function testUnmarshallTitle() /** * @depends testMarshallNoTitle */ - public function testMarshallTitle() + public function testMarshallTitle(): void { $mf = new ModalFeedbackRule('SHOW_HIM', ShowHide::SHOW, 'SHOW_MEH', 'Beautiful Feedback!'); $factory = new Compact21MarshallerFactory(); diff --git a/test/qtismtest/data/storage/xml/marshalling/NullValueMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/NullValueMarshallerTest.php index 2c9266d4d..a33d27fae 100644 --- a/test/qtismtest/data/storage/xml/marshalling/NullValueMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/NullValueMarshallerTest.php @@ -12,7 +12,7 @@ */ class NullValueMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $component = new NullValue(); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component); @@ -22,7 +22,7 @@ public function testMarshall() $this::assertEquals('null', $element->nodeName); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/NumberCorrectMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/NumberCorrectMarshallerTest.php index 96934b7d6..576ac9599 100644 --- a/test/qtismtest/data/storage/xml/marshalling/NumberCorrectMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/NumberCorrectMarshallerTest.php @@ -13,7 +13,7 @@ */ class NumberCorrectMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $sectionIdentifier = 'mySection1'; $includeCategory = 'cat1'; @@ -33,7 +33,7 @@ public function testMarshall() $this::assertEquals($excludeCategory, $element->getAttribute('excludeCategory')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/NumberIncorrectMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/NumberIncorrectMarshallerTest.php index 46058c87d..151eb8ae4 100644 --- a/test/qtismtest/data/storage/xml/marshalling/NumberIncorrectMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/NumberIncorrectMarshallerTest.php @@ -13,7 +13,7 @@ */ class NumberIncorrectMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $sectionIdentifier = 'mySection1'; $includeCategory = 'cat1'; @@ -33,7 +33,7 @@ public function testMarshall() $this::assertEquals($excludeCategory, $element->getAttribute('excludeCategory')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/NumberPresentedMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/NumberPresentedMarshallerTest.php index 0101c40fd..ec5f473c8 100644 --- a/test/qtismtest/data/storage/xml/marshalling/NumberPresentedMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/NumberPresentedMarshallerTest.php @@ -13,7 +13,7 @@ */ class NumberPresentedMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $sectionIdentifier = 'mySection1'; $includeCategory = 'cat1'; @@ -33,7 +33,7 @@ public function testMarshall() $this::assertEquals($excludeCategory, $element->getAttribute('excludeCategory')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/NumberRespondedMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/NumberRespondedMarshallerTest.php index 34d62c393..548c67920 100644 --- a/test/qtismtest/data/storage/xml/marshalling/NumberRespondedMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/NumberRespondedMarshallerTest.php @@ -13,7 +13,7 @@ */ class NumberRespondedMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $sectionIdentifier = 'mySection1'; $includeCategory = 'cat1'; @@ -33,7 +33,7 @@ public function testMarshall() $this::assertEquals($excludeCategory, $element->getAttribute('excludeCategory')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/NumberSelectedMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/NumberSelectedMarshallerTest.php index fec54f7ff..ceb2266d6 100644 --- a/test/qtismtest/data/storage/xml/marshalling/NumberSelectedMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/NumberSelectedMarshallerTest.php @@ -13,7 +13,7 @@ */ class NumberSelectedMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $sectionIdentifier = 'mySection1'; $includeCategory = 'cat1'; @@ -33,7 +33,7 @@ public function testMarshall() $this::assertEquals($excludeCategory, $element->getAttribute('excludeCategory')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/ObjectMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ObjectMarshallerTest.php index ada6d97a5..33fef170f 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ObjectMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ObjectMarshallerTest.php @@ -14,7 +14,7 @@ */ class ObjectMarshallerTest extends QtiSmTestCase { - public function testUnmarshallSimple() + public function testUnmarshallSimple(): void { /** @var ObjectElement $object */ $object = $this->createComponentFromXml(' @@ -48,7 +48,7 @@ public function testUnmarshallSimple() $this::assertFalse($object->hasWidth()); } - public function testUnmarshallNoDataAttributeValue() + public function testUnmarshallNoDataAttributeValue(): void { $object = $this->createComponentFromXml(' @@ -60,7 +60,7 @@ public function testUnmarshallNoDataAttributeValue() $this::assertEquals('application/x-shockwave-flash', $object->getType()); } - public function testUnmarshallWithDimensionPercentAttributesValue() + public function testUnmarshallWithDimensionPercentAttributesValue(): void { /** @var ObjectElement $object */ $object = $this->createComponentFromXml(' @@ -73,7 +73,7 @@ public function testUnmarshallWithDimensionPercentAttributesValue() $this::assertEquals('100%', $object->getWidth()); } - public function testUnmarshallWithDimensionIntegerAttributesValue() + public function testUnmarshallWithDimensionIntegerAttributesValue(): void { /** @var ObjectElement $object */ $object = $this->createComponentFromXml(' @@ -86,7 +86,7 @@ public function testUnmarshallWithDimensionIntegerAttributesValue() $this::assertEquals('1000', $object->getWidth()); } - public function testMarshallSimple() + public function testMarshallSimple(): void { $param1 = new Param('movie', 'movie.swf', ParamType::REF); $param2 = new Param('quality', 'high', ParamType::DATA); @@ -100,7 +100,7 @@ public function testMarshallSimple() $this::assertEquals('', $dom->saveXml($element)); } - public function testMarshallNoDataAttributeValue() + public function testMarshallNoDataAttributeValue(): void { $object = new ObjectElement('', 'application/x-shockwave-flash', 'flash-movie'); $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($object)->marshall($object); diff --git a/test/qtismtest/data/storage/xml/marshalling/OperatorMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/OperatorMarshallerTest.php index 8fef2e70c..2f2f84b01 100644 --- a/test/qtismtest/data/storage/xml/marshalling/OperatorMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/OperatorMarshallerTest.php @@ -14,7 +14,7 @@ */ class OperatorMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -63,7 +63,7 @@ public function testUnmarshall() $this::assertEquals(4, $sub22->getValue()); } - public function testMarshall() + public function testMarshall(): void { $sub1Operands = new ExpressionCollection([new BaseValue(BaseType::INTEGER, 1), new BaseValue(BaseType::INTEGER, 2)]); $sub2Operands = new ExpressionCollection([new BaseValue(BaseType::INTEGER, 3), new BaseValue(BaseType::INTEGER, 4)]); diff --git a/test/qtismtest/data/storage/xml/marshalling/OrderInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/OrderInteractionMarshallerTest.php index 8fb4a26bc..60681b2ab 100644 --- a/test/qtismtest/data/storage/xml/marshalling/OrderInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/OrderInteractionMarshallerTest.php @@ -17,7 +17,7 @@ */ class OrderInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $choice1 = new SimpleChoice('choice_1'); $choice1->setContent(new FlowStaticCollection([new TextRun('Choice #1')])); @@ -43,7 +43,7 @@ public function testMarshall21() /** * @depends testMarshall21 */ - public function testMarshallNoMinMaxChoicesIfNotSpecified21() + public function testMarshallNoMinMaxChoicesIfNotSpecified21(): void { $choice1 = new SimpleChoice('choice_1'); $choice1->setContent(new FlowStaticCollection([new TextRun('Choice #1')])); @@ -59,7 +59,7 @@ public function testMarshallNoMinMaxChoicesIfNotSpecified21() $this::assertEquals('Choice #1', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' @@ -90,7 +90,7 @@ public function testUnmarshall21() $this::assertCount(2, $simpleChoices); } - public function testUnmarshall20() + public function testUnmarshall20(): void { $element = $this->createDOMElement(' @@ -124,7 +124,7 @@ public function testUnmarshall20() /** * @depends testUnmarshall20 */ - public function testUnmarshallMinMaxChoicesIgnored20() + public function testUnmarshallMinMaxChoicesIgnored20(): void { // Check that minChoices and maxChoices are ignored in QTI 2.0. $element = $this->createDOMElement(' @@ -148,7 +148,7 @@ public function testUnmarshallMinMaxChoicesIgnored20() $this::assertFalse($component->hasMaxChoices()); } - public function testMarshal20() + public function testMarshal20(): void { $choice1 = new SimpleChoice('choice_1'); $choice1->setContent(new FlowStaticCollection([new TextRun('Choice #1')])); diff --git a/test/qtismtest/data/storage/xml/marshalling/OrderingMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/OrderingMarshallerTest.php index b0321954e..ea92a1c10 100644 --- a/test/qtismtest/data/storage/xml/marshalling/OrderingMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/OrderingMarshallerTest.php @@ -12,7 +12,7 @@ */ class OrderingMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $shuffle = true; $component = new Ordering($shuffle); @@ -24,7 +24,7 @@ public function testMarshall() $this::assertEquals('true', $element->getAttribute('shuffle')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/OutcomeConditionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/OutcomeConditionMarshallerTest.php index 64419062d..959084ac9 100644 --- a/test/qtismtest/data/storage/xml/marshalling/OutcomeConditionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/OutcomeConditionMarshallerTest.php @@ -19,7 +19,7 @@ */ class OutcomeConditionMarshallerTest extends QtiSmTestCase { - public function testMarshallIfMinimal() + public function testMarshallIfMinimal(): void { $setOutcomeValue = new SetOutcomeValue('myStringVar', new BaseValue(BaseType::STRING, 'Tested!')); $outcomeIf = new OutcomeIf(new BaseValue(BaseType::BOOLEAN, true), new OutcomeRuleCollection([$setOutcomeValue])); @@ -35,7 +35,7 @@ public function testMarshallIfMinimal() $this::assertSame($element->getElementsByTagName('outcomeIf')->item(0), $element->getElementsByTagName('setOutcomeValue')->item(0)->parentNode); } - public function testUnmarshallConditionMinimal() + public function testUnmarshallConditionMinimal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -66,7 +66,7 @@ public function testUnmarshallConditionMinimal() $this::assertEquals('myStringVar', $outcomeRules[0]->getIdentifier()); } - public function testUnmarshallConditionElseIf() + public function testUnmarshallConditionElseIf(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -113,7 +113,7 @@ public function testUnmarshallConditionElseIf() $this::assertEquals('ElseIf!', $outcomeRules[0]->getExpression()->getValue()); } - public function testUnmarshallConditionElseIfElse() + public function testUnmarshallConditionElseIfElse(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -171,7 +171,7 @@ public function testUnmarshallConditionElseIfElse() $this::assertEquals('Else!', $outcomeRules[0]->getExpression()->getValue()); } - public function testUnmarshallConditionMultipleElseIf() + public function testUnmarshallConditionMultipleElseIf(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -242,7 +242,7 @@ public function testUnmarshallConditionMultipleElseIf() $this::assertEquals('Else!', $outcomeRules[0]->getExpression()->getValue()); } - public function testUnmarshallConditionUltimate() + public function testUnmarshallConditionUltimate(): void { // Special thanks to Younes Djaghloul ! We love you Younz :D ! $dom = new DOMDocument('1.0', 'UTF-8'); diff --git a/test/qtismtest/data/storage/xml/marshalling/OutcomeControlMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/OutcomeControlMarshallerTest.php index 4d59cbd62..7a5e91dca 100644 --- a/test/qtismtest/data/storage/xml/marshalling/OutcomeControlMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/OutcomeControlMarshallerTest.php @@ -18,7 +18,7 @@ */ class OutcomeControlMarshallerTest extends QtiSmTestCase { - public function testMarshallIfMinimal() + public function testMarshallIfMinimal(): void { $setOutcomeValue = new SetOutcomeValue('myStringVar', new BaseValue(BaseType::STRING, 'Tested!')); $baseValue = new BaseValue(BaseType::BOOLEAN, true); @@ -46,7 +46,7 @@ public function testMarshallIfMinimal() $this::assertEquals('string', $tested->getAttribute('baseType')); } - public function testMarshallElseIfMinimal() + public function testMarshallElseIfMinimal(): void { $setOutcomeValue = new SetOutcomeValue('myStringVar', new BaseValue(BaseType::STRING, 'Tested!')); $baseValue = new BaseValue(BaseType::BOOLEAN, true); @@ -74,7 +74,7 @@ public function testMarshallElseIfMinimal() $this::assertEquals('string', $tested->getAttribute('baseType')); } - public function testMarshallElseMinimal() + public function testMarshallElseMinimal(): void { $setOutcomeValue = new SetOutcomeValue('myStringVar', new BaseValue(BaseType::STRING, 'Tested!')); $component = new OutcomeElse(new OutcomeRuleCollection([$setOutcomeValue])); @@ -95,7 +95,7 @@ public function testMarshallElseMinimal() $this::assertEquals('Tested!', $tested->nodeValue); } - public function testUnmarshallIfMinimal() + public function testUnmarshallIfMinimal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -125,7 +125,7 @@ public function testUnmarshallIfMinimal() $this::assertEquals(BaseType::STRING, $outcomeRules[0]->getExpression()->getBaseType()); } - public function testUnmarshallElseIfMinimal() + public function testUnmarshallElseIfMinimal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -155,7 +155,7 @@ public function testUnmarshallElseIfMinimal() $this::assertEquals(BaseType::STRING, $outcomeRules[0]->getExpression()->getBaseType()); } - public function testUnmarshallElseMinimal() + public function testUnmarshallElseMinimal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/OutcomeDeclarationMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/OutcomeDeclarationMarshallerTest.php index 2dc2516d0..caf00c4cb 100644 --- a/test/qtismtest/data/storage/xml/marshalling/OutcomeDeclarationMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/OutcomeDeclarationMarshallerTest.php @@ -27,7 +27,7 @@ */ class OutcomeDeclarationMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { // Initialize a minimal outcomeDeclaration. $identifier = 'outcome1'; @@ -51,7 +51,7 @@ public function testMarshall21() $this::assertEquals('0.5', $element->getAttribute('masteryValue')); } - public function testUnmarshallExternalScoredWithIllegalValue() + public function testUnmarshallExternalScoredWithIllegalValue(): void { $this->expectException(UnmarshallingException::class); $dom = new DOMDocument('1.0', 'UTF-8'); @@ -63,7 +63,7 @@ public function testUnmarshallExternalScoredWithIllegalValue() $marshaller->unmarshall($element); } - public function testUnmarshallExternalScored() + public function testUnmarshallExternalScored(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -85,7 +85,7 @@ public function testUnmarshallExternalScored() * @throws MarshallerNotFoundException * @throws MarshallingException */ - public function testMarshallExternalScored($qtiVersion, $externalScored, $expectedExternalScored) + public function testMarshallExternalScored($qtiVersion, $externalScored, $expectedExternalScored): void { // Initialize a minimal outcomeDeclaration. $identifier = 'outcome1'; @@ -107,7 +107,7 @@ public function testMarshallExternalScored($qtiVersion, $externalScored, $expect /** * @return array */ - public function qtiVersionsToTestForExternalScored() + public function qtiVersionsToTestForExternalScored(): array { return [ ['2.0', ExternalScored::HUMAN, ''], @@ -124,7 +124,7 @@ public function qtiVersionsToTestForExternalScored() /** * @depends testMarshall21 */ - public function testMarshallNoOutputViewsNormalMinimumMasteryValueView20() + public function testMarshallNoOutputViewsNormalMinimumMasteryValueView20(): void { $identifier = 'outcome1'; $cardinality = Cardinality::SINGLE; @@ -146,7 +146,7 @@ public function testMarshallNoOutputViewsNormalMinimumMasteryValueView20() $this::assertSame(0, $lookupTableElts->length); } - public function testMarshallMinimal() + public function testMarshallMinimal(): void { // Initialize a minimal outcomeDeclaration. $identifier = 'outcome1'; @@ -164,7 +164,7 @@ public function testMarshallMinimal() $this::assertEquals('outcome1', $element->getAttribute('identifier')); } - public function testMarshallDefaultValue21() + public function testMarshallDefaultValue21(): void { $identifier = 'outcome2'; $cardinality = Cardinality::MULTIPLE; @@ -205,7 +205,7 @@ public function testMarshallDefaultValue21() $this::assertEquals('', $value->getAttribute('baseType')); } - public function testMarshallMatchTable21() + public function testMarshallMatchTable21(): void { $identifier = 'outcome3'; $cardinality = Cardinality::SINGLE; @@ -250,7 +250,7 @@ public function testMarshallMatchTable21() /** * @depends testMarshallMatchTable21 */ - public function testMarshallMatchTable20() + public function testMarshallMatchTable20(): void { // This should fail because no marshaller is known for lookupTable sub classes // in a QTI 2.0 context. @@ -272,7 +272,7 @@ public function testMarshallMatchTable20() $element = $marshaller->marshall($component); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -288,7 +288,7 @@ public function testUnmarshall21() $this::assertEquals('http://my.long.com/interpretation', $component->getLongInterpretation()); } - public function testUnmarshallDefaultValue21() + public function testUnmarshallDefaultValue21(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -325,7 +325,7 @@ public function testUnmarshallDefaultValue21() $this::assertInstanceOf(QtiDuration::class, $values[1]->getValue()); } - public function testUnmarshallRecord21() + public function testUnmarshallRecord21(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -379,7 +379,7 @@ public function testUnmarshallRecord21() $this::assertEquals(1.11, $values[2]->getValue()); } - public function testUnmarshallMatchTable21() + public function testUnmarshallMatchTable21(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -417,7 +417,7 @@ public function testUnmarshallMatchTable21() /** * @depends testUnmarshallMatchTable21 */ - public function testUnmarshallMatchTable20() + public function testUnmarshallMatchTable20(): void { // Make sure match table is not take into account // in a QTI 2.0 context. diff --git a/test/qtismtest/data/storage/xml/marshalling/OutcomeMaximumMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/OutcomeMaximumMarshallerTest.php index 37abcca8d..1d6a3dea5 100644 --- a/test/qtismtest/data/storage/xml/marshalling/OutcomeMaximumMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/OutcomeMaximumMarshallerTest.php @@ -13,7 +13,7 @@ */ class OutcomeMaximumMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $sectionIdentifier = 'mySection1'; $outcomeIdentifier = 'myOutcome1'; @@ -37,7 +37,7 @@ public function testMarshall() $this::assertEquals($excludeCategory, $element->getAttribute('excludeCategory')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/OutcomeMinimumMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/OutcomeMinimumMarshallerTest.php index 615cafdf6..71b508fa3 100644 --- a/test/qtismtest/data/storage/xml/marshalling/OutcomeMinimumMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/OutcomeMinimumMarshallerTest.php @@ -13,7 +13,7 @@ */ class OutcomeMinimumMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $sectionIdentifier = 'mySection1'; $outcomeIdentifier = 'myOutcome1'; @@ -37,7 +37,7 @@ public function testMarshall() $this::assertEquals($excludeCategory, $element->getAttribute('excludeCategory')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/OutcomeProcessingMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/OutcomeProcessingMarshallerTest.php index 208e70568..81282a3e7 100644 --- a/test/qtismtest/data/storage/xml/marshalling/OutcomeProcessingMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/OutcomeProcessingMarshallerTest.php @@ -17,7 +17,7 @@ */ class OutcomeProcessingMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $outcomeRules = new OutcomeRuleCollection(); $outcomeRules[] = new LookupOutcomeValue('output1', new BaseValue(BaseType::FLOAT, 24.3)); @@ -38,7 +38,7 @@ public function testMarshall() $this::assertEquals('true', $element->getElementsByTagName('baseValue')->item(1)->nodeValue); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/OutcomeVariableMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/OutcomeVariableMarshallerTest.php index deff5c12c..5c9706f71 100644 --- a/test/qtismtest/data/storage/xml/marshalling/OutcomeVariableMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/OutcomeVariableMarshallerTest.php @@ -41,7 +41,7 @@ */ class OutcomeVariableMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { /** @var ResultOutcomeVariable $resultOutcomeVariable */ $resultOutcomeVariable = $this->createComponentFromXml(' @@ -95,7 +95,7 @@ public function testUnmarshall() $this::assertEquals(3, $resultOutcomeVariable->getValues()->count()); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { /** @var ResultOutcomeVariable $resultOutcomeVariable */ $resultOutcomeVariable = $this->createComponentFromXml(' @@ -134,7 +134,7 @@ public function testUnmarshallMinimal() $this::assertNull($resultOutcomeVariable->getValues()); } - public function testMarshall() + public function testMarshall(): void { $component = new ResultOutcomeVariable( new QtiIdentifier('fixture-identifier'), @@ -166,7 +166,7 @@ public function testMarshall() $this::assertEquals(2, $element->getElementsByTagName('value')->length); } - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $component = new ResultOutcomeVariable( new QtiIdentifier('fixture-identifier'), @@ -189,7 +189,7 @@ public function testMarshallMinimal() $this::assertEquals(0, $element->getElementsByTagName('value')->length); } - public function testGetExpectedQtiClassName() + public function testGetExpectedQtiClassName(): void { $component = new ResultOutcomeVariable( new QtiIdentifier('fixture-identifier'), diff --git a/test/qtismtest/data/storage/xml/marshalling/ParamMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ParamMarshallerTest.php index 0f25aade6..0c0785c49 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ParamMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ParamMarshallerTest.php @@ -12,7 +12,7 @@ */ class ParamMarshallerTest extends QtiSmTestCase { - public function testUnmarshallSimple() + public function testUnmarshallSimple(): void { $param = $this->createComponentFromXml(' @@ -25,7 +25,7 @@ public function testUnmarshallSimple() $this::assertEquals('application/x-shockwave-flash', $param->getType()); } - public function testMarshallSimple() + public function testMarshallSimple(): void { $param = new Param('movie', 'movie.swf', ParamType::REF, 'application/x-shockwave-flash'); diff --git a/test/qtismtest/data/storage/xml/marshalling/PatternMatchMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/PatternMatchMarshallerTest.php index 95552b1aa..84c421d69 100644 --- a/test/qtismtest/data/storage/xml/marshalling/PatternMatchMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/PatternMatchMarshallerTest.php @@ -15,7 +15,7 @@ */ class PatternMatchMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $subs = new ExpressionCollection(); $subs[] = new BaseValue(BaseType::STRING, 'Hello World'); @@ -32,7 +32,7 @@ public function testMarshall() $this::assertEquals(1, $element->getElementsByTagName('baseValue')->length); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/PositionObjectInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/PositionObjectInteractionMarshallerTest.php index 20d6638c2..f307e2580 100644 --- a/test/qtismtest/data/storage/xml/marshalling/PositionObjectInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/PositionObjectInteractionMarshallerTest.php @@ -17,7 +17,7 @@ */ class PositionObjectInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $object = new ObjectElement('myimg.jpg', 'image/jpeg'); $object->setWidth('400'); @@ -41,7 +41,7 @@ public function testMarshall21() /** * @depends testMarshall21 */ - public function testMarshall20() + public function testMarshall20(): void { // Make sure minChoices is not taken into account in a QTI 2.0 context. $object = new ObjectElement('myimg.jpg', 'image/jpeg'); @@ -59,7 +59,7 @@ public function testMarshall20() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' @@ -84,7 +84,7 @@ public function testUnmarshall21() /** * @depends testUnmarshall21 */ - public function testUnmarshall21InvalidCenterPoint() + public function testUnmarshall21InvalidCenterPoint(): void { $element = $this->createDOMElement(' @@ -101,7 +101,7 @@ public function testUnmarshall21InvalidCenterPoint() /** * @depends testUnmarshall21 */ - public function testUnmarshall21InvalidCenterPointFirstValue() + public function testUnmarshall21InvalidCenterPointFirstValue(): void { $element = $this->createDOMElement(' @@ -118,7 +118,7 @@ public function testUnmarshall21InvalidCenterPointFirstValue() /** * @depends testUnmarshall21 */ - public function testUnmarshall21InvalidCenterPointSecondValue() + public function testUnmarshall21InvalidCenterPointSecondValue(): void { $element = $this->createDOMElement(' @@ -135,7 +135,7 @@ public function testUnmarshall21InvalidCenterPointSecondValue() /** * @depends testUnmarshall21 */ - public function testUnmarshall21NoObject() + public function testUnmarshall21NoObject(): void { $element = $this->createDOMElement(' @@ -150,7 +150,7 @@ public function testUnmarshall21NoObject() /** * @depends testUnmarshall21 */ - public function testUnmarshall21MissingResponseIdentifier() + public function testUnmarshall21MissingResponseIdentifier(): void { $element = $this->createDOMElement(' @@ -167,7 +167,7 @@ public function testUnmarshall21MissingResponseIdentifier() /** * @depends testUnmarshall21 */ - public function testUnmarshall20() + public function testUnmarshall20(): void { // Make sure minChoices is not in output in a QTI 2.0 context. $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/PositionObjectStageMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/PositionObjectStageMarshallerTest.php index 7b3421ed5..7071422fe 100644 --- a/test/qtismtest/data/storage/xml/marshalling/PositionObjectStageMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/PositionObjectStageMarshallerTest.php @@ -15,7 +15,7 @@ */ class PositionObjectStageMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $interactionObject = new ObjectElement('airplane.jpg', 'image/jpeg'); $interactionObject->setHeight('16'); @@ -37,7 +37,7 @@ public function testMarshall() ); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/PreConditionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/PreConditionMarshallerTest.php index 7c4ddfa6b..1f8dca536 100644 --- a/test/qtismtest/data/storage/xml/marshalling/PreConditionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/PreConditionMarshallerTest.php @@ -14,7 +14,7 @@ */ class PreConditionMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $component = new PreCondition(new BaseValue(BaseType::BOOLEAN, true)); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component); @@ -25,7 +25,7 @@ public function testMarshall() $this::assertEquals('baseValue', $element->getElementsByTagName('baseValue')->item(0)->nodeName); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/PrintedVariableMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/PrintedVariableMarshallerTest.php index e96b522d8..b8c83f071 100644 --- a/test/qtismtest/data/storage/xml/marshalling/PrintedVariableMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/PrintedVariableMarshallerTest.php @@ -20,7 +20,7 @@ class PrintedVariableMarshallerTest extends QtiSmTestCase * @throws MarshallerNotFoundException * @throws MarshallingException */ - public function testMarshall21() + public function testMarshall21(): void { $component = new PrintedVariable('PRID'); $component->setIndex(0); @@ -42,7 +42,7 @@ public function testMarshall21() * @throws MarshallerNotFoundException * @throws MarshallingException */ - public function testMarshall22() + public function testMarshall22(): void { $component = new PrintedVariable('PRID'); $component->setAriaOrientation(AriaOrientation::VERTICAL); @@ -55,7 +55,7 @@ public function testMarshall22() $this::assertFalse($element->hasAttribute('aria-orientation')); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -74,7 +74,7 @@ public function testUnmarshall21() /** * @throws MarshallerNotFoundException */ - public function testUnmarshall22() + public function testUnmarshall22(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -92,7 +92,7 @@ public function testUnmarshall22() /** * @depends testUnmarshall21 */ - public function testUnmarshallNoIdentifier() + public function testUnmarshallNoIdentifier(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/PromptMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/PromptMarshallerTest.php index 54fa3fba6..4017c0a36 100644 --- a/test/qtismtest/data/storage/xml/marshalling/PromptMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/PromptMarshallerTest.php @@ -16,7 +16,7 @@ */ class PromptMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $component = new Prompt('my-prompt', 'qti-prompt'); $component->setContent(new FlowStaticCollection([new TextRun('This is a prompt')])); @@ -29,7 +29,7 @@ public function testMarshall() $this::assertEquals('This is a prompt', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement('This is a prompt'); @@ -45,7 +45,7 @@ public function testUnmarshall() $this::assertEquals('This is a prompt', $content[0]->getContent()); } - public function testUnmarshallExcludedFlowStatic() + public function testUnmarshallExcludedFlowStatic(): void { $element = $this->createDOMElement('This is a prompt with a
    pre which is not allowed.
    '); @@ -55,7 +55,7 @@ public function testUnmarshallExcludedFlowStatic() $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallExcludedComponents() + public function testUnmarshallExcludedComponents(): void { $element = $this->createDOMElement(' @@ -71,7 +71,7 @@ public function testUnmarshallExcludedComponents() $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallPromptWithAnchorInQti21ThrowsException() + public function testUnmarshallPromptWithAnchorInQti21ThrowsException(): void { $element = $this->createDOMElement('This is an anchor: anchor text'); @@ -81,7 +81,7 @@ public function testUnmarshallPromptWithAnchorInQti21ThrowsException() $marshaller->unmarshall($element); } - public function testUnmarshallPromptWithAnchorInQti22Works() + public function testUnmarshallPromptWithAnchorInQti22Works(): void { $element = $this->createDOMElement('This is an anchor: anchor text'); diff --git a/test/qtismtest/data/storage/xml/marshalling/Qti21MarshallerFactoryTest.php b/test/qtismtest/data/storage/xml/marshalling/Qti21MarshallerFactoryTest.php index 72206f01f..05e50a757 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Qti21MarshallerFactoryTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Qti21MarshallerFactoryTest.php @@ -17,7 +17,7 @@ */ class Qti21MarshallerFactyoryTest extends QtiSmTestCase { - public function testFromDomElement() + public function testFromDomElement(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -28,7 +28,7 @@ public function testFromDomElement() $this::assertInstanceOf(AreaMapEntryMarshaller::class, $marshaller); } - public function testFromQtiComponent() + public function testFromQtiComponent(): void { $shape = QtiShape::RECT; $coords = new QtiCoords($shape, [0, 20, 100, 0]); @@ -39,7 +39,7 @@ public function testFromQtiComponent() $this::assertInstanceOf(AreaMapEntryMarshaller::class, $marshaller); } - public function testFromInvalidObject() + public function testFromInvalidObject(): void { $this->expectException(InvalidArgumentException::class); $component = new stdClass(); diff --git a/test/qtismtest/data/storage/xml/marshalling/RandomFloatMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/RandomFloatMarshallerTest.php index 1f7229fa3..2a1e58172 100644 --- a/test/qtismtest/data/storage/xml/marshalling/RandomFloatMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/RandomFloatMarshallerTest.php @@ -11,7 +11,7 @@ */ class RandomFloatMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $min = 1; $max = '{tplVariable1}'; @@ -21,7 +21,7 @@ public function testMarshall() $this::assertTrue(true); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/RandomIntegerMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/RandomIntegerMarshallerTest.php index ca375103f..a92c0bca7 100644 --- a/test/qtismtest/data/storage/xml/marshalling/RandomIntegerMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/RandomIntegerMarshallerTest.php @@ -12,7 +12,7 @@ */ class RandomIntegerMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $min = 3; $max = '{tplVariable1}'; @@ -27,7 +27,7 @@ public function testMarshall() $this::assertEquals($step . '', $element->getAttribute('step')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/RepeatMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/RepeatMarshallerTest.php index cb578006d..d8da3a4d5 100644 --- a/test/qtismtest/data/storage/xml/marshalling/RepeatMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/RepeatMarshallerTest.php @@ -17,7 +17,7 @@ */ class RepeatMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $sub1 = new BaseValue(BaseType::FLOAT, 23.545); $sub21 = new BaseValue(BaseType::FLOAT, 1.68); @@ -43,7 +43,7 @@ public function testMarshall() $this::assertEquals('1.68', $sub22->nodeValue); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/ResponseDeclarationMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ResponseDeclarationMarshallerTest.php index 8d02dc041..b2ed593ce 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ResponseDeclarationMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ResponseDeclarationMarshallerTest.php @@ -23,7 +23,7 @@ */ class ResponseDeclarationMarshallerTest extends QtiSmTestCase { - public function testMarshallMinimal() + public function testMarshallMinimal(): void { // Initialize a minimal responseDeclaration. $identifier = 'response1'; @@ -41,7 +41,7 @@ public function testMarshallMinimal() $this::assertEquals('response1', $element->getAttribute('identifier')); } - public function testMarshallCorrectResponse() + public function testMarshallCorrectResponse(): void { $identifier = 'response2'; $cardinality = Cardinality::MULTIPLE; @@ -82,7 +82,7 @@ public function testMarshallCorrectResponse() $this::assertEquals('', $value->getAttribute('baseType')); } - public function testMarshallMapping() + public function testMarshallMapping(): void { $identifier = 'response3'; $cardinality = Cardinality::SINGLE; @@ -124,7 +124,7 @@ public function testMarshallMapping() $this::assertEquals(1.2, $entry->getAttribute('mappedValue')); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -139,7 +139,7 @@ public function testUnmarshallMinimal() $this::assertEquals(BaseType::INTEGER, $component->getBaseType()); } - public function testUnmarshallCorrectResponse() + public function testUnmarshallCorrectResponse(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -176,7 +176,7 @@ public function testUnmarshallCorrectResponse() $this::assertInstanceOf(QtiDuration::class, $values[1]->getValue()); } - public function testUnmarshallMatchTable() + public function testUnmarshallMatchTable(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/ResponseValidityConstraintMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ResponseValidityConstraintMarshallerTest.php index 0e73fb806..3aa49ae4b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ResponseValidityConstraintMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ResponseValidityConstraintMarshallerTest.php @@ -15,7 +15,7 @@ */ class ResponseValidityConstraintMarshallerTest extends QtiSmTestCase { - public function testUnmarshallSimple() + public function testUnmarshallSimple(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -33,7 +33,7 @@ public function testUnmarshallSimple() /** * @depends testUnmarshallSimple */ - public function testUnmarshallWithAssociationConstraints() + public function testUnmarshallWithAssociationConstraints(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(' @@ -61,7 +61,7 @@ public function testUnmarshallWithAssociationConstraints() /** * @depends testUnmarshallSimple */ - public function testUnmarshallWithPatternMask() + public function testUnmarshallWithPatternMask(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -75,7 +75,7 @@ public function testUnmarshallWithPatternMask() /** * @depends testUnmarshallSimple */ - public function testUnmarshallNoResponseIdentifier() + public function testUnmarshallNoResponseIdentifier(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -90,7 +90,7 @@ public function testUnmarshallNoResponseIdentifier() /** * @depends testUnmarshallSimple */ - public function testUnmarshallNoMinConstraint() + public function testUnmarshallNoMinConstraint(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -105,7 +105,7 @@ public function testUnmarshallNoMinConstraint() /** * @depends testUnmarshallSimple */ - public function testUnmarshallNoMaxConstraint() + public function testUnmarshallNoMaxConstraint(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -120,7 +120,7 @@ public function testUnmarshallNoMaxConstraint() /** * @depends testUnmarshallSimple */ - public function testUnmarshallInvalidMaxConstraintOne() + public function testUnmarshallInvalidMaxConstraintOne(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -135,7 +135,7 @@ public function testUnmarshallInvalidMaxConstraintOne() /** * @depends testUnmarshallSimple */ - public function testUnmarshallInvalidMaxConstraintTwo() + public function testUnmarshallInvalidMaxConstraintTwo(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -147,7 +147,7 @@ public function testUnmarshallInvalidMaxConstraintTwo() $component = $factory->createMarshaller($element)->unmarshall($element); } - public function testMarshallSimple() + public function testMarshallSimple(): void { $component = new ResponseValidityConstraint('RESPONSE', 0, 1, '/.+/ui'); $factory = new Compact21MarshallerFactory(); @@ -162,7 +162,7 @@ public function testMarshallSimple() /** * @depends testMarshallSimple */ - public function testMarshallWithAssociationConstraints() + public function testMarshallWithAssociationConstraints(): void { $component = new ResponseValidityConstraint('RESPONSE', 0, 1); $component->setAssociationValidityConstraints( diff --git a/test/qtismtest/data/storage/xml/marshalling/ResponseVariableMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ResponseVariableMarshallerTest.php index 1cf63b120..8a3149b1b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ResponseVariableMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ResponseVariableMarshallerTest.php @@ -39,7 +39,7 @@ */ class ResponseVariableMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { /** @var ResultResponseVariable $resultResponseVariable */ $resultResponseVariable = $this->createComponentFromXml(' @@ -77,7 +77,7 @@ public function testUnmarshall() $this::assertEquals('value-id-1', $resultResponseVariable->getChoiceSequence()->getValue()); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { /** @var ResultResponseVariable $resultResponseVariable */ $resultResponseVariable = $this->createComponentFromXml(' @@ -110,7 +110,7 @@ public function testUnmarshallMinimal() $this::assertNull($resultResponseVariable->getChoiceSequence()); } - public function testMarshall() + public function testMarshall(): void { $component = new ResultResponseVariable( new QtiIdentifier('fixture-identifier'), @@ -147,7 +147,7 @@ public function testMarshall() $this::assertEquals(3, $element->getElementsByTagName('correctResponse')->item(0)->getElementsByTagName('value')->length); } - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $component = new ResultResponseVariable( new QtiIdentifier('fixture-identifier'), @@ -177,7 +177,7 @@ public function testMarshallMinimal() $this::assertEquals(0, $element->getElementsByTagName('correctResponse')->length); } - public function testGetExpectedQtiClassName() + public function testGetExpectedQtiClassName(): void { $component = new ResultResponseVariable( new QtiIdentifier('fixture-identifier'), diff --git a/test/qtismtest/data/storage/xml/marshalling/RoundToMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/RoundToMarshallerTest.php index e02381fc8..92bcf4cb0 100644 --- a/test/qtismtest/data/storage/xml/marshalling/RoundToMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/RoundToMarshallerTest.php @@ -16,7 +16,7 @@ */ class RoundToMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $subExpr = new ExpressionCollection([new BaseValue(BaseType::FLOAT, 24.3333)]); $component = new RoundTo($subExpr, 2); @@ -33,7 +33,7 @@ public function testMarshall() $this::assertEquals('24.3333', $subExprElts->item(0)->nodeValue); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/RubricBlockMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/RubricBlockMarshallerTest.php index bb97f2ad1..ef8d09aa3 100644 --- a/test/qtismtest/data/storage/xml/marshalling/RubricBlockMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/RubricBlockMarshallerTest.php @@ -21,7 +21,7 @@ */ class RubricBlockMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { $rubricBlock = $this->createComponentFromXml(' @@ -53,7 +53,7 @@ public function testUnmarshall() /** * @depends testUnmarshall */ - public function testUnmarshallNoViewsAttribute() + public function testUnmarshallNoViewsAttribute(): void { $this->expectException(UnmarshallingException::class); $this->expectExceptionMessage("The mandatory attribute 'views' is missing."); @@ -69,7 +69,7 @@ public function testUnmarshallNoViewsAttribute() /** * @depends testUnmarshall */ - public function testUnmarshallInvalidContent() + public function testUnmarshallInvalidContent(): void { $this->expectException(UnmarshallingException::class); $this->expectExceptionMessage("The 'rubricBlock' cannot contain 'choiceInteraction' elements."); @@ -86,7 +86,7 @@ public function testUnmarshallInvalidContent() /** * @depends testUnmarshall */ - public function testUnmarshallApipAccessibilityInRubricBlock() + public function testUnmarshallApipAccessibilityInRubricBlock(): void { $rubricBlock = $this->createComponentFromXml(' @@ -100,7 +100,7 @@ public function testUnmarshallApipAccessibilityInRubricBlock() $this::assertInstanceOf(RubricBlock::class, $rubricBlock); } - public function testMarshall() + public function testMarshall(): void { $stylesheet = new Stylesheet('./stylesheet.css'); diff --git a/test/qtismtest/data/storage/xml/marshalling/RubricBlockRefMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/RubricBlockRefMarshallerTest.php index 9912d445f..fe64efe02 100644 --- a/test/qtismtest/data/storage/xml/marshalling/RubricBlockRefMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/RubricBlockRefMarshallerTest.php @@ -12,7 +12,7 @@ */ class RubricBlockRefMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $component = new RubricBlockRef('R01', './R01.xml'); $marshaller = (new Compact21MarshallerFactory('2.1.0'))->createMarshaller($component); @@ -23,7 +23,7 @@ public function testMarshall() $this::assertEquals('./R01.xml', $elt->getAttribute('href')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/SectionPartMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SectionPartMarshallerTest.php index e26f6cdcb..4c25f0ca2 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SectionPartMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SectionPartMarshallerTest.php @@ -12,7 +12,7 @@ */ class SectionPartMarshallerTest extends QtiSmTestCase { - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $identifier = 'mySectionPart1'; @@ -25,7 +25,7 @@ public function testMarshallMinimal() $this::assertEquals($identifier, $element->getAttribute('identifier')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/SelectPointInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SelectPointInteractionMarshallerTest.php index fdbb95e98..736506ae5 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SelectPointInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SelectPointInteractionMarshallerTest.php @@ -16,7 +16,7 @@ */ class SelectPointInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $object = new ObjectElement('./myimg.png', 'image/png'); $prompt = new Prompt(); @@ -40,7 +40,7 @@ public function testMarshall21() /** * @depends testMarshall21 */ - public function testMarshall20() + public function testMarshall20(): void { // Make sure minChoices is not in the output in a QTI 2.0 context. $object = new ObjectElement('./myimg.png', 'image/png'); @@ -55,7 +55,7 @@ public function testMarshall20() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement( ' @@ -83,7 +83,7 @@ public function testUnmarshall21() /** * @depends testUnmarshall21 */ - public function testUnmarshall21NoObject() + public function testUnmarshall21NoObject(): void { $element = $this->createDOMElement(' @@ -100,7 +100,7 @@ public function testUnmarshall21NoObject() /** * @depends testUnmarshall21 */ - public function testUnmarshall21NoResponseIdentifier() + public function testUnmarshall21NoResponseIdentifier(): void { $element = $this->createDOMElement(' @@ -118,7 +118,7 @@ public function testUnmarshall21NoResponseIdentifier() /** * @depends testUnmarshall21 */ - public function testUnmarshall20() + public function testUnmarshall20(): void { // Make sure minChoices is not taken into account. $element = $this->createDOMElement(' @@ -134,7 +134,7 @@ public function testUnmarshall20() /** * @depends testUnmarshall21 */ - public function testUnmarshall20MissingMaxChoices() + public function testUnmarshall20MissingMaxChoices(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/SelectionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SelectionMarshallerTest.php index 40283350d..20f23ef8c 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SelectionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SelectionMarshallerTest.php @@ -13,7 +13,7 @@ */ class SelectionMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $select = 2; $withReplacement = true; @@ -32,7 +32,7 @@ public function testMarshall() $this::assertEquals(0, $element->childNodes->length); } - public function testMarshallWithExternalData() + public function testMarshallWithExternalData(): void { $select = 2; $withReplacement = true; @@ -53,7 +53,7 @@ public function testMarshallWithExternalData() $this::assertEquals('', $element->ownerDocument->saveXML($element)); } - public function testUnmarshallValid() + public function testUnmarshallValid(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -67,7 +67,7 @@ public function testUnmarshallValid() $this::assertTrue($component->isWithReplacement()); } - public function testUnmarshallValidTwo() + public function testUnmarshallValidTwo(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -81,7 +81,7 @@ public function testUnmarshallValidTwo() $this::assertFalse($component->isWithReplacement()); } - public function testUnmarshallValidWithExtension() + public function testUnmarshallValidWithExtension(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(' @@ -109,7 +109,7 @@ public function testUnmarshallValidWithExtension() $this::assertEquals(1, $component->getXml()->documentElement->getElementsByTagNameNS('http://www.taotesting.com/xsd/ais_v1p0p0', 'qtiMetadataRef')->length); } - public function testUnmarshallInvalid() + public function testUnmarshallInvalid(): void { $dom = new DOMDocument('1.0', 'UTF-8'); // the mandatory 'select' attribute is missing in the following test. diff --git a/test/qtismtest/data/storage/xml/marshalling/SessionIdentifierMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SessionIdentifierMarshallerTest.php index ff009c605..2fc1ce0d8 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SessionIdentifierMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SessionIdentifierMarshallerTest.php @@ -35,7 +35,7 @@ */ class SessionIdentifierMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { /** @var SessionIdentifier $sessionIdentifier */ $sessionIdentifier = $this->createComponentFromXml( @@ -53,7 +53,7 @@ public function testUnmarshall() $this::assertEquals('fixture-id', $sessionIdentifier->getIdentifier()); } - public function testMarshall() + public function testMarshall(): void { $sourceID = 'fixture-sourceID'; $id = 'fixture-id'; @@ -68,7 +68,7 @@ public function testMarshall() $this::assertEquals($id, $element->getAttribute('identifier')); } - public function testGetExpectedQtiClassName() + public function testGetExpectedQtiClassName(): void { $sourceID = 'fixture-sourceID'; $id = 'fixture-id'; @@ -78,7 +78,7 @@ public function testGetExpectedQtiClassName() $this::assertEquals($component->getQtiClassName(), $marshaller->getExpectedQtiClassName()); } - public function testWrongSessionIdentifierIdentifier() + public function testWrongSessionIdentifierIdentifier(): void { $this->expectException(UnmarshallingException::class); @@ -87,7 +87,7 @@ public function testWrongSessionIdentifierIdentifier() $this->getMarshallerFactory()->createMarshaller($element)->unmarshall($element); } - public function testWrongSessionIdentifierSourceID() + public function testWrongSessionIdentifierSourceID(): void { $this->expectException(UnmarshallingException::class); @@ -96,7 +96,7 @@ public function testWrongSessionIdentifierSourceID() $this->getMarshallerFactory()->createMarshaller($element)->unmarshall($element); } - public function testEmptySessionIdentifier() + public function testEmptySessionIdentifier(): void { $this->expectException(UnmarshallingException::class); diff --git a/test/qtismtest/data/storage/xml/marshalling/SetCorrectResponseMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SetCorrectResponseMarshallerTest.php index 84af9b7e8..5de40cb1b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SetCorrectResponseMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SetCorrectResponseMarshallerTest.php @@ -16,7 +16,7 @@ */ class SetCorrectResponseMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $variableExpr = new Variable('var1'); $boolExpr = new BaseValue(BaseType::BOOLEAN, true); @@ -31,7 +31,7 @@ public function testMarshall() $this::assertEquals('true', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/SetDefaultValueMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SetDefaultValueMarshallerTest.php index 57d7de6ca..b7d28be5f 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SetDefaultValueMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SetDefaultValueMarshallerTest.php @@ -16,7 +16,7 @@ */ class SetDefaultValueMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $variableExpr = new Variable('var1'); $boolExpr = new BaseValue(BaseType::BOOLEAN, true); @@ -31,7 +31,7 @@ public function testMarshall() $this::assertEquals('true', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/SetOutcomeValueMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SetOutcomeValueMarshallerTest.php index 6168e3cdb..367069b87 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SetOutcomeValueMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SetOutcomeValueMarshallerTest.php @@ -14,7 +14,7 @@ */ class SetOutcomeValueMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $identifier = 'variable1'; @@ -28,7 +28,7 @@ public function testMarshall() $this::assertEquals($identifier, $element->getAttribute('identifier')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/SetTemplateValueMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SetTemplateValueMarshallerTest.php index d5eb3d55c..e5f6921f1 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SetTemplateValueMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SetTemplateValueMarshallerTest.php @@ -16,7 +16,7 @@ */ class SetTemplateValueMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $variableExpr = new Variable('var1'); $boolExpr = new BaseValue(BaseType::BOOLEAN, true); @@ -31,7 +31,7 @@ public function testMarshall() $this::assertEquals('true', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/ShufflingGroupMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ShufflingGroupMarshallerTest.php index 5827582b3..bf45420a9 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ShufflingGroupMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ShufflingGroupMarshallerTest.php @@ -15,7 +15,7 @@ */ class ShufflingGroupMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $component = new ShufflingGroup(new IdentifierCollection(['id1', 'id2', 'id3'])); $component->setFixedIdentifiers(new IdentifierCollection(['id2'])); @@ -28,7 +28,7 @@ public function testMarshall() $this::assertEquals('id2', $element->getAttribute('fixedIdentifiers')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -43,7 +43,7 @@ public function testUnmarshall() $this::assertEquals(['id2'], $component->getFixedIdentifiers()->getArrayCopy()); } - public function testUnmarshallMissingIdentifiersAttribute() + public function testUnmarshallMissingIdentifiersAttribute(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/ShufflingMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ShufflingMarshallerTest.php index d42c1c18a..0b375b3e5 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ShufflingMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ShufflingMarshallerTest.php @@ -15,7 +15,7 @@ */ class ShufflingMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $shufflingGroup1 = new ShufflingGroup(new IdentifierCollection(['id1', 'id2', 'id3'])); $shufflingGroup2 = new ShufflingGroup(new IdentifierCollection(['id4', 'id5', 'id6'])); @@ -30,7 +30,7 @@ public function testMarshall() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/SimpleAssociableChoiceMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SimpleAssociableChoiceMarshallerTest.php index 449387754..2b66642ea 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SimpleAssociableChoiceMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SimpleAssociableChoiceMarshallerTest.php @@ -18,7 +18,7 @@ */ class SimpleAssociableChoiceMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $simpleChoice = new SimpleAssociableChoice('choice_1', 1); $simpleChoice->setClass('qti-simpleAssociableChoice'); @@ -38,7 +38,7 @@ public function testMarshall21() /** * @depends testMarshall21 */ - public function testMarshallMatchMin21() + public function testMarshallMatchMin21(): void { $simpleChoice = new SimpleAssociableChoice('choice_1', 3); $simpleChoice->setMatchMin(2); @@ -56,7 +56,7 @@ public function testMarshallMatchMin21() /** * @depends testMarshall21 */ - public function testMarshallMatchGroup21() + public function testMarshallMatchGroup21(): void { // Aims at testing that matchGroup attribute is not // in the output in a QTI 2.1 context. @@ -73,7 +73,7 @@ public function testMarshallMatchGroup21() $this::assertEquals('Choice #1', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' This is ... strong! @@ -98,7 +98,7 @@ public function testUnmarshall21() /** * @depends testUnmarshall21 */ - public function testUnmarshallMatchGroup21() + public function testUnmarshallMatchGroup21(): void { // Aims at testing that matchGroup attribute // as no influence at unmarshalling time in a QTI 2.1 context. @@ -116,7 +116,7 @@ public function testUnmarshallMatchGroup21() /** * @depends testUnmarshall21 */ - public function testUnmarshall21NoMatchMax() + public function testUnmarshall21NoMatchMax(): void { $element = $this->createDOMElement(' Choice #1 @@ -133,7 +133,7 @@ public function testUnmarshall21NoMatchMax() /** * @depends testUnmarshall21 */ - public function testUnmarshall21NoIdentifier() + public function testUnmarshall21NoIdentifier(): void { $element = $this->createDOMElement(' This is ... strong! @@ -147,7 +147,7 @@ public function testUnmarshall21NoIdentifier() $marshaller->unmarshall($element); } - public function testMarshall20() + public function testMarshall20(): void { $simpleChoice = new SimpleAssociableChoice('choice_1', 1); $simpleChoice->setContent(new FlowStaticCollection([new TextRun('Choice #1')])); @@ -163,7 +163,7 @@ public function testMarshall20() /** * @depends testMarshall20 */ - public function testMarshallNoTemplateIdentifierNoShowHideNoMatchMin20() + public function testMarshallNoTemplateIdentifierNoShowHideNoMatchMin20(): void { // Aims at testing that attributes templateIdentifier, showHide, matchMin // are never in the output in a QTI 2.0 context. @@ -184,7 +184,7 @@ public function testMarshallNoTemplateIdentifierNoShowHideNoMatchMin20() /** * @depends testMarshall20 */ - public function testMarshallMatchGroup20() + public function testMarshallMatchGroup20(): void { // Aims at testing that matchGroup is in the output // in a QTI 2.0 context. @@ -200,7 +200,7 @@ public function testMarshallMatchGroup20() $this::assertEquals('Choice #1', $dom->saveXML($element)); } - public function testUnmarshall20() + public function testUnmarshall20(): void { $element = $this->createDOMElement(' Choice #1 @@ -222,7 +222,7 @@ public function testUnmarshall20() /** * @depends testUnmarshall20 */ - public function testUnmarshallNoTemplateIdentifierShowHideMatchMinInfluence20() + public function testUnmarshallNoTemplateIdentifierShowHideMatchMinInfluence20(): void { // Aims at testing that matchMin, showHide and templateIdentifier attributes // have no influence in a QTI 2.0 context. diff --git a/test/qtismtest/data/storage/xml/marshalling/SimpleChoiceMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SimpleChoiceMarshallerTest.php index f52e16554..6dd602c33 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SimpleChoiceMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SimpleChoiceMarshallerTest.php @@ -16,7 +16,7 @@ */ class SimpleChoiceMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $simpleChoice = new SimpleChoice('choice_1'); $simpleChoice->setClass('qti-simpleChoice'); @@ -32,7 +32,7 @@ public function testMarshall21() $this::assertEquals('This is ... strong!', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' This is ... strong! @@ -50,7 +50,7 @@ public function testUnmarshall21() $this::assertCount(3, $content); } - public function testMarshallSimple20() + public function testMarshallSimple20(): void { $simpleChoice = new SimpleChoice('choice_1'); $simpleChoice->setContent(new FlowStaticCollection([new TextRun('Choice #1')])); @@ -66,7 +66,7 @@ public function testMarshallSimple20() /** * @depends testMarshallSimple20 */ - public function testMarshallNoTemplateIdentifierNoShowHide20() + public function testMarshallNoTemplateIdentifierNoShowHide20(): void { // Aims at testing that templateIdentifier and showHide attributes // are not taken into accoun in a QTI 2.0 context. @@ -84,7 +84,7 @@ public function testMarshallNoTemplateIdentifierNoShowHide20() $this::assertEquals('Choice #1', $dom->saveXML($element)); } - public function testUnmarshallSimple20() + public function testUnmarshallSimple20(): void { $element = $this->createDOMElement(' Choice #1 @@ -106,7 +106,7 @@ public function testUnmarshallSimple20() /** * @depends testUnmarshallSimple20 */ - public function testUnmarshallNoTemplateIdentifierNoShowHide20() + public function testUnmarshallNoTemplateIdentifierNoShowHide20(): void { // Aims at testing that templateIdentifier and showHide attribute have // no effect in a QTI 2.0 context. diff --git a/test/qtismtest/data/storage/xml/marshalling/SimpleInlineMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SimpleInlineMarshallerTest.php index f6126b4fa..845be512e 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SimpleInlineMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SimpleInlineMarshallerTest.php @@ -24,7 +24,7 @@ */ class SimpleInlineMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $strong = new Strong('john'); $strong->setLabel('His name'); @@ -42,7 +42,7 @@ public function testMarshall21() $this::assertEquals('He is John Dunbar.', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML('He is John Dunbar.'); @@ -72,7 +72,7 @@ public function testUnmarshall21() $this::assertEquals('.', $sentence[2]->getContent()); } - public function testUnmarshall21MissingHref() + public function testUnmarshall21MissingHref(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML('QTI-SDK'); @@ -86,7 +86,7 @@ public function testUnmarshall21MissingHref() $a = $marshaller->unmarshall($element); } - public function testMarshallQandA21() + public function testMarshallQandA21(): void { $q = new Q('albert-einstein'); @@ -103,7 +103,7 @@ public function testMarshallQandA21() $this::assertEquals('Albert Einstein is a physicist.', $dom->saveXML($element)); } - public function testUnmarshallQandA21() + public function testUnmarshallQandA21(): void { $q = $this->createComponentFromXml('Albert Einstein is a physicist.'); $this::assertInstanceOf(Q::class, $q); @@ -111,7 +111,7 @@ public function testUnmarshallQandA21() $this::assertEquals('/home/jerome', $q->getXmlBase()); } - public function testUnmarshall22Ltr() + public function testUnmarshall22Ltr(): void { $q = $this->createComponentFromXml(' @@ -124,7 +124,7 @@ public function testUnmarshall22Ltr() $this::assertEquals(Direction::LTR, $q->getDir()); } - public function testUnmarshall22Rtl() + public function testUnmarshall22Rtl(): void { $q = $this->createComponentFromXml(' @@ -135,7 +135,7 @@ public function testUnmarshall22Rtl() $this::assertEquals(Direction::RTL, $q->getDir()); } - public function testUnmarshall22DirAuto() + public function testUnmarshall22DirAuto(): void { $q = $this->createComponentFromXml(' @@ -146,7 +146,7 @@ public function testUnmarshall22DirAuto() $this::assertEquals(Direction::AUTO, $q->getDir()); } - public function testUnmarshall21DirAuto() + public function testUnmarshall21DirAuto(): void { $q = $this->createComponentFromXml(' @@ -157,7 +157,7 @@ public function testUnmarshall21DirAuto() $this::assertEquals(Direction::AUTO, $q->getDir()); } - public function testMarshall22Rtl() + public function testMarshall22Rtl(): void { $q = new Q('albert'); $q->setDir(Direction::RTL); @@ -170,7 +170,7 @@ public function testMarshall22Rtl() $this::assertEquals('', $dom->saveXML($element)); } - public function testMarshall21Rtl() + public function testMarshall21Rtl(): void { $q = new Q('albert'); $q->setDir(Direction::RTL); @@ -183,7 +183,7 @@ public function testMarshall21Rtl() $this::assertEquals('', $dom->saveXML($element)); } - public function testMarshall20Rtl() + public function testMarshall20Rtl(): void { $q = new Q('albert'); $q->setDir(Direction::RTL); @@ -196,7 +196,7 @@ public function testMarshall20Rtl() $this::assertEquals('', $dom->saveXML($element)); } - public function testMarshall22Ltr() + public function testMarshall22Ltr(): void { $q = new Q('albert'); $q->setDir(Direction::LTR); @@ -209,7 +209,7 @@ public function testMarshall22Ltr() $this::assertEquals('', $dom->saveXML($element)); } - public function testMarshall22DirAuto() + public function testMarshall22DirAuto(): void { $q = new Q('albert'); $q->setDir(Direction::AUTO); @@ -222,7 +222,7 @@ public function testMarshall22DirAuto() $this::assertEquals('', $dom->saveXML($element)); } - public function testMarshallBdo22() + public function testMarshallBdo22(): void { $bdo = new Bdo('bido'); $bdo->setDir(Direction::RTL); @@ -234,7 +234,7 @@ public function testMarshallBdo22() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshallBdo22() + public function testUnmarshallBdo22(): void { $bdo = $this->createComponentFromXml('I am reversed!', '2.2.0'); $this::assertEquals(Direction::RTL, $bdo->getDir()); @@ -248,7 +248,7 @@ public function testUnmarshallBdo22() /** * @throws MarshallerNotFoundException|MarshallingException */ - public function testMarshallSpan21() + public function testMarshallSpan21(): void { $span = new Span('myspan', 'myclass'); $span->setAriaControls('IDREF1'); @@ -271,7 +271,7 @@ public function testMarshallSpan21() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshallSpan21() + public function testUnmarshallSpan21(): void { // In QTI 2.1, aria-* and dir must be ignored. @@ -311,7 +311,7 @@ public function testUnmarshallSpan21() /** * @throws MarshallerNotFoundException|MarshallingException */ - public function testMarshallSpan22() + public function testMarshallSpan22(): void { $span = new Span('myspan', 'myclass'); $span->setAriaLabel('my aria label'); @@ -338,7 +338,7 @@ public function testMarshallSpan22() ); } - public function testUnmarshallSpan22() + public function testUnmarshallSpan22(): void { /** @var Span $span */ $span = $this->createComponentFromXml( diff --git a/test/qtismtest/data/storage/xml/marshalling/SimpleMatchSetMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SimpleMatchSetMarshallerTest.php index d52cfae9d..ede84a5a7 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SimpleMatchSetMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SimpleMatchSetMarshallerTest.php @@ -15,7 +15,7 @@ */ class SimpleMatchSetMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $associableChoice1 = new SimpleAssociableChoice('choice1', 1); $associableChoice1->setContent(new FlowStaticCollection([new TextRun('This is choice1')])); @@ -33,7 +33,7 @@ public function testMarshall() $this::assertEquals('This is choice1This is choice2', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' This is choice1This is choice2 diff --git a/test/qtismtest/data/storage/xml/marshalling/SliderInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SliderInteractionMarshallerTest.php index f4b2128ec..278481578 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SliderInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SliderInteractionMarshallerTest.php @@ -16,7 +16,7 @@ */ class SliderInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $sliderInteraction = new SliderInteraction('RESPONSE', 0.0, 100.0, 'my-slider', 'slide-it'); $sliderInteraction->setStep(1); @@ -39,7 +39,7 @@ public function testMarshall() ); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' @@ -66,7 +66,7 @@ public function testUnmarshall() /** * @depends testUnmarshall */ - public function testUnmarshallWrongOrientationValue() + public function testUnmarshallWrongOrientationValue(): void { $element = $this->createDOMElement(' @@ -83,7 +83,7 @@ public function testUnmarshallWrongOrientationValue() /** * @depends testUnmarshall */ - public function testUnmarshallNoUpperBound() + public function testUnmarshallNoUpperBound(): void { $element = $this->createDOMElement(' @@ -100,7 +100,7 @@ public function testUnmarshallNoUpperBound() /** * @depends testUnmarshall */ - public function testUnmarshallNoLowerBound() + public function testUnmarshallNoLowerBound(): void { $element = $this->createDOMElement(' @@ -117,7 +117,7 @@ public function testUnmarshallNoLowerBound() /** * @depends testUnmarshall */ - public function testUnmarshallNoResponseIdentifier() + public function testUnmarshallNoResponseIdentifier(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/StatsOperatorMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/StatsOperatorMarshallerTest.php index 29f6431e1..fa49b2d3a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/StatsOperatorMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/StatsOperatorMarshallerTest.php @@ -16,7 +16,7 @@ */ class StatsOperatorMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $subExpr = new ExpressionCollection([new BaseValue(BaseType::FLOAT, 12.5468)]); $name = Statistics::POP_VARIANCE; @@ -34,7 +34,7 @@ public function testMarshall() $this::assertEquals('12.5468', $subExprElts->item(0)->nodeValue); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/StringMatchMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/StringMatchMarshallerTest.php index 81c78da43..f9cc5c650 100644 --- a/test/qtismtest/data/storage/xml/marshalling/StringMatchMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/StringMatchMarshallerTest.php @@ -15,7 +15,7 @@ */ class StringMatchMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $subs = new ExpressionCollection(); $subs[] = new BaseValue(BaseType::STRING, 'hell'); @@ -32,7 +32,7 @@ public function testMarshall() $this::assertEquals(2, $element->getElementsByTagName('baseValue')->length); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/StylesheetMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/StylesheetMarshallerTest.php index e81ca7c2b..51d6fc98d 100644 --- a/test/qtismtest/data/storage/xml/marshalling/StylesheetMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/StylesheetMarshallerTest.php @@ -12,7 +12,7 @@ */ class StylesheetMarshallerTest extends QtiSmTestCase { - public function testMarshallOne() + public function testMarshallOne(): void { $uri = 'http://myuri.com'; $type = 'text/css'; @@ -35,7 +35,7 @@ public function testMarshallOne() $this::assertEquals($title, $element->getAttribute('title')); } - public function testMarshallTwo() + public function testMarshallTwo(): void { $uri = 'http://myuri.com'; @@ -52,7 +52,7 @@ public function testMarshallTwo() $this::assertFalse($element->hasAttribute('title')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/SubstringMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/SubstringMarshallerTest.php index 104afa6d2..a86ee5821 100644 --- a/test/qtismtest/data/storage/xml/marshalling/SubstringMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/SubstringMarshallerTest.php @@ -15,7 +15,7 @@ */ class SubstringMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $expr = [new BaseValue(BaseType::STRING, 'Hell'), new BaseValue(BaseType::STRING, 'Shell')]; $component = new Substring(new ExpressionCollection($expr), false); @@ -35,7 +35,7 @@ public function testMarshall() $this::assertEquals('string', $sub->getAttribute('baseType')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/TableMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TableMarshallerTest.php index 96213653d..9fb003604 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TableMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TableMarshallerTest.php @@ -30,7 +30,7 @@ */ class TableMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $th1 = new Th('firstname'); $th1->setContent(new FlowCollection([new TextRun('First Name')])); @@ -120,7 +120,7 @@ public function testMarshall() $this::assertEquals($expected, $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $table = $this->createComponentFromXml(' @@ -214,7 +214,7 @@ public function testUnmarshall() /** * @depends testUnmarshall */ - public function testUnmarshallNoTbody() + public function testUnmarshallNoTbody(): void { $this->expectException(UnmarshallingException::class); $this->expectExceptionMessage("A 'table' element must contain at lease one 'tbody' element."); diff --git a/test/qtismtest/data/storage/xml/marshalling/TemplateBlockMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TemplateBlockMarshallerTest.php index 31927c147..2f7fc8ecb 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TemplateBlockMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TemplateBlockMarshallerTest.php @@ -17,7 +17,7 @@ */ class TemplateBlockMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $templateBlock = new TemplateBlock('tpl1', 'block1'); $div = new Div(); @@ -34,7 +34,7 @@ public function testMarshall() /** * @depends testMarshall */ - public function testMarshallXmlBase() + public function testMarshallXmlBase(): void { $templateBlock = new TemplateBlock('tpl1', 'block1'); $div = new Div(); @@ -49,7 +49,7 @@ public function testMarshallXmlBase() $this::assertEquals('
    Templatable...
    ', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement('
    Templatable...
    @@ -65,7 +65,7 @@ public function testUnmarshall() /** * @depends testUnmarshall */ - public function testUnmarshallInvalidShowHide() + public function testUnmarshallInvalidShowHide(): void { $element = $this->createDOMElement('
    Templatable...
    @@ -80,7 +80,7 @@ public function testUnmarshallInvalidShowHide() /** * @depends testUnmarshall */ - public function testUnmarshallInvalidContent() + public function testUnmarshallInvalidContent(): void { $element = $this->createDOMElement(' @@ -95,7 +95,7 @@ public function testUnmarshallInvalidContent() /** * @depends testUnmarshall */ - public function testUnmarshallNoTemplateIdentifier() + public function testUnmarshallNoTemplateIdentifier(): void { $element = $this->createDOMElement(' Templatable... @@ -110,7 +110,7 @@ public function testUnmarshallNoTemplateIdentifier() /** * @depends testUnmarshall */ - public function testUnmarshallXmlBase() + public function testUnmarshallXmlBase(): void { $element = $this->createDOMElement('
    Templatable...
    diff --git a/test/qtismtest/data/storage/xml/marshalling/TemplateConditionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TemplateConditionMarshallerTest.php index e3cd7a0fa..7c699b036 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TemplateConditionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TemplateConditionMarshallerTest.php @@ -27,7 +27,7 @@ */ class TemplateConditionMarshallerTest extends QtiSmTestCase { - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $true = new BaseValue(BaseType::BOOLEAN, true); $setTemplateValue = new SetTemplateValue('tpl1', new BaseValue(BaseType::INTEGER, 1337)); @@ -41,7 +41,7 @@ public function testMarshallMinimal() $this::assertEquals('true1337', $dom->saveXML($element)); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { $element = $this->createDOMElement(' @@ -76,7 +76,7 @@ public function testUnmarshallMinimal() $this::assertEquals(1337, $templateRules[0]->getExpression()->getValue()); } - public function testMarshallElseIfMinimal() + public function testMarshallElseIfMinimal(): void { $true = new BaseValue(BaseType::BOOLEAN, true); $setTemplateValue = new SetTemplateValue('tpl1', new BaseValue(BaseType::INTEGER, 1337)); @@ -98,7 +98,7 @@ public function testMarshallElseIfMinimal() ); } - public function testUnMarshallElseIfMinimal() + public function testUnMarshallElseIfMinimal(): void { $element = $this->createDOMElement(' @@ -149,7 +149,7 @@ public function testUnMarshallElseIfMinimal() $this::assertInstanceOf(ExitTemplate::class, $templateRules[0]); } - public function testMarshallIfElseMinimal() + public function testMarshallIfElseMinimal(): void { $true = new BaseValue(BaseType::BOOLEAN, true); $setTemplateValue = new SetTemplateValue('tpl1', new BaseValue(BaseType::INTEGER, 1337)); @@ -171,7 +171,7 @@ public function testMarshallIfElseMinimal() ); } - public function testUnmarshallIfElseMinimal() + public function testUnmarshallIfElseMinimal(): void { $element = $this->createDOMElement(' @@ -223,7 +223,7 @@ public function testUnmarshallIfElseMinimal() $this::assertEquals('einstein', $setCorrectResponse->getExpression()->getValue()); } - public function testUnmarshallUnleashTheBeast() + public function testUnmarshallUnleashTheBeast(): void { $element = $this->createDOMElement(' @@ -473,7 +473,7 @@ public function testUnmarshallUnleashTheBeast() $this::assertTrue($templateRules[0]->getExpression()->getValue()); } - public function testMarshallUnleashTheBeast() + public function testMarshallUnleashTheBeast(): void { // Same structure as testUnmarshallUnleashTheBeast. diff --git a/test/qtismtest/data/storage/xml/marshalling/TemplateConstraintMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TemplateConstraintMarshallerTest.php index 1a738dec9..7f7dd986a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TemplateConstraintMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TemplateConstraintMarshallerTest.php @@ -14,7 +14,7 @@ */ class TemplateConstraintMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $rand1 = new RandomInteger(0, 5); $rand2 = new RandomInteger(0, 5); @@ -30,7 +30,7 @@ public function testMarshall() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/TemplateControlMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TemplateControlMarshallerTest.php index 9dba5f0b0..c9bb9935a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TemplateControlMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TemplateControlMarshallerTest.php @@ -17,7 +17,7 @@ */ class TemplateControlMarshallerTest extends QtiSmTestCase { - public function testMarshallTemplateIfSimple() + public function testMarshallTemplateIfSimple(): void { $true = new BaseValue(BaseType::BOOLEAN, true); $setTemplateValue = new SetTemplateValue('tpl1', new BaseValue(BaseType::INTEGER, 1337)); @@ -30,7 +30,7 @@ public function testMarshallTemplateIfSimple() $this::assertEquals('true1337', $dom->saveXML($element)); } - public function testUnmarshallTemplateIfSimple() + public function testUnmarshallTemplateIfSimple(): void { $element = $this->createDOMElement(' @@ -50,7 +50,7 @@ public function testUnmarshallTemplateIfSimple() $this::assertInstanceOf(BaseValue::class, $templateRules[0]->getExpression()); } - public function testMarshallTemplateIfMultipleRules() + public function testMarshallTemplateIfMultipleRules(): void { $true = new BaseValue(BaseType::BOOLEAN, true); $setTemplateValue1 = new SetTemplateValue('tpl1', new BaseValue(BaseType::INTEGER, 1337)); @@ -67,7 +67,7 @@ public function testMarshallTemplateIfMultipleRules() ); } - public function testUnmarshallTemplateIfMultipleRules() + public function testUnmarshallTemplateIfMultipleRules(): void { $element = $this->createDOMElement(' @@ -99,7 +99,7 @@ public function testUnmarshallTemplateIfMultipleRules() $this::assertEquals(1338, $templateRules[1]->getExpression()->getValue()); } - public function testMarshallTemplateElseIfSimple() + public function testMarshallTemplateElseIfSimple(): void { $true = new BaseValue(BaseType::BOOLEAN, true); $setTemplateValue = new SetTemplateValue('tpl1', new BaseValue(BaseType::INTEGER, 1337)); @@ -112,7 +112,7 @@ public function testMarshallTemplateElseIfSimple() $this::assertEquals('true1337', $dom->saveXML($element)); } - public function testUnmarshallTemplateElseIfSimple() + public function testUnmarshallTemplateElseIfSimple(): void { $element = $this->createDOMElement(' @@ -132,7 +132,7 @@ public function testUnmarshallTemplateElseIfSimple() $this::assertInstanceOf(BaseValue::class, $templateRules[0]->getExpression()); } - public function testMarshallTemplateElseSimple() + public function testMarshallTemplateElseSimple(): void { $setTemplateValue = new SetTemplateValue('tpl1', new BaseValue(BaseType::INTEGER, 1337)); $templateIf = new TemplateElse(new TemplateRuleCollection([$setTemplateValue])); @@ -144,7 +144,7 @@ public function testMarshallTemplateElseSimple() $this::assertEquals('1337', $dom->saveXML($element)); } - public function testUnmarshallTemplateElseSimple() + public function testUnmarshallTemplateElseSimple(): void { $element = $this->createDOMElement(' @@ -162,7 +162,7 @@ public function testUnmarshallTemplateElseSimple() $this::assertInstanceOf(BaseValue::class, $templateRules[0]->getExpression()); } - public function testMarshallTemplateElseMultipleRules() + public function testMarshallTemplateElseMultipleRules(): void { $setTemplateValue1 = new SetTemplateValue('tpl1', new BaseValue(BaseType::INTEGER, 1337)); $setTemplateValue2 = new SetTemplateValue('tpl2', new BaseValue(BaseType::INTEGER, 1338)); diff --git a/test/qtismtest/data/storage/xml/marshalling/TemplateDeclarationMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TemplateDeclarationMarshallerTest.php index a3b525940..9f5018893 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TemplateDeclarationMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TemplateDeclarationMarshallerTest.php @@ -18,7 +18,7 @@ */ class TemplateDeclarationMarshallerTest extends QtiSmTestCase { - public function testMarshall21() + public function testMarshall21(): void { $values = new ValueCollection([new Value('tplx', BaseType::IDENTIFIER)]); $defaultValue = new DefaultValue($values); @@ -30,7 +30,7 @@ public function testMarshall21() $this::assertEquals('tplx', $dom->saveXML($element)); } - public function testUnmarshall21() + public function testUnmarshall21(): void { $element = $this->createDOMElement(' tplx @@ -49,7 +49,7 @@ public function testUnmarshall21() $this::assertEquals('tplx', $values[0]->getValue()); } - public function testMarshallHtmlEntities21() + public function testMarshallHtmlEntities21(): void { $values = new ValueCollection([new Value('non breaking space', BaseType::STRING)]); $defaultValue = new DefaultValue($values); @@ -61,7 +61,7 @@ public function testMarshallHtmlEntities21() $this::assertEquals('non&nbsp;breaking&nbsp;space', $dom->saveXML($element)); } - public function testUnmarshallHtmlEntities21() + public function testUnmarshallHtmlEntities21(): void { $element = $this->createDOMElement(' non&nbsp;breaking&nbsp;space @@ -80,7 +80,7 @@ public function testUnmarshallHtmlEntities21() $this::assertEquals('non breaking space', $values[0]->getValue()); } - public function testMarshall20() + public function testMarshall20(): void { // Make sure that paramVariable and mathVariable appear in output even // if their value is false. In QTI 2.0, these attributes are required. @@ -95,7 +95,7 @@ public function testMarshall20() $this::assertEquals('tplx', $dom->saveXML($element)); } - public function testUnmarshall20NoParamVariable() + public function testUnmarshall20NoParamVariable(): void { $element = $this->createDOMElement(' tplx @@ -107,7 +107,7 @@ public function testUnmarshall20NoParamVariable() $component = $this->getMarshallerFactory('2.0.0')->createMarshaller($element)->unmarshall($element); } - public function testUnmarshall20NoMathVariable() + public function testUnmarshall20NoMathVariable(): void { $element = $this->createDOMElement(' tplx diff --git a/test/qtismtest/data/storage/xml/marshalling/TemplateDefaultMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TemplateDefaultMarshallerTest.php index d3aa84425..54a3630cc 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TemplateDefaultMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TemplateDefaultMarshallerTest.php @@ -13,7 +13,7 @@ */ class TemplateDefaultMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $templateIdentifier = 'myTemplate1'; $expression = new NullValue(); @@ -32,7 +32,7 @@ public function testMarshall() $this::assertEquals('null', $expressionElt->nodeName); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/TemplateInlineMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TemplateInlineMarshallerTest.php index 3ac61fb15..4ccc5b8ad 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TemplateInlineMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TemplateInlineMarshallerTest.php @@ -15,7 +15,7 @@ */ class TemplateInlineMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $templateInline = new TemplateInline('tpl1', 'inline1'); $templateInline->setContent(new InlineStaticCollection([new TextRun('Inline ...')])); @@ -27,7 +27,7 @@ public function testMarshall() $this::assertEquals('Inline ...', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' Inline ... @@ -47,7 +47,7 @@ public function testUnmarshall() /** * @depends testUnmarshall */ - public function testUnmarshallInvalidContent() + public function testUnmarshallInvalidContent(): void { $element = $this->createDOMElement('
    Block Content
    diff --git a/test/qtismtest/data/storage/xml/marshalling/TemplateProcessingMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TemplateProcessingMarshallerTest.php index d97115ad9..39b4c791a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TemplateProcessingMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TemplateProcessingMarshallerTest.php @@ -19,7 +19,7 @@ */ class TemplateProcessingMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $templateConstraint = new TemplateConstraint(new BaseValue(BaseType::BOOLEAN, true)); $templateIf = new TemplateIf(new BaseValue(BaseType::BOOLEAN, true), new TemplateRuleCollection([new SetCorrectResponse('RESPONSE', new BaseValue(BaseType::IDENTIFIER, 'jerome'))])); @@ -37,7 +37,7 @@ public function testMarshall() ); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(' diff --git a/test/qtismtest/data/storage/xml/marshalling/TemplateVariableMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TemplateVariableMarshallerTest.php index 14109e4aa..57fde705a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TemplateVariableMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TemplateVariableMarshallerTest.php @@ -37,7 +37,7 @@ */ class TemplateVariableMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { /** @var ResultTemplateVariable $resultTemplateVariable */ $resultTemplateVariable = $this->createComponentFromXml(' @@ -63,7 +63,7 @@ public function testUnmarshall() $this::assertEquals(3, $resultTemplateVariable->getValues()->count()); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { /** @var ResultTemplateVariable $resultTemplateVariable */ $resultTemplateVariable = $this->createComponentFromXml(' @@ -84,7 +84,7 @@ public function testUnmarshallMinimal() $this::assertNull($resultTemplateVariable->getValues()); } - public function testMarshall() + public function testMarshall(): void { $component = new ResultTemplateVariable( new QtiIdentifier('fixture-identifier'), @@ -110,7 +110,7 @@ public function testMarshall() $this::assertEquals(2, $element->getElementsByTagName('value')->length); } - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $component = new ResultTemplateVariable( new QtiIdentifier('fixture-identifier'), @@ -133,7 +133,7 @@ public function testMarshallMinimal() $this::assertEquals(0, $element->getElementsByTagName('value')->length); } - public function testGetExpectedQtiClassName() + public function testGetExpectedQtiClassName(): void { $component = new ResultTemplateVariable( new QtiIdentifier('fixture-identifier'), diff --git a/test/qtismtest/data/storage/xml/marshalling/TestFeedbackMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TestFeedbackMarshallerTest.php index d88f39c47..8bd650e44 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TestFeedbackMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TestFeedbackMarshallerTest.php @@ -24,7 +24,7 @@ */ class TestFeedbackMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $identifier = 'myTestFeedBack1'; $outcomeIdentifier = 'myOutcomeIdentifier1'; @@ -57,7 +57,7 @@ public function testMarshall() $this::assertEquals(1, $content->item(0)->getElementsByTagName('p')->length); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -86,7 +86,7 @@ public function testUnmarshall() * @param string $expectedContent * @throws ReflectionException */ - public function testExtractContent($xmlData, $expectedContent) + public function testExtractContent($xmlData, $expectedContent): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML($xmlData); @@ -101,14 +101,14 @@ public function testExtractContent($xmlData, $expectedContent) /** * @return array */ - public function feedbackContent() + public function feedbackContent(): array { return [ ['

    Hello there!

    ', '

    Hello there!

    '], ]; } - public function testUnmarshallWrongContent() + public function testUnmarshallWrongContent(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(' @@ -127,7 +127,7 @@ public function testUnmarshallWrongContent() $marshaller->unmarshall($element); } - public function testUnmarshallNoAccessAttribute() + public function testUnmarshallNoAccessAttribute(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(' @@ -144,7 +144,7 @@ public function testUnmarshallNoAccessAttribute() $marshaller->unmarshall($element); } - public function testUnmarshallNoShowHideAttribute() + public function testUnmarshallNoShowHideAttribute(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(' @@ -161,7 +161,7 @@ public function testUnmarshallNoShowHideAttribute() $marshaller->unmarshall($element); } - public function testUnmarshallNoOutcomeIdentifierAttribute() + public function testUnmarshallNoOutcomeIdentifierAttribute(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(' @@ -178,7 +178,7 @@ public function testUnmarshallNoOutcomeIdentifierAttribute() $marshaller->unmarshall($element); } - public function testUnmarshallNoIdentifierAttribute() + public function testUnmarshallNoIdentifierAttribute(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(' diff --git a/test/qtismtest/data/storage/xml/marshalling/TestFeedbackRefMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TestFeedbackRefMarshallerTest.php index 3d0005efb..141f0b78b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TestFeedbackRefMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TestFeedbackRefMarshallerTest.php @@ -15,7 +15,7 @@ */ class TestFeedbackRefMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -30,7 +30,7 @@ public function testUnmarshall() $this::assertEquals('./TF01.xml', $ref->getHref()); } - public function testMarshall() + public function testMarshall(): void { $ref = new TestFeedbackRef('showme', 'SHOW_FEEDBACK', TestFeedbackAccess::DURING, ShowHide::SHOW, './TF01.xml'); $factory = new Compact21MarshallerFactory(); @@ -44,7 +44,7 @@ public function testMarshall() $this::assertEquals('./TF01.xml', $elt->getAttribute('href')); } - public function testUnmarshallMissingIdentifier() + public function testUnmarshallMissingIdentifier(): void { $this->expectException(UnmarshallingException::class); $this->expectExceptionMessage("The mandatory 'identifier' attribute is missing from element 'testFeedbackRef'"); @@ -56,7 +56,7 @@ public function testUnmarshallMissingIdentifier() $ref = $factory->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallMissingOutcomeIdentifier() + public function testUnmarshallMissingOutcomeIdentifier(): void { $this->expectException(UnmarshallingException::class); $this->expectExceptionMessage("The mandatory 'outcomeIdentifier' attribute is missing from element 'testFeedbackRef'"); @@ -68,7 +68,7 @@ public function testUnmarshallMissingOutcomeIdentifier() $ref = $factory->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallMissingAccess() + public function testUnmarshallMissingAccess(): void { $this->expectException(UnmarshallingException::class); $this->expectExceptionMessage("The mandatory 'access' attribute is missing from element 'testFeedbackRef'"); @@ -80,7 +80,7 @@ public function testUnmarshallMissingAccess() $ref = $factory->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallMissingShowHide() + public function testUnmarshallMissingShowHide(): void { $this->expectException(UnmarshallingException::class); $this->expectExceptionMessage("The mandatory 'showHide' attribute is missing from element 'testFeedbackRef'"); @@ -92,7 +92,7 @@ public function testUnmarshallMissingShowHide() $ref = $factory->createMarshaller($element)->unmarshall($element); } - public function testUnmarshallMissingHref() + public function testUnmarshallMissingHref(): void { $this->expectException(UnmarshallingException::class); $this->expectExceptionMessage("The mandatory 'href' attribute is missing from element 'testFeedbackRef'"); diff --git a/test/qtismtest/data/storage/xml/marshalling/TestPartMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TestPartMarshallerTest.php index 61235032c..4fbfabc91 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TestPartMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TestPartMarshallerTest.php @@ -19,7 +19,7 @@ */ class TestPartMarshallerTest extends QtiSmTestCase { - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $section1 = new AssessmentSection('section1', 'My Section 1', true); $section2 = new AssessmentSection('section2', 'My Section 2', false); @@ -43,7 +43,7 @@ public function testMarshallMinimal() $this::assertEquals('section2', $element->getElementsByTagName('assessmentSection')->item(1)->getAttribute('identifier')); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -71,7 +71,7 @@ public function testUnmarshallMinimal() $this::assertEquals('section2', $assessmentSections['section2']->getIdentifier()); } - public function testUnmarshallMorderate() + public function testUnmarshallMorderate(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -141,7 +141,7 @@ public function testUnmarshallMorderate() $this::assertTrue($component->hasTimeLimits()); } - public function testUnmarshallNoSections() + public function testUnmarshallNoSections(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -160,7 +160,7 @@ public function testUnmarshallNoSections() $marshaller->unmarshall($element); } - public function testUnmarshallNoSubmissionMode() + public function testUnmarshallNoSubmissionMode(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -181,7 +181,7 @@ public function testUnmarshallNoSubmissionMode() $marshaller->unmarshall($element); } - public function testUnmarshallNoNavigationMode() + public function testUnmarshallNoNavigationMode(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( @@ -202,7 +202,7 @@ public function testUnmarshallNoNavigationMode() $marshaller->unmarshall($element); } - public function testUnmarshallNoIdentifier() + public function testUnmarshallNoIdentifier(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/TestResultMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TestResultMarshallerTest.php index a09b56175..0541c1e9d 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TestResultMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TestResultMarshallerTest.php @@ -38,7 +38,7 @@ */ class TestResultMarshallerTest extends QtiSmTestCase { - public function testUnmarshall() + public function testUnmarshall(): void { /** @var TestResult $testResult */ $testResult = $this->createComponentFromXml(' @@ -65,7 +65,7 @@ public function testUnmarshall() $this::assertEquals(2, $testResult->getItemVariables()->count()); } - public function testUnmarshallMinimal() + public function testUnmarshallMinimal(): void { /** @var TestResult $testResult */ $testResult = $this->createComponentFromXml(' @@ -83,7 +83,7 @@ public function testUnmarshallMinimal() $this::assertNull($testResult->getItemVariables()); } - public function testMarshall() + public function testMarshall(): void { $component = new TestResult( new QtiIdentifier('fixture-identifier'), @@ -116,7 +116,7 @@ public function testMarshall() $this::assertEquals(1, $element->getElementsByTagName('templateVariable')->length); } - public function testMarshallMinimal() + public function testMarshallMinimal(): void { $component = new TestResult( new QtiIdentifier('fixture-identifier'), @@ -139,7 +139,7 @@ public function testMarshallMinimal() $this::assertFalse($element->hasChildNodes()); } - public function testGetExpectedQtiClassName() + public function testGetExpectedQtiClassName(): void { $component = new TestResult( new QtiIdentifier('fixture-identifier'), diff --git a/test/qtismtest/data/storage/xml/marshalling/TestVariablesMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TestVariablesMarshallerTest.php index 2d122d253..6c0bfb3c6 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TestVariablesMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TestVariablesMarshallerTest.php @@ -14,7 +14,7 @@ */ class TestVariablesMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $sectionIdentifier = 'mySection1'; $variableIdentifier = 'myVariable1'; @@ -40,7 +40,7 @@ public function testMarshall() $this::assertEquals('integer', $element->getAttribute('baseType')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/TextEntryInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TextEntryInteractionMarshallerTest.php index 6c16e49f6..646151a59 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TextEntryInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TextEntryInteractionMarshallerTest.php @@ -11,7 +11,7 @@ */ class TextEntryInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshallMinimal21() + public function testMarshallMinimal21(): void { $textEntryInteraction = new TextEntryInteraction('RESPONSE'); $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($textEntryInteraction)->marshall($textEntryInteraction); @@ -21,7 +21,7 @@ public function testMarshallMinimal21() $this::assertEquals('', $dom->saveXML($element)); } - public function testMarshallMaximal21() + public function testMarshallMaximal21(): void { $textEntryInteraction = new TextEntryInteraction('RESPONSE'); $textEntryInteraction->setBase(2); @@ -36,7 +36,7 @@ public function testMarshallMaximal21() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshallMinimal21() + public function testUnmarshallMinimal21(): void { $element = $this->createDOMElement(''); $textEntryInteraction = $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); @@ -50,7 +50,7 @@ public function testUnmarshallMinimal21() $this::assertFalse($textEntryInteraction->hasPlaceholderText()); } - public function testUnmarshallMaximal21() + public function testUnmarshallMaximal21(): void { $element = $this->createDOMElement(''); $textEntryInteraction = $this->getMarshallerFactory('2.1.0')->createMarshaller($element)->unmarshall($element); diff --git a/test/qtismtest/data/storage/xml/marshalling/TimeLimitsMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/TimeLimitsMarshallerTest.php index f71c1e365..c64aab52b 100644 --- a/test/qtismtest/data/storage/xml/marshalling/TimeLimitsMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/TimeLimitsMarshallerTest.php @@ -13,7 +13,7 @@ */ class TimeLimitsMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $minTime = new QtiDuration('PT50S'); $maxTime = new QtiDuration('PT100S'); @@ -29,7 +29,7 @@ public function testMarshall() $this::assertEquals('false', $element->getAttribute('allowLateSubmission')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -46,7 +46,7 @@ public function testUnmarshall() $this::assertFalse($component->doesAllowLateSubmission()); } - public function testUnmarshallZero() + public function testUnmarshallZero(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/UploadInteractionMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/UploadInteractionMarshallerTest.php index 730c767a3..3919c5ec6 100644 --- a/test/qtismtest/data/storage/xml/marshalling/UploadInteractionMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/UploadInteractionMarshallerTest.php @@ -15,7 +15,7 @@ */ class UploadInteractionMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $uploadInteraction = new UploadInteraction('RESPONSE', 'my-upload'); $uploadInteraction->setType('image/png'); @@ -31,7 +31,7 @@ public function testMarshall() $this::assertEquals('Prompt...', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement( ' @@ -50,7 +50,7 @@ public function testUnmarshall() $this::assertEquals('Prompt...', $promptContent[0]->getContent()); } - public function testUnmarshallNoResponseIdentifier() + public function testUnmarshallNoResponseIdentifier(): void { $element = $this->createDOMElement(' Prompt... diff --git a/test/qtismtest/data/storage/xml/marshalling/ValueMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/ValueMarshallerTest.php index 292475f0e..234f113e2 100644 --- a/test/qtismtest/data/storage/xml/marshalling/ValueMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/ValueMarshallerTest.php @@ -15,7 +15,7 @@ */ class ValueMarshallerTest extends QtiSmTestCase { - public function testMarshallBaseType() + public function testMarshallBaseType(): void { $fieldIdentifier = 'goodIdentifier'; $baseType = BaseType::INTEGER; @@ -33,7 +33,7 @@ public function testMarshallBaseType() $this::assertEquals($value . '', $element->nodeValue); } - public function testMarshallBaseTypeBoolean() + public function testMarshallBaseTypeBoolean(): void { $fieldIdentifier = 'goodIdentifier'; $baseType = BaseType::BOOLEAN; @@ -47,7 +47,7 @@ public function testMarshallBaseTypeBoolean() $this::assertSame('false', $element->nodeValue); } - public function testMarshallNoBaseType() + public function testMarshallNoBaseType(): void { $value = new QtiPair('id1', 'id2'); @@ -58,7 +58,7 @@ public function testMarshallNoBaseType() $this::assertEquals('id1 id2', $element->nodeValue); } - public function testUnmarshallNoBaseType() + public function testUnmarshallNoBaseType(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML('A B'); @@ -72,7 +72,7 @@ public function testUnmarshallNoBaseType() $this::assertEquals('A B', $component->getValue()); } - public function testUnmarshallNoBaseTypeButForced() + public function testUnmarshallNoBaseTypeButForced(): void { // Here we use the ValueMarshaller as a parametric marshaller // to force the Pair to be unserialized as a Pair object @@ -89,7 +89,7 @@ public function testUnmarshallNoBaseTypeButForced() $this::assertEquals('B', $component->getValue()->getSecond()); } - public function testUnmarshallNoBaseTypeButForcedAndEntities() + public function testUnmarshallNoBaseTypeButForcedAndEntities(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML('Hello <b>bold</b>'); @@ -103,7 +103,7 @@ public function testUnmarshallNoBaseTypeButForcedAndEntities() $this::assertSame('Hello bold', $component->getValue()); } - public function testMarshallNoBaseTypeButForcedAndEntities() + public function testMarshallNoBaseTypeButForcedAndEntities(): void { $value = 'Hello bold'; $baseType = BaseType::STRING; @@ -115,7 +115,7 @@ public function testMarshallNoBaseTypeButForcedAndEntities() $this::assertSame('Hello <b>bold</b>', $element->ownerDocument->saveXML($element)); } - public function testUnmarshallNoValueStringExpected() + public function testUnmarshallNoValueStringExpected(): void { // Just an empty . $dom = new DOMDocument('1.0', 'UTF-8'); @@ -136,7 +136,7 @@ public function testUnmarshallNoValueStringExpected() $this::assertEquals('', $component->getValue()); } - public function testUnmarshallNoValueIntegerExpected() + public function testUnmarshallNoValueIntegerExpected(): void { $this->expectException(UnmarshallingException::class); $dom = new DOMDocument('1.0', 'UTF-8'); @@ -148,7 +148,7 @@ public function testUnmarshallNoValueIntegerExpected() $this::assertEquals('', $component->getValue()); } - public function testUnmarshallNoValue() + public function testUnmarshallNoValue(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -160,7 +160,7 @@ public function testUnmarshallNoValue() $this::assertSame('', $component->getValue()); } - public function testUnmarshallStringBaseTypeWithNullValue() + public function testUnmarshallStringBaseTypeWithNullValue(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -172,7 +172,7 @@ public function testUnmarshallStringBaseTypeWithNullValue() $this::assertSame('', $component->getValue()); } - public function testUnmarshallBaseTypePairWithFieldIdentifier() + public function testUnmarshallBaseTypePairWithFieldIdentifier(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML('A B'); @@ -188,7 +188,7 @@ public function testUnmarshallBaseTypePairWithFieldIdentifier() $this::assertEquals('fieldIdentifier1', $component->getFieldIdentifier()); } - public function testUnmarshallBaseTypeInteger() + public function testUnmarshallBaseTypeInteger(): void { $dom = new DOMDocument('1.0', 'UTF-8'); // 0 value diff --git a/test/qtismtest/data/storage/xml/marshalling/VariableDeclarationMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/VariableDeclarationMarshallerTest.php index 2a80c088b..5bc5dfad8 100644 --- a/test/qtismtest/data/storage/xml/marshalling/VariableDeclarationMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/VariableDeclarationMarshallerTest.php @@ -17,7 +17,7 @@ */ class VariableDeclarationMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $component = new VariableDeclaration('myVar', BaseType::INTEGER, Cardinality::SINGLE); @@ -38,7 +38,7 @@ public function testMarshall() $this::assertEquals(1, $defaultValueElts->length); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML( diff --git a/test/qtismtest/data/storage/xml/marshalling/VariableMappingMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/VariableMappingMarshallerTest.php index ceffb7ce4..a486f74a4 100644 --- a/test/qtismtest/data/storage/xml/marshalling/VariableMappingMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/VariableMappingMarshallerTest.php @@ -12,7 +12,7 @@ */ class VariableMappingMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $source = 'myIdentifier1'; $target = 'myIdentifier2'; @@ -27,7 +27,7 @@ public function testMarshall() $this::assertEquals($target, $element->getAttribute('targetIdentifier')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/VariableMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/VariableMarshallerTest.php index 3b0b14dec..d22d7ca23 100644 --- a/test/qtismtest/data/storage/xml/marshalling/VariableMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/VariableMarshallerTest.php @@ -12,7 +12,7 @@ */ class VariableMarshallerTest extends QtiSmTestCase { - public function testMarshallWeight() + public function testMarshallWeight(): void { $identifier = 'myVariable1'; $weightIdentifier = 'myWeight1'; @@ -27,7 +27,7 @@ public function testMarshallWeight() $this::assertEquals($weightIdentifier, $element->getAttribute('weightIdentifier')); } - public function testMarshallNoWeight() + public function testMarshallNoWeight(): void { $identifier = 'myVariable1'; @@ -41,7 +41,7 @@ public function testMarshallNoWeight() $this::assertEquals('', $element->getAttribute('weightIdentifier')); // should have no weightIdentifier attr. } - public function testUnmarshallWeight() + public function testUnmarshallWeight(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -55,7 +55,7 @@ public function testUnmarshallWeight() $this::assertEquals('myWeight1', $component->getWeightIdentifier()); } - public function testUnmarshallNoWeight() + public function testUnmarshallNoWeight(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/WeightMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/WeightMarshallerTest.php index c0af741e8..4e7fb46ad 100644 --- a/test/qtismtest/data/storage/xml/marshalling/WeightMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/WeightMarshallerTest.php @@ -13,7 +13,7 @@ */ class WeightMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $identifier = 'myWeight1'; $value = 3.45; @@ -28,7 +28,7 @@ public function testMarshall() $this::assertEquals($value . '', $element->getAttribute('value')); } - public function testUnmarshall() + public function testUnmarshall(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -42,7 +42,7 @@ public function testUnmarshall() $this::assertEquals(3.45, $component->getValue()); } - public function testUnmarshallWrongIdentifier() + public function testUnmarshallWrongIdentifier(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -56,7 +56,7 @@ public function testUnmarshallWrongIdentifier() $marshaller->unmarshall($element); } - public function testUnmarshallNonFloatValue() + public function testUnmarshallNonFloatValue(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -70,7 +70,7 @@ public function testUnmarshallNonFloatValue() $marshaller->unmarshall($element); } - public function testUnmarshallNoValue() + public function testUnmarshallNoValue(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); @@ -84,7 +84,7 @@ public function testUnmarshallNoValue() $marshaller->unmarshall($element); } - public function testUnmarshallMissingIdentifier() + public function testUnmarshallMissingIdentifier(): void { $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); diff --git a/test/qtismtest/data/storage/xml/marshalling/XIncludeMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/XIncludeMarshallerTest.php index 9e20069c6..0e5ea2a86 100644 --- a/test/qtismtest/data/storage/xml/marshalling/XIncludeMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/XIncludeMarshallerTest.php @@ -13,7 +13,7 @@ */ class XIncludeMarshallerTest extends QtiSmTestCase { - public function testMarshall() + public function testMarshall(): void { $xinclude = new XInclude(''); $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($xinclude)->marshall($xinclude); @@ -23,7 +23,7 @@ public function testMarshall() $this::assertEquals('', $dom->saveXML($element)); } - public function testUnmarshall() + public function testUnmarshall(): void { $element = $this->createDOMElement(''); @@ -38,7 +38,7 @@ public function testUnmarshall() $this::assertEquals('http://www.w3.org/2001/XInclude', $includeElement->namespaceURI); } - public function testGetXmlWrongNamespace() + public function testGetXmlWrongNamespace(): void { $element = $this->createDOMElement(''); diff --git a/test/qtismtest/data/storage/xml/versions/CompactVersionTest.php b/test/qtismtest/data/storage/xml/versions/CompactVersionTest.php index ac1aa50fd..d516f1c6f 100644 --- a/test/qtismtest/data/storage/xml/versions/CompactVersionTest.php +++ b/test/qtismtest/data/storage/xml/versions/CompactVersionTest.php @@ -13,7 +13,7 @@ */ class CompactVersionTest extends QtiSmTestCase { - public function testVersionCompareSupported() + public function testVersionCompareSupported(): void { $this::assertTrue(CompactVersion::compare('2.1', '2.1.0', '=')); } @@ -24,7 +24,7 @@ public function testVersionCompareSupported() * @param string $expectedVersion * @param string $expectedClass */ - public function testCreateWithSupportedVersion(string $version, string $expectedVersion, string $expectedClass) + public function testCreateWithSupportedVersion(string $version, string $expectedVersion, string $expectedClass): void { $versionObject = CompactVersion::create($version); $this::assertInstanceOf($expectedClass, $versionObject); @@ -47,7 +47,7 @@ public function versionsToCreate(): array ]; } - public function testCreateWithUnsupportedVersionThrowsException() + public function testCreateWithUnsupportedVersionThrowsException(): void { $wrongVersion = '2.0'; diff --git a/test/qtismtest/data/storage/xml/versions/QtiVersionTest.php b/test/qtismtest/data/storage/xml/versions/QtiVersionTest.php index 27bdf4017..0bc31b55a 100644 --- a/test/qtismtest/data/storage/xml/versions/QtiVersionTest.php +++ b/test/qtismtest/data/storage/xml/versions/QtiVersionTest.php @@ -20,13 +20,13 @@ */ class QtiVersionTest extends QtiSmTestCase { - public function testVersionCompareValid() + public function testVersionCompareValid(): void { $this::assertTrue(QtiVersion::compare('2', '2.0.0', '=')); $this::assertFalse(QtiVersion::compare('2', '2.1', '=')); } - public function testVersionCompareInvalidVersion1() + public function testVersionCompareInvalidVersion1(): void { $msg = 'QTI version "2.1.4" is not supported. Supported versions are "2.0.0", "2.1.0", "2.1.1", "2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.2.4", "3.0.0".'; $this->expectException(QtiVersionException::class); @@ -34,7 +34,7 @@ public function testVersionCompareInvalidVersion1() QtiVersion::compare('2.1.4', '2.1.1', '>'); } - public function testVersionCompareInvalidVersion2() + public function testVersionCompareInvalidVersion2(): void { $msg = 'QTI version "2.1.4" is not supported. Supported versions are "2.0.0", "2.1.0", "2.1.1", "2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.2.4", "3.0.0".'; $this->expectException(QtiVersionException::class); @@ -48,7 +48,7 @@ public function testVersionCompareInvalidVersion2() * @param string $expectedVersion * @param string $expectedClass */ - public function testCreateWithSupportedVersion(string $version, string $expectedVersion, string $expectedClass) + public function testCreateWithSupportedVersion(string $version, string $expectedVersion, string $expectedClass): void { $versionObject = QtiVersion::create($version); $this::assertInstanceOf($expectedClass, $versionObject); @@ -73,7 +73,7 @@ public function versionsToCreate(): array ]; } - public function testCreateWithUnsupportedVersionThrowsException() + public function testCreateWithUnsupportedVersionThrowsException(): void { $wrongVersion = '36.15'; diff --git a/test/qtismtest/data/storage/xml/versions/ResultVersionTest.php b/test/qtismtest/data/storage/xml/versions/ResultVersionTest.php index d2d81277a..760b00c75 100644 --- a/test/qtismtest/data/storage/xml/versions/ResultVersionTest.php +++ b/test/qtismtest/data/storage/xml/versions/ResultVersionTest.php @@ -13,7 +13,7 @@ */ class ResultVersionTest extends QtiSmTestCase { - public function testVersionCompareSupported() + public function testVersionCompareSupported(): void { $this::assertTrue(ResultVersion::compare('2.1', '2.1.0', '=')); } @@ -24,7 +24,7 @@ public function testVersionCompareSupported() * @param string $expectedVersion * @param string $expectedClass */ - public function testCreateWithSupportedVersion(string $version, string $expectedVersion, string $expectedClass) + public function testCreateWithSupportedVersion(string $version, string $expectedVersion, string $expectedClass): void { $versionObject = ResultVersion::create($version); $this::assertInstanceOf($expectedClass, $versionObject); @@ -47,7 +47,7 @@ public function versionsToCreate(): array ]; } - public function testCreateWithUnsupportedVersionThrowsException() + public function testCreateWithUnsupportedVersionThrowsException(): void { $wrongVersion = '2.0'; diff --git a/test/qtismtest/runtime/common/ContainerTest.php b/test/qtismtest/runtime/common/ContainerTest.php index 1d5b59283..e328d3e28 100644 --- a/test/qtismtest/runtime/common/ContainerTest.php +++ b/test/qtismtest/runtime/common/ContainerTest.php @@ -40,7 +40,7 @@ class ContainerTest extends QtiSmTestCase * * @return Container A Container object. */ - protected function getContainer() + protected function getContainer(): Container { return $this->container; } @@ -61,7 +61,7 @@ public function tearDown(): void * @dataProvider validValueProvider * @param mixed $value */ - public function testAddValid($value) + public function testAddValid($value): void { // Try to test any QTI runtime model compliant data // for addition in the container. @@ -75,7 +75,7 @@ public function testAddValid($value) * @dataProvider invalidValueProvider * @param mixed $value */ - public function testAddInvalid($value) + public function testAddInvalid($value): void { $container = $this->getContainer(); @@ -83,7 +83,7 @@ public function testAddInvalid($value) $container[] = $value; } - public function testIsNull() + public function testIsNull(): void { $container = $this->getContainer(); @@ -97,7 +97,7 @@ public function testIsNull() * @dataProvider validValueCollectionProvider * @param ValueCollection $valueCollection */ - public function testCreateFromDataModelValid(ValueCollection $valueCollection) + public function testCreateFromDataModelValid(ValueCollection $valueCollection): void { $container = Container::createFromDataModel($valueCollection); $this::assertInstanceOf(Container::class, $container); @@ -108,7 +108,7 @@ public function testCreateFromDataModelValid(ValueCollection $valueCollection) * @param Container $a * @param Container $b */ - public function testEqualsPrimitiveValid(Container $a, Container $b) + public function testEqualsPrimitiveValid(Container $a, Container $b): void { $this::assertTrue($a->equals($b)); } @@ -118,7 +118,7 @@ public function testEqualsPrimitiveValid(Container $a, Container $b) * @param Container $a * @param mixed $b */ - public function testEqualsPrimitiveInvalid(Container $a, $b) + public function testEqualsPrimitiveInvalid(Container $a, $b): void { $this::assertFalse($a->equals($b)); } @@ -129,7 +129,7 @@ public function testEqualsPrimitiveInvalid(Container $a, $b) * @param mixed $lookup * @param mixed $expected */ - public function testOccurences(Container $container, $lookup, $expected) + public function testOccurences(Container $container, $lookup, $expected): void { $this::assertEquals($expected, $container->occurences($lookup)); } @@ -137,7 +137,7 @@ public function testOccurences(Container $container, $lookup, $expected) /** * @return array */ - public function validValueProvider() + public function validValueProvider(): array { return [ [new QtiInteger(25)], @@ -159,7 +159,7 @@ public function validValueProvider() * @return array * @throws Exception */ - public function invalidValueProvider() + public function invalidValueProvider(): array { return [ [new DateTime()], @@ -170,7 +170,7 @@ public function invalidValueProvider() /** * @return array */ - public function validEqualsPrimitiveProvider() + public function validEqualsPrimitiveProvider(): array { return [ [new Container([new QtiBoolean(true), new QtiBoolean(false)]), new Container([new QtiBoolean(false), new QtiBoolean(true)])], @@ -187,7 +187,7 @@ public function validEqualsPrimitiveProvider() /** * @return array */ - public function invalidEqualsPrimitiveProvider() + public function invalidEqualsPrimitiveProvider(): array { return [ [new Container([new QtiInteger(14)]), new Container([new QtiInteger(13)])], @@ -201,7 +201,7 @@ public function invalidEqualsPrimitiveProvider() /** * @return array */ - public function occurencesProvider() + public function occurencesProvider(): array { return [ [new Container([new QtiInteger(15)]), new QtiInteger(15), 1], @@ -225,7 +225,7 @@ public function occurencesProvider() /** * @return array */ - public function validValueCollectionProvider() + public function validValueCollectionProvider(): array { $returnValue = []; @@ -241,7 +241,7 @@ public function validValueCollectionProvider() return $returnValue; } - public function testClone() + public function testClone(): void { $container = $this->getContainer(); $container[] = new QtiPoint(10, 20); @@ -265,7 +265,7 @@ public function testClone() $this::assertNotSame($clone[7], $container[7]); } - public function testContains() + public function testContains(): void { $pair = new QtiPair('A', 'B'); $container = $this->getContainer(); @@ -273,7 +273,7 @@ public function testContains() $this::assertTrue($container->contains(new QtiPair('A', 'B'))); } - public function testContains2() + public function testContains2(): void { $identifier = new QtiIdentifier('test'); $container = $this->getContainer(); @@ -287,7 +287,7 @@ public function testContains2() * @param Container $container * @param string $expected The expected result of a __toString() call. */ - public function testToString(Container $container, $expected) + public function testToString(Container $container, $expected): void { $this::assertEquals($expected, $container->__toString()); } @@ -295,7 +295,7 @@ public function testToString(Container $container, $expected) /** * @return array */ - public function toStringProvider() + public function toStringProvider(): array { $returnValue = []; @@ -313,7 +313,7 @@ public function toStringProvider() * @param mixed $value * @param string $expectedMsg */ - public function testInvalidDatatype($value, $expectedMsg) + public function testInvalidDatatype($value, $expectedMsg): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage($expectedMsg); @@ -323,7 +323,7 @@ public function testInvalidDatatype($value, $expectedMsg) /** * @return array */ - public function invalidDatatypeProvider() + public function invalidDatatypeProvider(): array { $message = 'A value is not compliant with the QTI runtime model datatypes: Null, QTI Boolean, QTI Coords, QTI DirectedPair, QTI Duration, QTI File, QTI Float, QTI Identifier, QTI Integer, QTI IntOrIdentifier, QTI Pair, QTI Point, QTI String, QTI Uri. "%s" given.'; @@ -337,13 +337,13 @@ public function invalidDatatypeProvider() ]; } - public function testAlwaysMultipleCardinality() + public function testAlwaysMultipleCardinality(): void { $container = new Container(); $this::assertEquals(Cardinality::MULTIPLE, $container->getCardinality()); } - public function testDetach() + public function testDetach(): void { $object = new QtiBoolean(true); $container = new Container([$object]); @@ -355,7 +355,7 @@ public function testDetach() $this::assertCount(0, $container); } - public function testDetachNotFound() + public function testDetachNotFound(): void { $this->expectException(UnexpectedValueException::class); $this->expectExceptionMessage('The object you want to detach could not be found in the collection.'); @@ -365,7 +365,7 @@ public function testDetachNotFound() $container->detach(new QtiBoolean(false)); } - public function testDetachNotObject() + public function testDetachNotObject(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("You can only detach 'objects' into an AbstractCollection, 'NULL' given."); @@ -373,7 +373,7 @@ public function testDetachNotObject() $container->detach(null); } - public function testReplaceNotFound() + public function testReplaceNotFound(): void { $this->expectException(UnexpectedValueException::class); $this->expectExceptionMessage('The object you want to replace could not be found.'); @@ -383,7 +383,7 @@ public function testReplaceNotFound() $container->replace(new QtiBoolean(false), new QtiBoolean(false)); } - public function testReplaceToReplaceNotObject() + public function testReplaceToReplaceNotObject(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("You can only replace 'objects' into an AbstractCollection, 'NULL' given."); @@ -393,7 +393,7 @@ public function testReplaceToReplaceNotObject() $container->replace(null, new QtiBoolean(false)); } - public function testReplaceReplacementNotObject() + public function testReplaceReplacementNotObject(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("You can only replace 'objects' into an AbstractCollection, 'NULL' given."); @@ -403,7 +403,7 @@ public function testReplaceReplacementNotObject() $container->replace(new QtiBoolean(false), null); } - public function testMergeNotCompliantTypes() + public function testMergeNotCompliantTypes(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Only collections with compliant types can be merged ("qtism\runtime\common\Container" vs "qtism\common\collections\StringCollection").'); @@ -413,7 +413,7 @@ public function testMergeNotCompliantTypes() $container1->merge($container2); } - public function testDiffNotCompliantTypes() + public function testDiffNotCompliantTypes(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Difference may apply only on two collections of the same type.'); @@ -423,7 +423,7 @@ public function testDiffNotCompliantTypes() $container1->diff($container2); } - public function testIntersectNotCompliantTypes() + public function testIntersectNotCompliantTypes(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Intersection may apply only on two collections of the same type.'); diff --git a/test/qtismtest/runtime/common/MultipleContainerTest.php b/test/qtismtest/runtime/common/MultipleContainerTest.php index e9b0daa9d..1a02db547 100644 --- a/test/qtismtest/runtime/common/MultipleContainerTest.php +++ b/test/qtismtest/runtime/common/MultipleContainerTest.php @@ -18,7 +18,7 @@ */ class MultipleContainerTest extends QtiSmTestCase { - public function testCreationEmpty() + public function testCreationEmpty(): void { $container = new MultipleContainer(BaseType::BOOLEAN); $this::assertEquals(BaseType::BOOLEAN, $container->getBaseType()); @@ -26,7 +26,7 @@ public function testCreationEmpty() $this::assertEquals(Cardinality::MULTIPLE, $container->getCardinality()); } - public function testCreationWithValues() + public function testCreationWithValues(): void { $data = [new QtiInteger(10), new QtiInteger(20), new QtiInteger(20), new QtiInteger(30), new QtiInteger(40), new QtiInteger(50)]; $container = new MultipleContainer(BaseType::INTEGER, $data); @@ -36,26 +36,26 @@ public function testCreationWithValues() $this::assertEquals(20, $container[1]->getValue()); } - public function testCreationEmptyWrongBaseType1() + public function testCreationEmptyWrongBaseType1(): void { $this->expectException(InvalidArgumentException::class); $container = new MultipleContainer('invalid'); } - public function testCreationEmptyWrongBaseType2() + public function testCreationEmptyWrongBaseType2(): void { $this->expectException(InvalidArgumentException::class); $container = new MultipleContainer(14); } - public function testCreationWithWrongValues() + public function testCreationWithWrongValues(): void { $this->expectException(InvalidArgumentException::class); $data = [new QtiPoint(20, 20)]; $container = new MultipleContainer(BaseType::DURATION, $data); } - public function testCreateFromDataModel() + public function testCreateFromDataModel(): void { $valueCollection = new ValueCollection(); $valueCollection[] = new Value(new QtiPoint(10, 30), BaseType::POINT); @@ -75,7 +75,7 @@ public function testCreateFromDataModel() * @param int $baseType * @param ValueCollection $valueCollection */ - public function testCreateFromDataModelValid($baseType, ValueCollection $valueCollection) + public function testCreateFromDataModelValid($baseType, ValueCollection $valueCollection): void { $container = MultipleContainer::createFromDataModel($valueCollection, $baseType); $this::assertInstanceOf(MultipleContainer::class, $container); @@ -86,7 +86,7 @@ public function testCreateFromDataModelValid($baseType, ValueCollection $valueCo * @param int $baseType * @param ValueCollection $valueCollection */ - public function testCreateFromDataModelInvalid($baseType, ValueCollection $valueCollection) + public function testCreateFromDataModelInvalid($baseType, ValueCollection $valueCollection): void { $this->expectException(InvalidArgumentException::class); $container = MultipleContainer::createFromDataModel($valueCollection, $baseType); @@ -95,7 +95,7 @@ public function testCreateFromDataModelInvalid($baseType, ValueCollection $value /** * @return array */ - public function invalidCreateFromDataModelProvider() + public function invalidCreateFromDataModelProvider(): array { $returnValue = []; @@ -110,7 +110,7 @@ public function invalidCreateFromDataModelProvider() /** * @return array */ - public function validCreateFromDataModelProvider() + public function validCreateFromDataModelProvider(): array { $returnValue = []; @@ -125,7 +125,7 @@ public function validCreateFromDataModelProvider() return $returnValue; } - public function testEquals() + public function testEquals(): void { $c1 = new MultipleContainer(BaseType::INTEGER, [new QtiInteger(5), new QtiInteger(4), new QtiInteger(3), new QtiInteger(2), new QtiInteger(1)]); $c2 = new MultipleContainer(BaseType::INTEGER, [new QtiInteger(1), new QtiInteger(6), new QtiInteger(7), new QtiInteger(8), new QtiInteger(5)]); @@ -133,7 +133,7 @@ public function testEquals() $this::assertFalse($c2->equals($c1)); } - public function testEqualsTwo() + public function testEqualsTwo(): void { $c1 = new MultipleContainer(BaseType::FLOAT, [new QtiFloat(2.75), new QtiFloat(1.65)]); $c2 = new MultipleContainer(BaseType::FLOAT, [new QtiFloat(2.75), new QtiFloat(1.65)]); @@ -141,7 +141,7 @@ public function testEqualsTwo() $this::assertTrue($c2->equals($c1)); } - public function testEqualsEmpty() + public function testEqualsEmpty(): void { $c1 = new MultipleContainer(BaseType::FLOAT); $c2 = new MultipleContainer(BaseType::FLOAT); @@ -154,7 +154,7 @@ public function testEqualsEmpty() * @param MultipleContainer $originalContainer * @param MultipleContainer $expectedContainer */ - public function testDistinct(MultipleContainer $originalContainer, MultipleContainer $expectedContainer) + public function testDistinct(MultipleContainer $originalContainer, MultipleContainer $expectedContainer): void { $distinctContainer = $originalContainer->distinct(); $this::assertTrue($distinctContainer->equals($expectedContainer)); @@ -164,7 +164,7 @@ public function testDistinct(MultipleContainer $originalContainer, MultipleConta /** * @return array */ - public function distinctProvider() + public function distinctProvider(): array { return [ [new MultipleContainer(BaseType::INTEGER), new MultipleContainer(BaseType::INTEGER)], diff --git a/test/qtismtest/runtime/common/OrderedContainerTest.php b/test/qtismtest/runtime/common/OrderedContainerTest.php index dd9ad4a48..036cdcc8e 100644 --- a/test/qtismtest/runtime/common/OrderedContainerTest.php +++ b/test/qtismtest/runtime/common/OrderedContainerTest.php @@ -21,7 +21,7 @@ class OrderedContainerTest extends QtiSmTestCase * @param OrderedContainer $containerA * @param OrderedContainer $containerB */ - public function testEqualsValid(OrderedContainer $containerA, OrderedContainer $containerB) + public function testEqualsValid(OrderedContainer $containerA, OrderedContainer $containerB): void { $this::assertTrue($containerA->equals($containerB)); $this::assertTrue($containerB->equals($containerA)); @@ -32,13 +32,13 @@ public function testEqualsValid(OrderedContainer $containerA, OrderedContainer $ * @param OrderedContainer $containerA * @param OrderedContainer $containerB */ - public function testEqualsInvalid(OrderedContainer $containerA, OrderedContainer $containerB) + public function testEqualsInvalid(OrderedContainer $containerA, OrderedContainer $containerB): void { $this::assertFalse($containerA->equals($containerB)); $this::assertFalse($containerB->equals($containerA)); } - public function testCreationEmpty() + public function testCreationEmpty(): void { $container = new OrderedContainer(BaseType::INTEGER); $this::assertCount(0, $container); @@ -49,7 +49,7 @@ public function testCreationEmpty() /** * @return array */ - public function equalsValidProvider() + public function equalsValidProvider(): array { return [ [new OrderedContainer(BaseType::INTEGER), new OrderedContainer(BaseType::INTEGER)], @@ -62,7 +62,7 @@ public function equalsValidProvider() /** * @return array */ - public function equalsInvalidProvider() + public function equalsInvalidProvider(): array { return [ [new OrderedContainer(BaseType::INTEGER, [new QtiInteger(20)]), new OrderedContainer(BaseType::INTEGER, [new QtiInteger(30)])], @@ -71,7 +71,7 @@ public function equalsInvalidProvider() ]; } - public function testEqualsNull() + public function testEqualsNull(): void { $container = new OrderedContainer(BaseType::INTEGER, [new QtiInteger(10)]); $this::assertFalse($container->equals(null)); diff --git a/test/qtismtest/runtime/common/OutcomeVariableTest.php b/test/qtismtest/runtime/common/OutcomeVariableTest.php index 43fe14106..94702e0db 100644 --- a/test/qtismtest/runtime/common/OutcomeVariableTest.php +++ b/test/qtismtest/runtime/common/OutcomeVariableTest.php @@ -28,7 +28,7 @@ */ class OutcomeVariableTest extends QtiSmTestCase { - public function testInstantiate() + public function testInstantiate(): void { $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER); $this::assertNull($outcome->getValue()); @@ -43,7 +43,7 @@ public function testInstantiate() $this::assertInstanceOf(RecordContainer::class, $outcome->getValue()); } - public function testCardinalitySingle() + public function testCardinalitySingle(): void { $variable = new OutcomeVariable('outcome1', Cardinality::SINGLE, BaseType::INTEGER); $this::assertInstanceOf(OutcomeVariable::class, $variable); @@ -78,7 +78,7 @@ public function testCardinalitySingle() $this::assertTrue($variable->isInitializedFromDefaultValue()); } - public function testCardinalityMultiple() + public function testCardinalityMultiple(): void { $variable = new OutcomeVariable('outcome1', Cardinality::MULTIPLE, BaseType::INTEGER); $this::assertInstanceOf(OutcomeVariable::class, $variable); @@ -112,7 +112,7 @@ public function testCardinalityMultiple() } } - public function testCreateFromVariableDeclarationMinimal() + public function testCreateFromVariableDeclarationMinimal(): void { $factory = $this->getMarshallerFactory('2.1.0'); $element = $this->createDOMElement(''); @@ -125,7 +125,7 @@ public function testCreateFromVariableDeclarationMinimal() $this::assertEquals(Cardinality::SINGLE, $outcomeVariable->getCardinality()); } - public function testCreateFromVariableDeclarationDefaultValueSingleCardinality() + public function testCreateFromVariableDeclarationDefaultValueSingleCardinality(): void { $factory = $this->getMarshallerFactory('2.1.0'); $element = $this->createDOMElement(' @@ -142,7 +142,7 @@ public function testCreateFromVariableDeclarationDefaultValueSingleCardinality() $this::assertTrue($pair->equals($outcomeVariable->getDefaultValue())); } - public function testCreateFromVariableDeclarationDefaultValueMultipleCardinality() + public function testCreateFromVariableDeclarationDefaultValueMultipleCardinality(): void { $factory = $this->getMarshallerFactory('2.1.0'); $element = $this->createDOMElement(' @@ -164,7 +164,7 @@ public function testCreateFromVariableDeclarationDefaultValueMultipleCardinality $this::assertTrue($defaultValue[1]->equals(new QtiPair('B', 'C'))); } - public function testCreateFromVariableDeclarationDefaultValueRecordCardinality() + public function testCreateFromVariableDeclarationDefaultValueRecordCardinality(): void { $factory = $this->getMarshallerFactory('2.1.0'); $element = $this->createDOMElement(' @@ -186,7 +186,7 @@ public function testCreateFromVariableDeclarationDefaultValueRecordCardinality() $this::assertInstanceOf(QtiFloat::class, $defaultValue['B']); } - public function testCreateFromVariableDeclarationExtended() + public function testCreateFromVariableDeclarationExtended(): void { $factory = $this->getMarshallerFactory('2.1.0'); $element = $this->createDOMElement(' @@ -231,7 +231,7 @@ public function testCreateFromVariableDeclarationExtended() $this::assertTrue($targetValue->equals(new QtiPair('E', 'F'))); } - public function testCreateFromVariableDeclarationInconsistentOne() + public function testCreateFromVariableDeclarationInconsistentOne(): void { $factory = $this->getMarshallerFactory('2.1.0'); $element = $this->createDOMElement(' @@ -252,7 +252,7 @@ public function testCreateFromVariableDeclarationInconsistentOne() $outcomeVariable = OutcomeVariable::createFromDataModel($outcomeDeclaration); } - public function testCreateFromVariableDeclarationInconsistentTwo() + public function testCreateFromVariableDeclarationInconsistentTwo(): void { $factory = $this->getMarshallerFactory('2.1.0'); $element = $this->createDOMElement(' @@ -272,7 +272,7 @@ public function testCreateFromVariableDeclarationInconsistentTwo() $outcomeDeclaration = $factory->createMarshaller($element)->unmarshall($element); } - public function testCreateFromVariableDeclarationInconsistentThree() + public function testCreateFromVariableDeclarationInconsistentThree(): void { $value = new Value('String!', BaseType::STRING); $defaultValue = new DefaultValue( @@ -285,7 +285,7 @@ public function testCreateFromVariableDeclarationInconsistentThree() $outcomeVariable = OutcomeVariable::createFromDataModel($variableDeclaration); } - public function testIsNull() + public function testIsNull(): void { $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::STRING); $this::assertTrue($outcome->isNull()); @@ -338,7 +338,7 @@ public function testIsNull() $this::assertFalse($outcome->isNull()); } - public function testClone() + public function testClone(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); $var->setDefaultValue(new QtiInteger(1)); @@ -349,74 +349,74 @@ public function testClone() $this::assertNotSame($var->getDefaultValue(), $clone->getDefaultValue()); } - public function testSetNoBaseTypeNotRecord() + public function testSetNoBaseTypeNotRecord(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('You are forced to specify a baseType if cardinality is not RECORD.'); $var = new OutcomeVariable('var', Cardinality::MULTIPLE, -1); } - public function testIsOrdered() + public function testIsOrdered(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); $this::assertFalse($var->isOrdered()); } - public function testIsNumeric() + public function testIsNumeric(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); $this::assertTrue($var->isNumeric()); } - public function testIsBool() + public function testIsBool(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); $this::assertFalse($var->isBool()); } - public function testIsInteger() + public function testIsInteger(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); $this::assertTrue($var->isInteger()); } - public function testIsFloat() + public function testIsFloat(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); $this::assertFalse($var->isFloat()); } - public function testIsPoint() + public function testIsPoint(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); $this::assertFalse($var->isPoint()); } - public function testIsPair() + public function testIsPair(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); $this::assertFalse($var->isPair()); } - public function testIsDirectedPair() + public function testIsDirectedPair(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); $this::assertFalse($var->isDirectedPair()); } - public function testIsDuration() + public function testIsDuration(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); $this::assertFalse($var->isDuration()); } - public function testIsString() + public function testIsString(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); $this::assertFalse($var->isString()); } - public function testSetNormalMaximumWrongType() + public function testSetNormalMaximumWrongType(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); @@ -426,7 +426,7 @@ public function testSetNormalMaximumWrongType() $var->setNormalMaximum(true); } - public function testSetNormalMinimumWrongType() + public function testSetNormalMinimumWrongType(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); @@ -436,7 +436,7 @@ public function testSetNormalMinimumWrongType() $var->setNormalMinimum(true); } - public function testSetMasterValueWrongType() + public function testSetMasterValueWrongType(): void { $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); @@ -446,7 +446,7 @@ public function testSetMasterValueWrongType() $var->setMasteryValue(true); } - public function testCreateFromResponseDeclaration() + public function testCreateFromResponseDeclaration(): void { $factory = $this->getMarshallerFactory('2.1.0'); $element = $this->createDOMElement(' diff --git a/test/qtismtest/runtime/common/RecordContainerTest.php b/test/qtismtest/runtime/common/RecordContainerTest.php index 73dfaa14a..f2e2c82dc 100644 --- a/test/qtismtest/runtime/common/RecordContainerTest.php +++ b/test/qtismtest/runtime/common/RecordContainerTest.php @@ -19,7 +19,7 @@ */ class RecordContainerTest extends QtiSmTestCase { - public function testValid() + public function testValid(): void { $record = new RecordContainer(); $this::assertInstanceOf(RecordContainer::class, $record); @@ -33,7 +33,7 @@ public function testValid() $this::assertEquals(1, $record->occurences(new QtiPoint(10, 10))); } - public function testEquals() + public function testEquals(): void { $record1 = new RecordContainer(['one' => new QtiInteger(1), 'two' => new QtiInteger(2)]); $record2 = new RecordContainer(['two' => new QtiInteger(2), 'one' => new QtiInteger(1)]); @@ -45,27 +45,27 @@ public function testEquals() $this::assertFalse($record3->equals($record1)); } - public function testInvalidInstantiationOne() + public function testInvalidInstantiationOne(): void { $this->expectException(InvalidArgumentException::class); $record = new RecordContainer([new QtiInteger(1), new QtiInteger(2), new QtiInteger(3)]); } - public function testInvalidUseOne() + public function testInvalidUseOne(): void { $this->expectException(RuntimeException::class); $record = new RecordContainer(); $record[] = new QtiString('string'); } - public function testInvalidUseTwo() + public function testInvalidUseTwo(): void { $this->expectException(RuntimeException::class); $record = new RecordContainer(); $record[111] = new QtiString('string'); } - public function testInvalidUseThree() + public function testInvalidUseThree(): void { $this->expectException(InvalidArgumentException::class); // try with a datatype not supported by the QTI Runtime Model. @@ -73,7 +73,7 @@ public function testInvalidUseThree() $record['document'] = new DOMDocument(); } - public function testCreateFromDataModel() + public function testCreateFromDataModel(): void { $valueCollection = new ValueCollection(); @@ -94,7 +94,7 @@ public function testCreateFromDataModel() $this::assertEquals('string', $record['val2']->getValue()); } - public function testCreateFromDataModelNoFieldIdentifier() + public function testCreateFromDataModelNoFieldIdentifier(): void { $valueCollection = new ValueCollection(); diff --git a/test/qtismtest/runtime/common/ResponseVariableTest.php b/test/qtismtest/runtime/common/ResponseVariableTest.php index ceeab5cef..119ce9f91 100644 --- a/test/qtismtest/runtime/common/ResponseVariableTest.php +++ b/test/qtismtest/runtime/common/ResponseVariableTest.php @@ -25,7 +25,7 @@ */ class ResponseVariableTest extends QtiSmTestCase { - public function testCreateFromVariableDeclarationExtended() + public function testCreateFromVariableDeclarationExtended(): void { $factory = $this->getMarshallerFactory('2.1.0'); $element = $this->createDOMElement(' @@ -113,13 +113,13 @@ public function testCreateFromVariableDeclarationExtended() $this::assertFalse($responseVariable->isInitializedFromDefaultValue()); } - public function testIsCorrectWithNullCorrectResponse() + public function testIsCorrectWithNullCorrectResponse(): void { $responseVariable = new ResponseVariable('MYVAR', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); $this::assertFalse($responseVariable->isCorrect()); } - public function testGetScalarDataModelValuesSingleCardinality() + public function testGetScalarDataModelValuesSingleCardinality(): void { $responseVariable = new ResponseVariable('MYVAR', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(10)); $values = $responseVariable->getDataModelValues(); @@ -134,7 +134,7 @@ public function testGetScalarDataModelValuesSingleCardinality() $this::assertSame(10.1, $values[0]->getValue()); } - public function testGetNonScalarDataModelValuesSingleCardinality() + public function testGetNonScalarDataModelValuesSingleCardinality(): void { // QtiPair $qtiPair = new QtiPair('A', 'B'); @@ -171,7 +171,7 @@ public function testGetNonScalarDataModelValuesSingleCardinality() $this::assertStringEqualsFile($path, $actual->getData()); } - public function testGetScalarDataModelValuesMultipleCardinality() + public function testGetScalarDataModelValuesMultipleCardinality(): void { $responseVariable = new ResponseVariable( 'MYVAR', @@ -189,7 +189,7 @@ public function testGetScalarDataModelValuesMultipleCardinality() $this::assertEquals(12, $values[1]->getValue()); } - public function testGetNonScalarDataModelValuesMultipleCardinality() + public function testGetNonScalarDataModelValuesMultipleCardinality(): void { // QtiPair $qtiPair1 = new QtiPair('A', 'B'); @@ -256,7 +256,7 @@ public function testGetDataModelValuesRecordCardinality(): void $this::assertTrue($qtiPair->equals($values[3]->getValue())); } - public function testClone() + public function testClone(): void { // value, default value and correct response must be independent after cloning. $responseVariable = new ResponseVariable('MYVAR', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25)); diff --git a/test/qtismtest/runtime/common/RuntimeUtilsTest.php b/test/qtismtest/runtime/common/RuntimeUtilsTest.php index 412abdf6e..0081aa5dc 100644 --- a/test/qtismtest/runtime/common/RuntimeUtilsTest.php +++ b/test/qtismtest/runtime/common/RuntimeUtilsTest.php @@ -32,7 +32,7 @@ class RuntimeUtilsTest extends QtiSmTestCase * @param mixed $value * @param int|bool $expectedBaseType */ - public function testInferBaseType($value, $expectedBaseType) + public function testInferBaseType($value, $expectedBaseType): void { $this::assertSame($expectedBaseType, Utils::inferBaseType($value)); } @@ -42,7 +42,7 @@ public function testInferBaseType($value, $expectedBaseType) * @param mixed $value * @param int|bool $expectedCardinality */ - public function testInferCardinality($value, $expectedCardinality) + public function testInferCardinality($value, $expectedCardinality): void { $this::assertSame($expectedCardinality, Utils::inferCardinality($value)); } @@ -53,7 +53,7 @@ public function testInferCardinality($value, $expectedCardinality) * @param string $string * @param bool $expected */ - public function testIsValidVariableIdentifier($string, $expected) + public function testIsValidVariableIdentifier($string, $expected): void { $this::assertSame($expected, Utils::isValidVariableIdentifier($string)); } @@ -64,7 +64,7 @@ public function testIsValidVariableIdentifier($string, $expected) * @param QtiDatatype $value * @param bool $expected */ - public function testIsNull(QtiDatatype $value = null, $expected) + public function testIsNull(QtiDatatype $value = null, $expected): void { $this::assertSame($expected, Utils::isNull($value)); } @@ -76,7 +76,7 @@ public function testIsNull(QtiDatatype $value = null, $expected) * @param QtiDatatype $b * @param bool $expected */ - public function testEquals(QtiDatatype $a = null, QtiDatatype $b = null, $expected) + public function testEquals(QtiDatatype $a = null, QtiDatatype $b = null, $expected): void { $this::assertSame($expected, Utils::equals($a, $b)); } @@ -86,7 +86,7 @@ public function testEquals(QtiDatatype $a = null, QtiDatatype $b = null, $expect * @param mixed $value * @param string $expectedMsg */ - public function testThrowTypingError($value, $expectedMsg) + public function testThrowTypingError($value, $expectedMsg): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage($expectedMsg); @@ -99,7 +99,7 @@ public function testThrowTypingError($value, $expectedMsg) * @param array $floatArray * @param array $integerArray */ - public function testFloatArrayToInteger($floatArray, $integerArray) + public function testFloatArrayToInteger($floatArray, $integerArray): void { $this::assertEquals($integerArray, Utils::floatArrayToInteger($floatArray)); } @@ -109,7 +109,7 @@ public function testFloatArrayToInteger($floatArray, $integerArray) * @param array $integerArray * @param array $floatArray */ - public function testIntegerArrayToFloat($integerArray, $floatArray) + public function testIntegerArrayToFloat($integerArray, $floatArray): void { $this::assertEquals($floatArray, Utils::integerArrayToFloat($integerArray)); } @@ -117,7 +117,7 @@ public function testIntegerArrayToFloat($integerArray, $floatArray) /** * @return array */ - public function throwTypingErrorProvider() + public function throwTypingErrorProvider(): array { $message = 'A value is not compliant with the QTI runtime model datatypes: Null, QTI Boolean, QTI Coords, QTI DirectedPair, QTI Duration, QTI File, QTI Float, QTI Identifier, QTI Integer, QTI IntOrIdentifier, QTI Pair, QTI Point, QTI String, QTI Uri. "%s" given.'; return [ @@ -130,7 +130,7 @@ public function throwTypingErrorProvider() /** * @return array */ - public function floatArrayToIntegerProvider() + public function floatArrayToIntegerProvider(): array { return [ [[10.2, 0.0], [10, 0]], @@ -140,7 +140,7 @@ public function floatArrayToIntegerProvider() /** * @return array */ - public function integerArrayToFloatProvider() + public function integerArrayToFloatProvider(): array { return [ [[10, 0], [10., 0.]], @@ -150,7 +150,7 @@ public function integerArrayToFloatProvider() /** * @return array */ - public function inferBaseTypeProvider() + public function inferBaseTypeProvider(): array { $returnValue = []; @@ -177,7 +177,7 @@ public function inferBaseTypeProvider() /** * @return array */ - public function inferCardinalityProvider() + public function inferCardinalityProvider(): array { $returnValue = []; @@ -202,7 +202,7 @@ public function inferCardinalityProvider() /** * @return array */ - public function isValidVariableIdentifierProvider() + public function isValidVariableIdentifierProvider(): array { return [ ['Q01', true], @@ -234,7 +234,7 @@ public function isValidVariableIdentifierProvider() /** * @return array */ - public function isNullDataProvider() + public function isNullDataProvider(): array { return [ [new QtiBoolean(true), false], @@ -251,7 +251,7 @@ public function isNullDataProvider() /** * @return array */ - public function equalsProvider() + public function equalsProvider(): array { return [ [new QtiBoolean(true), null, false], diff --git a/test/qtismtest/runtime/common/StackTraceTest.php b/test/qtismtest/runtime/common/StackTraceTest.php index e0c04c110..da80228cd 100644 --- a/test/qtismtest/runtime/common/StackTraceTest.php +++ b/test/qtismtest/runtime/common/StackTraceTest.php @@ -14,7 +14,7 @@ */ class StackTraceTest extends QtiSmTestCase { - public function testPop() + public function testPop(): void { $stackTrace = new StackTrace(); $stackTraceItem = new StackTraceItem(new BaseValue(BaseType::INTEGER, 0), 'pouet'); @@ -25,7 +25,7 @@ public function testPop() $this::assertCount(0, $stackTrace); } - public function testToString() + public function testToString(): void { $stackTrace = new StackTrace(); $stackTraceItem = new StackTraceItem(new BaseValue(BaseType::INTEGER, 0), 'pouet'); @@ -35,7 +35,7 @@ public function testToString() $this::assertEquals("pouet\npouet\n", $stackTrace . ''); } - public function testAddInvalidDataType() + public function testAddInvalidDataType(): void { $stackTrace = new StackTrace(); $stackTraceItem = new BaseValue(BaseType::INTEGER, 0); diff --git a/test/qtismtest/runtime/common/StateTest.php b/test/qtismtest/runtime/common/StateTest.php index 23176599f..fca15e6c0 100644 --- a/test/qtismtest/runtime/common/StateTest.php +++ b/test/qtismtest/runtime/common/StateTest.php @@ -24,7 +24,7 @@ */ class StateTest extends QtiSmTestCase { - public function testInstantiation() + public function testInstantiation(): void { $state = new State(); $this::assertInstanceOf(State::class, $state); @@ -51,13 +51,13 @@ public function testInstantiation() $this::assertNull($state['RESPONSE']); } - public function testInstantiationInvalid() + public function testInstantiationInvalid(): void { $this->expectException(InvalidArgumentException::class); $state = new State([15, 'string', new stdClass()]); } - public function testAddressing() + public function testAddressing(): void { $state = new State(); $response = new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::INTEGER); @@ -73,21 +73,21 @@ public function testAddressing() $this::assertFalse(isset($state['SCOREX'])); } - public function testAddressingInvalidOne() + public function testAddressingInvalidOne(): void { $this->expectException(OutOfBoundsException::class); $state = new State(); $state['var'] = new ResponseDeclaration('var', BaseType::POINT, Cardinality::ORDERED); } - public function testAdressingInvalidTwo() + public function testAdressingInvalidTwo(): void { $this->expectException(OutOfRangeException::class); $state = new State(); $var = $state[3]; } - public function testGetAllVariables() + public function testGetAllVariables(): void { $state = new State(); $this::assertCount(0, $state->getAllVariables()); @@ -110,7 +110,7 @@ public function testGetAllVariables() * @param bool $expected * @param State $state */ - public function testContainsNullOnly($expected, State $state) + public function testContainsNullOnly($expected, State $state): void { $this::assertEquals($expected, $state->containsNullOnly()); } @@ -118,7 +118,7 @@ public function testContainsNullOnly($expected, State $state) /** * @return array */ - public function containsNullOnlyProvider() + public function containsNullOnlyProvider(): array { return [ [true, new State()], @@ -147,7 +147,7 @@ public function containsNullOnlyProvider() * @param bool $expected * @param State $state */ - public function testContainsValuesEqualToVariableDefaultOnly($expected, State $state) + public function testContainsValuesEqualToVariableDefaultOnly($expected, State $state): void { $this::assertEquals($expected, $state->containsValuesEqualToVariableDefaultOnly()); } @@ -155,7 +155,7 @@ public function testContainsValuesEqualToVariableDefaultOnly($expected, State $s /** * @return array */ - public function containsValuesEqualToVariableDefaultOnlyProvider() + public function containsValuesEqualToVariableDefaultOnlyProvider(): array { $booleanNotDefault = new ResponseVariable('BOOLEAN_NOT_DEFAULT', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(true)); $booleanNotDefault->setDefaultValue(new QtiBoolean(false)); @@ -198,7 +198,7 @@ public function containsValuesEqualToVariableDefaultOnlyProvider() ]; } - public function testUnsetVariableByString() + public function testUnsetVariableByString(): void { $state = new State( [ @@ -211,7 +211,7 @@ public function testUnsetVariableByString() $this::assertCount(0, $state); } - public function testUnsetVariableByVariableObject() + public function testUnsetVariableByVariableObject(): void { $variable = new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::BOOLEAN, new QtiBoolean(true)); $state = new State([$variable]); @@ -221,7 +221,7 @@ public function testUnsetVariableByVariableObject() $this::assertCount(0, $state); } - public function testUnsetUnexistingVariable() + public function testUnsetUnexistingVariable(): void { $state = new State(); @@ -231,7 +231,7 @@ public function testUnsetUnexistingVariable() $state->unsetVariable('X'); } - public function testUnsetVariableWrongType() + public function testUnsetVariableWrongType(): void { $state = new State(); @@ -241,7 +241,7 @@ public function testUnsetVariableWrongType() $state->unsetVariable(true); } - public function testOffsetSetWrongOffsetType() + public function testOffsetSetWrongOffsetType(): void { $state = new State(); diff --git a/test/qtismtest/runtime/common/TemplateVariableTest.php b/test/qtismtest/runtime/common/TemplateVariableTest.php index c24ce08a3..3b1af4384 100644 --- a/test/qtismtest/runtime/common/TemplateVariableTest.php +++ b/test/qtismtest/runtime/common/TemplateVariableTest.php @@ -12,7 +12,7 @@ */ class TemplateVariableTest extends QtiSmTestCase { - public function testCreateFromDataModel() + public function testCreateFromDataModel(): void { $decl = $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/common/VariableFactoryTest.php b/test/qtismtest/runtime/common/VariableFactoryTest.php index 40ef17667..0ffb4b1dc 100644 --- a/test/qtismtest/runtime/common/VariableFactoryTest.php +++ b/test/qtismtest/runtime/common/VariableFactoryTest.php @@ -21,8 +21,6 @@ * @license GPLv2 */ -declare(strict_types=1); - namespace qtismtest\runtime\common; use UnexpectedValueException; diff --git a/test/qtismtest/runtime/common/VariableIdentifierTest.php b/test/qtismtest/runtime/common/VariableIdentifierTest.php index abe325c6a..d007197b1 100644 --- a/test/qtismtest/runtime/common/VariableIdentifierTest.php +++ b/test/qtismtest/runtime/common/VariableIdentifierTest.php @@ -16,7 +16,7 @@ class VariableIdentifierTest extends QtiSmTestCase * * @param string $identifier */ - public function testInvalidIdentifier($identifier) + public function testInvalidIdentifier($identifier): void { $this->expectException(InvalidArgumentException::class); $v = new VariableIdentifier($identifier); @@ -27,7 +27,7 @@ public function testInvalidIdentifier($identifier) * * @param string $identifier */ - public function testSimpleIdentifiers($identifier) + public function testSimpleIdentifiers($identifier): void { $v = new VariableIdentifier($identifier); @@ -44,7 +44,7 @@ public function testSimpleIdentifiers($identifier) * @param string $expectedPrefix * @param string $expectedVariableName */ - public function testPrefixedIdentifiers($identifier, $expectedPrefix, $expectedVariableName) + public function testPrefixedIdentifiers($identifier, $expectedPrefix, $expectedVariableName): void { $v = new VariableIdentifier($identifier); @@ -63,7 +63,7 @@ public function testPrefixedIdentifiers($identifier, $expectedPrefix, $expectedV * @param string $expectedSequence * @param string $expectedVariableName */ - public function testSequencedIdentifiers($identifier, $expectedPrefix, $expectedSequence, $expectedVariableName) + public function testSequencedIdentifiers($identifier, $expectedPrefix, $expectedSequence, $expectedVariableName): void { $v = new VariableIdentifier($identifier); @@ -75,28 +75,28 @@ public function testSequencedIdentifiers($identifier, $expectedPrefix, $expected $this::assertEquals($expectedSequence, $v->getSequenceNumber()); } - public function testInvalidSequenceNumberOne() + public function testInvalidSequenceNumberOne(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The identifier 'Q01.bla.SCORE' is not a valid QTI Variable Name Identifier."); new VariableIdentifier('Q01.bla.SCORE'); } - public function testInvalidSequenceNumberTwo() + public function testInvalidSequenceNumberTwo(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The identifier 'Q01.0.SCORE' is not a valid QTI Variable Name Identifier."); new VariableIdentifier('Q01.0.SCORE'); } - public function testInvalidVariableName() + public function testInvalidVariableName(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The identifier 'Q01.0. ' is not a valid QTI Variable Name Identifier."); new VariableIdentifier('Q01.0. '); } - public function testInvalidPrefix() + public function testInvalidPrefix(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("The identifier ' .SCORE' is not a valid QTI Variable Name Identifier."); @@ -106,7 +106,7 @@ public function testInvalidPrefix() /** * @return array */ - public function invalidIdentifierProvider() + public function invalidIdentifierProvider(): array { return [ ['Q*01'], @@ -132,7 +132,7 @@ public function invalidIdentifierProvider() /** * @return array */ - public function simpleIdentifiersProvider() + public function simpleIdentifiersProvider(): array { return [ ['Q01'], @@ -144,7 +144,7 @@ public function simpleIdentifiersProvider() /** * @return array */ - public function prefixedIdentifiersProvider() + public function prefixedIdentifiersProvider(): array { return [ ['Q01.SCORE', 'Q01', 'SCORE'], @@ -156,7 +156,7 @@ public function prefixedIdentifiersProvider() /** * @return array */ - public function sequencedIdentifiersProvider() + public function sequencedIdentifiersProvider(): array { return [ ['Q01.1.SCORE', 'Q01', 1, 'SCORE'], diff --git a/test/qtismtest/runtime/expressions/BaseValueProcessorTest.php b/test/qtismtest/runtime/expressions/BaseValueProcessorTest.php index 29d652fab..6c530be16 100644 --- a/test/qtismtest/runtime/expressions/BaseValueProcessorTest.php +++ b/test/qtismtest/runtime/expressions/BaseValueProcessorTest.php @@ -11,7 +11,7 @@ */ class BaseValueProcessorTest extends QtiSmTestCase { - public function testBaseValue() + public function testBaseValue(): void { $baseValue = $this->createComponentFromXml('true'); $baseValueProcessor = new BaseValueProcessor($baseValue); diff --git a/test/qtismtest/runtime/expressions/CorrectProcessorTest.php b/test/qtismtest/runtime/expressions/CorrectProcessorTest.php index f90e5060f..25391dc18 100644 --- a/test/qtismtest/runtime/expressions/CorrectProcessorTest.php +++ b/test/qtismtest/runtime/expressions/CorrectProcessorTest.php @@ -18,7 +18,7 @@ */ class CorrectProcessorTest extends QtiSmTestCase { - public function testMultipleCardinality() + public function testMultipleCardinality(): void { $responseDeclaration = $this->createComponentFromXml(' @@ -44,7 +44,7 @@ public function testMultipleCardinality() $this::assertTrue($comparable->equals($result)); } - public function testSingleCardinality() + public function testSingleCardinality(): void { $responseDeclaration = $this->createComponentFromXml(' @@ -64,7 +64,7 @@ public function testSingleCardinality() $this::assertEquals(20, $result->getValue()); } - public function testNull() + public function testNull(): void { $responseDeclaration = $this->createComponentFromXml(' @@ -82,7 +82,7 @@ public function testNull() $this::assertNull($result); } - public function testException() + public function testException(): void { $variableDeclaration = $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/DefaultProcessorTest.php b/test/qtismtest/runtime/expressions/DefaultProcessorTest.php index b1ba0e039..b9f4d545f 100644 --- a/test/qtismtest/runtime/expressions/DefaultProcessorTest.php +++ b/test/qtismtest/runtime/expressions/DefaultProcessorTest.php @@ -17,7 +17,7 @@ */ class DefaultProcessorTest extends QtiSmTestCase { - public function testMultipleCardinality() + public function testMultipleCardinality(): void { $variableDeclaration = $this->createComponentFromXml(' @@ -41,7 +41,7 @@ public function testMultipleCardinality() $this::assertTrue($comparable->equals($processor->process())); } - public function testSingleCardinality() + public function testSingleCardinality(): void { $variableDeclaration = $this->createComponentFromXml(' @@ -60,7 +60,7 @@ public function testSingleCardinality() $this::assertFalse($result->getValue()); } - public function testNoVariable() + public function testNoVariable(): void { $expr = $this->createComponentFromXml(''); $processor = new DefaultProcessor($expr); @@ -69,7 +69,7 @@ public function testNoVariable() $this::assertNull($result); } - public function testNoDefaultValue() + public function testNoDefaultValue(): void { $variableDeclaration = $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/ExpressionEngineTest.php b/test/qtismtest/runtime/expressions/ExpressionEngineTest.php index dde722fff..1d0db2627 100644 --- a/test/qtismtest/runtime/expressions/ExpressionEngineTest.php +++ b/test/qtismtest/runtime/expressions/ExpressionEngineTest.php @@ -14,7 +14,7 @@ */ class ExpressionEngineTest extends QtiSmTestCase { - public function testExpressionEngineBaseValue() + public function testExpressionEngineBaseValue(): void { $expression = $this->createComponentFromXml('P2D'); $engine = new ExpressionEngine($expression); @@ -23,7 +23,7 @@ public function testExpressionEngineBaseValue() $this::assertEquals(2, $result->getDays()); } - public function testExpressionEngineSum() + public function testExpressionEngineSum(): void { $expression = $this->createComponentFromXml(' @@ -44,7 +44,7 @@ public function testExpressionEngineSum() $this::assertEquals(60.0, $result->getValue()); } - public function testCreateWrongExpressionType() + public function testCreateWrongExpressionType(): void { $expression = new ItemSessionControl(); diff --git a/test/qtismtest/runtime/expressions/ExpressionProcessorFactoryTest.php b/test/qtismtest/runtime/expressions/ExpressionProcessorFactoryTest.php index 113e658e6..1b0d06e5a 100644 --- a/test/qtismtest/runtime/expressions/ExpressionProcessorFactoryTest.php +++ b/test/qtismtest/runtime/expressions/ExpressionProcessorFactoryTest.php @@ -12,7 +12,7 @@ */ class ExpressionProcessorFactoryTest extends QtiSmTestCase { - public function testCreateProcessor() + public function testCreateProcessor(): void { $expression = $this->createComponentFromXml('1337'); @@ -22,7 +22,7 @@ public function testCreateProcessor() $this::assertEquals('baseValue', $processor->getExpression()->getQtiClassName()); } - public function testCreateProcessorNoProcessor() + public function testCreateProcessorNoProcessor(): void { $expression = $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/MapResponsePointProcessorTest.php b/test/qtismtest/runtime/expressions/MapResponsePointProcessorTest.php index e327f9a58..d712e3e23 100644 --- a/test/qtismtest/runtime/expressions/MapResponsePointProcessorTest.php +++ b/test/qtismtest/runtime/expressions/MapResponsePointProcessorTest.php @@ -18,7 +18,7 @@ */ class MapResponsePointProcessorTest extends QtiSmTestCase { - public function testSingleCardinality() + public function testSingleCardinality(): void { $expr = $this->createComponentFromXml(''); $variableDeclaration = $this->createComponentFromXml(' @@ -58,7 +58,7 @@ public function testSingleCardinality() $this::assertEquals(666.666, $result->getValue()); } - public function testMultipleCardinality() + public function testMultipleCardinality(): void { $expr = $this->createComponentFromXml(''); $variableDeclaration = $this->createComponentFromXml(' @@ -98,7 +98,7 @@ public function testMultipleCardinality() $this::assertEquals(666.666, $result->getValue()); } - public function testNoVariable() + public function testNoVariable(): void { $expr = $this->createComponentFromXml(''); $processor = new MapResponsePointProcessor($expr); @@ -106,7 +106,7 @@ public function testNoVariable() $result = $processor->process(); } - public function testNoVariableValue() + public function testNoVariableValue(): void { $expr = $this->createComponentFromXml(''); $variableDeclaration = $this->createComponentFromXml(' @@ -124,7 +124,7 @@ public function testNoVariableValue() $this::assertEquals(0.0, $result->getValue()); } - public function testDefaultValue() + public function testDefaultValue(): void { $expr = $this->createComponentFromXml(''); $variableDeclaration = $this->createComponentFromXml(' @@ -142,7 +142,7 @@ public function testDefaultValue() $this::assertEquals(2.0, $result->getValue()); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expr = $this->createComponentFromXml(''); $variableDeclaration = $this->createComponentFromXml(' @@ -160,7 +160,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testNoAreaMapping() + public function testNoAreaMapping(): void { // When no areaMapping is found, we consider a default value of 0.0. $expr = $this->createComponentFromXml(''); @@ -175,7 +175,7 @@ public function testNoAreaMapping() $this::assertEquals(0.0, $result->getValue()); } - public function testWrongVariableType() + public function testWrongVariableType(): void { $expr = $this->createComponentFromXml(''); $variableDeclaration = $this->createComponentFromXml(' @@ -189,7 +189,7 @@ public function testWrongVariableType() $result = $processor->process(); } - public function testLowerBoundOverflow() + public function testLowerBoundOverflow(): void { $expr = $this->createComponentFromXml(''); $variableDeclaration = $this->createComponentFromXml(' @@ -210,7 +210,7 @@ public function testLowerBoundOverflow() $this::assertEquals(1, $result->getValue()); } - public function testUpperBoundOverflow() + public function testUpperBoundOverflow(): void { $expr = $this->createComponentFromXml(''); $variableDeclaration = $this->createComponentFromXml(' @@ -231,7 +231,7 @@ public function testUpperBoundOverflow() $this::assertEquals(5, $result->getValue()); } - public function testWithRecord() + public function testWithRecord(): void { $expr = $this->createComponentFromXml(''); $variableDeclaration = $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/MapResponseProcessorTest.php b/test/qtismtest/runtime/expressions/MapResponseProcessorTest.php index dcbbb3430..eb1fdd4df 100644 --- a/test/qtismtest/runtime/expressions/MapResponseProcessorTest.php +++ b/test/qtismtest/runtime/expressions/MapResponseProcessorTest.php @@ -24,7 +24,7 @@ */ class MapResponseProcessorTest extends QtiSmTestCase { - public function testSimple() + public function testSimple(): void { $variableDeclaration = $this->createComponentFromXml(' @@ -63,7 +63,7 @@ public function testSimple() $this::assertEquals(3, $result->getValue()); } - public function testMultipleComplexTyping() + public function testMultipleComplexTyping(): void { $variableDeclaration = $this->createComponentFromXml(' @@ -103,7 +103,7 @@ public function testMultipleComplexTyping() $this::assertEquals(4, $result->getValue()); // 2.5 taken into account only once! } - public function testIdentifier() + public function testIdentifier(): void { $variableDeclaration = $this->createComponentFromXml(' @@ -125,7 +125,7 @@ public function testIdentifier() $this::assertEquals(6.0, $result->getValue()); } - public function testVariableNotDefined() + public function testVariableNotDefined(): void { $this->expectException(ExpressionProcessingException::class); $this->expectExceptionMessage("No variable with identifier 'INVALID' could be found while processing MapResponse."); @@ -136,7 +136,7 @@ public function testVariableNotDefined() $mapResponseProcessor->process(); } - public function testNoMapping() + public function testNoMapping(): void { // When no mapping is set. We consider a "fake" mapping with a default value of 0. $variableDeclaration = $this->createComponentFromXml(''); @@ -160,7 +160,7 @@ public function testNoMapping() $this::assertEquals(0.0, $result->getValue()); } - public function testMultipleCardinalityIdentifierToFloat() + public function testMultipleCardinalityIdentifierToFloat(): void { $responseDeclaration = $this->createComponentFromXml(' @@ -233,7 +233,7 @@ public function testMultipleCardinalityIdentifierToFloat() $result = $mapResponseProcessor->process(); } - public function testOutcomeDeclaration() + public function testOutcomeDeclaration(): void { $this->expectException(ExpressionProcessingException::class); $variableDeclaration = $this->createComponentFromXml(' @@ -251,7 +251,7 @@ public function testOutcomeDeclaration() $mapResponseProcessor->process(); } - public function testEmptyMapEntryForStringSingleCardinality() + public function testEmptyMapEntryForStringSingleCardinality(): void { $variableDeclaration = $this->createComponentFromXml(' @@ -293,7 +293,7 @@ public function testEmptyMapEntryForStringSingleCardinality() $this::assertEquals(0, $result->getValue()); } - public function testEmptyMapEntryForStringMultipleCardinality() + public function testEmptyMapEntryForStringMultipleCardinality(): void { $variableDeclaration = $this->createComponentFromXml(' @@ -361,7 +361,7 @@ public function testEmptyMapEntryForStringMultipleCardinality() $this::assertEquals(0, $result->getValue()); } - public function testEmptyMapEntryForStringMultipleCardinalityCaseInsensitive() + public function testEmptyMapEntryForStringMultipleCardinalityCaseInsensitive(): void { $variableDeclaration = $this->createComponentFromXml(' @@ -461,7 +461,7 @@ public function testEmptyMapEntryForStringMultipleCardinalityCaseInsensitive() $this::assertEquals(0, $result->getValue()); } - public function testLowerBoundSingleCardinality() + public function testLowerBoundSingleCardinality(): void { $variableDeclaration = $this->createComponentFromXml(' @@ -492,7 +492,7 @@ public function testLowerBoundSingleCardinality() $this::assertEquals(-1.0, $result->getValue()); } - public function testLowerBoundWithMultipleCardinality() + public function testLowerBoundWithMultipleCardinality(): void { // In case of using a single cardinality variable lower bound is ignored! $variableDeclaration = $this->createComponentFromXml(' @@ -524,7 +524,7 @@ public function testLowerBoundWithMultipleCardinality() $this::assertEquals(-1.0, $result->getValue()); } - public function testUpperBoundSingleCardinality() + public function testUpperBoundSingleCardinality(): void { // In case of using a single cardinality variable lower bound is ignored! $variableDeclaration = $this->createComponentFromXml(' @@ -556,7 +556,7 @@ public function testUpperBoundSingleCardinality() $this::assertEquals(1.0, $result->getValue()); } - public function testUpperBoundWithMultipleCardinality() + public function testUpperBoundWithMultipleCardinality(): void { // In case of using a single cardinality variable lower bound is ignored! $variableDeclaration = $this->createComponentFromXml(' @@ -588,7 +588,7 @@ public function testUpperBoundWithMultipleCardinality() $this::assertEquals(1.0, $result->getValue()); } - public function testOrderedContainer() + public function testOrderedContainer(): void { $variableDeclaration = $this->createComponentFromXml(' @@ -622,7 +622,7 @@ public function testOrderedContainer() $this::assertEquals(4.0, $result->getValue()); } - public function testDefaultValue() + public function testDefaultValue(): void { $variableDeclaration = $this->createComponentFromXml(' @@ -683,7 +683,7 @@ public function testDefaultValue() $this::assertEquals(2.5, $result->getValue()); } - public function testIdenticicalMapKeysSingleCardinality() + public function testIdenticicalMapKeysSingleCardinality(): void { $variableDeclaration = $this->createComponentFromXml(' @@ -715,7 +715,7 @@ public function testIdenticicalMapKeysSingleCardinality() $this::assertEquals(4.0, $result->getValue()); } - public function testIdenticicalMapKeysMultipleCardinality() + public function testIdenticicalMapKeysMultipleCardinality(): void { $variableDeclaration = $this->createComponentFromXml(' @@ -753,7 +753,7 @@ public function testIdenticicalMapKeysMultipleCardinality() $this::assertEquals(4.0, $result->getValue()); } - public function testSingleCardinalityStringCaseSensitivity() + public function testSingleCardinalityStringCaseSensitivity(): void { $variableDeclaration = $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/MathConstantProcessorTest.php b/test/qtismtest/runtime/expressions/MathConstantProcessorTest.php index 0a4aaf4c0..704535dbb 100644 --- a/test/qtismtest/runtime/expressions/MathConstantProcessorTest.php +++ b/test/qtismtest/runtime/expressions/MathConstantProcessorTest.php @@ -11,7 +11,7 @@ */ class MathConstantProcessorTest extends QtiSmTestCase { - public function testSimple() + public function testSimple(): void { $mathConstantExpr = $this->createComponentFromXml(''); $mathConstantProcessor = new MathConstantProcessor($mathConstantExpr); diff --git a/test/qtismtest/runtime/expressions/NullProcessorTest.php b/test/qtismtest/runtime/expressions/NullProcessorTest.php index 2e4cd9f7f..dfeebd34a 100644 --- a/test/qtismtest/runtime/expressions/NullProcessorTest.php +++ b/test/qtismtest/runtime/expressions/NullProcessorTest.php @@ -10,7 +10,7 @@ */ class NullProcessorTest extends QtiSmTestCase { - public function testNullProcessor() + public function testNullProcessor(): void { $nullExpression = $this->createComponentFromXml(''); $nullProcessor = new NullProcessor($nullExpression); diff --git a/test/qtismtest/runtime/expressions/NumberCorrectProcessorTest.php b/test/qtismtest/runtime/expressions/NumberCorrectProcessorTest.php index 3fbee3bb0..18cef0cce 100644 --- a/test/qtismtest/runtime/expressions/NumberCorrectProcessorTest.php +++ b/test/qtismtest/runtime/expressions/NumberCorrectProcessorTest.php @@ -21,7 +21,7 @@ */ class NumberCorrectProcessorTest extends QtiSmItemSubsetTestCase { - public function testNumberCorrect() + public function testNumberCorrect(): void { $session = $this->getTestSession(); @@ -130,7 +130,7 @@ public function testNumberCorrect() * @param IdentifierCollection|null $excludeCategories * @return NumberCorrect */ - protected static function getNumberCorrect($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null) + protected static function getNumberCorrect($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null): NumberCorrect { $numberCorrect = new NumberCorrect(); $numberCorrect->setSectionIdentifier($sectionIdentifier); diff --git a/test/qtismtest/runtime/expressions/NumberIncorrectProcessorTest.php b/test/qtismtest/runtime/expressions/NumberIncorrectProcessorTest.php index db8835bb4..59ab99202 100644 --- a/test/qtismtest/runtime/expressions/NumberIncorrectProcessorTest.php +++ b/test/qtismtest/runtime/expressions/NumberIncorrectProcessorTest.php @@ -21,7 +21,7 @@ */ class NumberIncorrectProcessorTest extends QtiSmItemSubsetTestCase { - public function testNumberIncorrect() + public function testNumberIncorrect(): void { $session = $this->getTestSession(); @@ -126,7 +126,7 @@ public function testNumberIncorrect() * @param IdentifierCollection|null $excludeCategories * @return NumberIncorrect */ - protected static function getNumberIncorrect($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null) + protected static function getNumberIncorrect($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null): NumberIncorrect { $numberIncorrect = new NumberIncorrect(); $numberIncorrect->setSectionIdentifier($sectionIdentifier); diff --git a/test/qtismtest/runtime/expressions/NumberPresentedProcessorTest.php b/test/qtismtest/runtime/expressions/NumberPresentedProcessorTest.php index 173be91ac..6d16109c2 100644 --- a/test/qtismtest/runtime/expressions/NumberPresentedProcessorTest.php +++ b/test/qtismtest/runtime/expressions/NumberPresentedProcessorTest.php @@ -25,7 +25,7 @@ class NumberPresentedProcessorTest extends QtiSmItemSubsetTestCase * @throws AssessmentTestSessionException * @throws PhpStorageException */ - public function testNumberPresented(NumberPresented $expression, array $expectedResults) + public function testNumberPresented(NumberPresented $expression, array $expectedResults): void { $session = $this->getTestSession(); $processor = new NumberPresentedProcessor($expression); @@ -50,7 +50,7 @@ public function testNumberPresented(NumberPresented $expression, array $expected /** * @return array */ - public function numberPresentedProvider() + public function numberPresentedProvider(): array { return [ [self::getNumberPresented(), [1, 2, 3, 4, 5, 6, 7, 8, 9]], @@ -70,7 +70,7 @@ public function numberPresentedProvider() * @param IdentifierCollection|null $excludeCategories * @return NumberPresented */ - protected static function getNumberPresented($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null) + protected static function getNumberPresented($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null): NumberPresented { $numberPresented = new NumberPresented(); $numberPresented->setSectionIdentifier($sectionIdentifier); diff --git a/test/qtismtest/runtime/expressions/NumberRespondedProcessorTest.php b/test/qtismtest/runtime/expressions/NumberRespondedProcessorTest.php index 2a74ce14a..63a4d4cd2 100644 --- a/test/qtismtest/runtime/expressions/NumberRespondedProcessorTest.php +++ b/test/qtismtest/runtime/expressions/NumberRespondedProcessorTest.php @@ -21,7 +21,7 @@ */ class NumberRespondedProcessorTest extends QtiSmItemSubsetTestCase { - public function testNumberResponded() + public function testNumberResponded(): void { $session = $this->getTestSession(); @@ -123,7 +123,7 @@ public function testNumberResponded() * @param IdentifierCollection|null $excludeCategories * @return NumberResponded */ - protected static function getNumberResponded($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null) + protected static function getNumberResponded($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null): NumberResponded { $numberResponded = new NumberResponded(); $numberResponded->setSectionIdentifier($sectionIdentifier); diff --git a/test/qtismtest/runtime/expressions/NumberSelectedProcessorTest.php b/test/qtismtest/runtime/expressions/NumberSelectedProcessorTest.php index d1dbd539b..8e318d1ec 100644 --- a/test/qtismtest/runtime/expressions/NumberSelectedProcessorTest.php +++ b/test/qtismtest/runtime/expressions/NumberSelectedProcessorTest.php @@ -18,7 +18,7 @@ class NumberSelectedProcessorTest extends QtiSmItemSubsetTestCase * @param NumberSelected $expression * @param int $expectedResult */ - public function testNumberSelected(NumberSelected $expression, $expectedResult) + public function testNumberSelected(NumberSelected $expression, $expectedResult): void { $session = $this->getTestSession(); @@ -33,7 +33,7 @@ public function testNumberSelected(NumberSelected $expression, $expectedResult) /** * @return array */ - public function numberSelectedProvider() + public function numberSelectedProvider(): array { return [ [self::getNumberSelected(), 9], @@ -49,7 +49,7 @@ public function numberSelectedProvider() * @param IdentifierCollection|null $excludeCategories * @return NumberSelected */ - protected static function getNumberSelected($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null) + protected static function getNumberSelected($sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null): NumberSelected { $numberSelected = new NumberSelected(); $numberSelected->setSectionIdentifier($sectionIdentifier); diff --git a/test/qtismtest/runtime/expressions/OutcomeMaximumProcessorTest.php b/test/qtismtest/runtime/expressions/OutcomeMaximumProcessorTest.php index d7a3fd5c9..627bf282a 100644 --- a/test/qtismtest/runtime/expressions/OutcomeMaximumProcessorTest.php +++ b/test/qtismtest/runtime/expressions/OutcomeMaximumProcessorTest.php @@ -21,7 +21,7 @@ class OutcomeMaximumProcessorTest extends QtiSmItemSubsetTestCase * @param OutcomeMaximum $expression * @param int $expectedResult */ - public function testOutcomeMaximum(OutcomeMaximum $expression, $expectedResult) + public function testOutcomeMaximum(OutcomeMaximum $expression, $expectedResult): void { $session = $this->getTestSession(); @@ -41,7 +41,7 @@ public function testOutcomeMaximum(OutcomeMaximum $expression, $expectedResult) /** * @return array */ - public function outcomeMaximumProvider() + public function outcomeMaximumProvider(): array { return [ [self::getOutcomeMaximum('SCORE'), null], // NULL values involved, the expression returns NULL systematically. @@ -64,7 +64,7 @@ public function outcomeMaximumProvider() * @param IdentifierCollection|null $excludeCategories * @return OutcomeMaximum */ - protected static function getOutcomeMaximum($outcomeIdentifier, $weightIdentifier = '', $sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null) + protected static function getOutcomeMaximum($outcomeIdentifier, $weightIdentifier = '', $sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null): OutcomeMaximum { $outcomeMaximum = new OutcomeMaximum($outcomeIdentifier); $outcomeMaximum->setSectionIdentifier($sectionIdentifier); diff --git a/test/qtismtest/runtime/expressions/OutcomeMinimumProcessorTest.php b/test/qtismtest/runtime/expressions/OutcomeMinimumProcessorTest.php index a4260b189..951cf73a6 100644 --- a/test/qtismtest/runtime/expressions/OutcomeMinimumProcessorTest.php +++ b/test/qtismtest/runtime/expressions/OutcomeMinimumProcessorTest.php @@ -21,7 +21,7 @@ class OutcomeMinimumProcessorTest extends QtiSmItemSubsetTestCase * @param OutcomeMinimum $expression * @param int $expectedResult */ - public function testOutcomeMaximum(OutcomeMinimum $expression, $expectedResult) + public function testOutcomeMaximum(OutcomeMinimum $expression, $expectedResult): void { $session = $this->getTestSession(); @@ -41,7 +41,7 @@ public function testOutcomeMaximum(OutcomeMinimum $expression, $expectedResult) /** * @return array */ - public function outcomeMinimumProvider() + public function outcomeMinimumProvider(): array { return [ [self::getOutcomeMinimum('SCORE'), new MultipleContainer(BaseType::FLOAT, [new QtiFloat(-2.0), new QtiFloat(0.5), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0)])], @@ -61,7 +61,7 @@ public function outcomeMinimumProvider() * @param IdentifierCollection|null $excludeCategories * @return OutcomeMinimum */ - protected static function getOutcomeMinimum($outcomeIdentifier, $weightIdentifier = '', $sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null) + protected static function getOutcomeMinimum($outcomeIdentifier, $weightIdentifier = '', $sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null): OutcomeMinimum { $outcomeMinimum = new OutcomeMinimum($outcomeIdentifier); $outcomeMinimum->setSectionIdentifier($sectionIdentifier); diff --git a/test/qtismtest/runtime/expressions/ProcessorUtilsTest.php b/test/qtismtest/runtime/expressions/ProcessorUtilsTest.php index 290a456aa..3f6ac7692 100644 --- a/test/qtismtest/runtime/expressions/ProcessorUtilsTest.php +++ b/test/qtismtest/runtime/expressions/ProcessorUtilsTest.php @@ -17,7 +17,7 @@ class ProcessorUtilsTest extends QtiSmTestCase * @param string $value * @param string $expected */ - public function testSanitizeVariableRefValid($value, $expected) + public function testSanitizeVariableRefValid($value, $expected): void { $ref = $this::assertEquals(Utils::sanitizeVariableRef($value), $expected); } @@ -26,7 +26,7 @@ public function testSanitizeVariableRefValid($value, $expected) * @dataProvider sanitizeVariableRefInvalidProvider * @param mixed $value */ - public function testSanitizeVariableRefInvalid($value) + public function testSanitizeVariableRefInvalid($value): void { $this->expectException(InvalidArgumentException::class); $ref = Utils::sanitizeVariableRef($value); @@ -35,7 +35,7 @@ public function testSanitizeVariableRefInvalid($value) /** * @return array */ - public function sanitizeVariableRefValidProvider() + public function sanitizeVariableRefValidProvider(): array { return [ ['variableRef', 'variableRef'], @@ -51,7 +51,7 @@ public function sanitizeVariableRefValidProvider() /** * @return array */ - public function sanitizeVariableRefInvalidProvider() + public function sanitizeVariableRefInvalidProvider(): array { return [ [new stdClass()], diff --git a/test/qtismtest/runtime/expressions/RandomFloatProcessorTest.php b/test/qtismtest/runtime/expressions/RandomFloatProcessorTest.php index fd85ee556..f4c39cbcc 100644 --- a/test/qtismtest/runtime/expressions/RandomFloatProcessorTest.php +++ b/test/qtismtest/runtime/expressions/RandomFloatProcessorTest.php @@ -12,7 +12,7 @@ */ class RandomFloatProcessorTest extends QtiSmTestCase { - public function testSimple() + public function testSimple(): void { $expression = $this->createComponentFromXml(''); $processor = new RandomFloatProcessor($expression); @@ -36,7 +36,7 @@ public function testSimple() $this::assertLessThanOrEqual(2430.6666, $result->getValue()); } - public function testMinGreaterThanMax() + public function testMinGreaterThanMax(): void { $expression = $this->createComponentFromXml(''); $processor = new RandomFloatProcessor($expression); diff --git a/test/qtismtest/runtime/expressions/RandomIntegerProcessorTest.php b/test/qtismtest/runtime/expressions/RandomIntegerProcessorTest.php index bd510c612..eb3d24b94 100644 --- a/test/qtismtest/runtime/expressions/RandomIntegerProcessorTest.php +++ b/test/qtismtest/runtime/expressions/RandomIntegerProcessorTest.php @@ -12,7 +12,7 @@ */ class RandomIntegerProcessorTest extends QtiSmTestCase { - public function testSimple() + public function testSimple(): void { $randomIntegerExpr = $this->createComponentFromXml(''); $randomIntegerProcessor = new RandomIntegerProcessor($randomIntegerExpr); @@ -38,7 +38,7 @@ public function testSimple() $this::assertEquals(0, $result->getValue() % 4); } - public function testMinLessThanMax() + public function testMinLessThanMax(): void { $expression = $this->createComponentFromXml(''); $processor = new RandomIntegerProcessor($expression); diff --git a/test/qtismtest/runtime/expressions/TestVariablesProcessorTest.php b/test/qtismtest/runtime/expressions/TestVariablesProcessorTest.php index f565ce822..375e92880 100644 --- a/test/qtismtest/runtime/expressions/TestVariablesProcessorTest.php +++ b/test/qtismtest/runtime/expressions/TestVariablesProcessorTest.php @@ -34,7 +34,7 @@ class TestVariablesProcessorTest extends QtiSmItemSubsetTestCase * @throws AssessmentTestSessionException * @throws PhpStorageException */ - public function testTestVariables(TestVariables $expression, $expectedResult) + public function testTestVariables(TestVariables $expression, $expectedResult): void { $session = $this->getTestSession(); @@ -121,7 +121,7 @@ public function testTestVariables(TestVariables $expression, $expectedResult) /** * @return array */ - public function variablesProvider() + public function variablesProvider(): array { return [ [self::getTestVariables('SCORE'), new MultipleContainer(BaseType::FLOAT, [new QtiFloat(1.0), new QtiFloat(3.0), new QtiFloat(2.0), new QtiFloat(0.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(1.0), new QtiFloat(0.0)])], @@ -165,7 +165,7 @@ public function variablesProvider() * @param IdentifierCollection|null $excludeCategories * @return TestVariables */ - protected static function getTestVariables($variableIdentifier, $baseType = -1, $weightIdentifier = '', $sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null) + protected static function getTestVariables($variableIdentifier, $baseType = -1, $weightIdentifier = '', $sectionIdentifier = '', IdentifierCollection $includeCategories = null, IdentifierCollection $excludeCategories = null): TestVariables { $testVariables = new TestVariables($variableIdentifier, $baseType, $weightIdentifier); $testVariables->setSectionIdentifier($sectionIdentifier); diff --git a/test/qtismtest/runtime/expressions/VariableProcessorTest.php b/test/qtismtest/runtime/expressions/VariableProcessorTest.php index 6380514a2..6c9c87ece 100644 --- a/test/qtismtest/runtime/expressions/VariableProcessorTest.php +++ b/test/qtismtest/runtime/expressions/VariableProcessorTest.php @@ -33,7 +33,7 @@ */ class VariableProcessorTest extends QtiSmTestCase { - public function testSimple() + public function testSimple(): void { $variableExpr = $this->createComponentFromXml(''); @@ -62,7 +62,7 @@ public function testSimple() $this::assertEquals(12, $result[1]->getValue()); } - public function testWeighted() + public function testWeighted(): void { $assessmentItemRef = new ExtendedAssessmentItemRef('Q01', './Q01.xml'); $weights = new WeightCollection([new Weight('weight1', 1.1)]); @@ -114,7 +114,7 @@ public function testWeighted() $this::assertEquals(12.1, round($stateVal[1]->getValue(), 2)); } - public function testMultipleOccurences() + public function testMultipleOccurences(): void { $doc = new XmlCompactDocument(); $doc->load(self::samplesDir() . 'custom/runtime/scenario_basic_nonadaptive_linear_singlesection_withreplacement.xml'); diff --git a/test/qtismtest/runtime/expressions/operators/AndProcessorTest.php b/test/qtismtest/runtime/expressions/operators/AndProcessorTest.php index b32b12be0..aef0ed10e 100644 --- a/test/qtismtest/runtime/expressions/operators/AndProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/AndProcessorTest.php @@ -21,7 +21,7 @@ */ class AndProcessorTest extends QtiSmTestCase { - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -30,7 +30,7 @@ public function testNotEnoughOperands() $result = $processor->process(); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiPoint(1, 2)]); @@ -39,7 +39,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinalityOne() + public function testWrongCardinalityOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new RecordContainer(['a' => new QtiString('string!')])]); @@ -48,7 +48,7 @@ public function testWrongCardinalityOne() $result = $processor->process(); } - public function testWrongCardinalityTwo() + public function testWrongCardinalityTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new MultipleContainer(BaseType::FLOAT, [new QtiFloat(25.0)])]); @@ -57,7 +57,7 @@ public function testWrongCardinalityTwo() $result = $processor->process(); } - public function testNullOperands() + public function testNullOperands(): void { $expression = $this->createFakeExpression(); @@ -75,7 +75,7 @@ public function testNullOperands() $this::assertNull($result); } - public function testTrue() + public function testTrue(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiBoolean(true)]); @@ -91,7 +91,7 @@ public function testTrue() $this::assertTrue($result->getValue()); } - public function testFalse() + public function testFalse(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiBoolean(false)]); @@ -111,7 +111,7 @@ public function testFalse() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/AnyNProcessorTest.php b/test/qtismtest/runtime/expressions/operators/AnyNProcessorTest.php index 13b7a5309..d2c0f2af8 100644 --- a/test/qtismtest/runtime/expressions/operators/AnyNProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/AnyNProcessorTest.php @@ -32,7 +32,7 @@ class AnyNProcessorTest extends QtiSmTestCase * @param bool $expected * @throws MarshallerNotFoundException */ - public function testAnyN($min, $max, array $booleans, $expected) + public function testAnyN($min, $max, array $booleans, $expected): void { $expression = $this->createFakeExpression($min, $max); $operands = new OperandsCollection($booleans); @@ -46,7 +46,7 @@ public function testAnyN($min, $max, array $booleans, $expected) } } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(2, 3); $operands = new OperandsCollection([new MultipleContainer(BaseType::INTEGER)]); @@ -55,7 +55,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(2, 3); $operands = new OperandsCollection([new QtiString('String')]); @@ -64,7 +64,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $expression = $this->createFakeExpression(2, 3); $operands = new OperandsCollection([new QtiPoint(1, 2)]); @@ -73,7 +73,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(2, 3); $operands = new OperandsCollection(); @@ -81,7 +81,7 @@ public function testNotEnoughOperands() $processor = new AnyNProcessor($expression, $operands); } - public function testWithMinFromVariableReference() + public function testWithMinFromVariableReference(): void { $expression = $this->createFakeExpression('var1', 4); $var1 = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(3)); @@ -94,7 +94,7 @@ public function testWithMinFromVariableReference() $this::assertFalse($result->getValue()); } - public function testWithMaxFromVariableReference() + public function testWithMaxFromVariableReference(): void { $expression = $this->createFakeExpression(3, 'var1'); $var1 = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(4)); @@ -107,7 +107,7 @@ public function testWithMaxFromVariableReference() $this::assertTrue($result->getValue()); } - public function testMinCannotBeResolved() + public function testMinCannotBeResolved(): void { $expression = $this->createFakeExpression('min', 4); $operands = new OperandsCollection([new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), null]); @@ -116,7 +116,7 @@ public function testMinCannotBeResolved() $result = $processor->process(); } - public function testMaxCannotBeResolved() + public function testMaxCannotBeResolved(): void { $expression = $this->createFakeExpression(3, 'max'); $operands = new OperandsCollection([new QtiBoolean(true), new QtiBoolean(true), new QtiBoolean(true), null]); @@ -125,7 +125,7 @@ public function testMaxCannotBeResolved() $result = $processor->process(); } - public function testMinReferenceWrongBaseType() + public function testMinReferenceWrongBaseType(): void { $expression = $this->createFakeExpression('min', 4); $min = new OutcomeVariable('min', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(2.3)); @@ -138,7 +138,7 @@ public function testMinReferenceWrongBaseType() $result = $processor->process(); } - public function testMaxReferenceWrongBaseType() + public function testMaxReferenceWrongBaseType(): void { $expression = $this->createFakeExpression(3, 'max'); $max = new OutcomeVariable('max', Cardinality::SINGLE, BaseType::FLOAT, new QtiFloat(4.5356)); @@ -157,7 +157,7 @@ public function testMaxReferenceWrongBaseType() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression($min, $max) + public function createFakeExpression($min, $max): QtiComponent { return $this->createComponentFromXml(' @@ -171,7 +171,7 @@ public function createFakeExpression($min, $max) /** * @return array */ - public function anyNProvider() + public function anyNProvider(): array { $returnValue = []; diff --git a/test/qtismtest/runtime/expressions/operators/ContainerSizeProcessorTest.php b/test/qtismtest/runtime/expressions/operators/ContainerSizeProcessorTest.php index c7fc9f8b4..ab761907e 100644 --- a/test/qtismtest/runtime/expressions/operators/ContainerSizeProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/ContainerSizeProcessorTest.php @@ -21,7 +21,7 @@ */ class ContainerSizeProcessorTest extends QtiSmTestCase { - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -29,7 +29,7 @@ public function testNotEnoughOperands() $processor = new ContainerSizeProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -39,7 +39,7 @@ public function testTooMuchOperands() $processor = new ContainerSizeProcessor($expression, $operands); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([null]); @@ -55,7 +55,7 @@ public function testNull() $this::assertSame(0, $result->getValue()); } - public function testWrongCardinalityOne() + public function testWrongCardinalityOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(25)]); @@ -64,7 +64,7 @@ public function testWrongCardinalityOne() $result = $processor->process(); } - public function testWrongCardinalityTwo() + public function testWrongCardinalityTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new RecordContainer(['1' => new QtiFloat(1.0), '2' => new QtiInteger(2)])]); @@ -73,7 +73,7 @@ public function testWrongCardinalityTwo() $result = $processor->process(); } - public function testSize() + public function testSize(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -93,7 +93,7 @@ public function testSize() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/ContainsProcessorTest.php b/test/qtismtest/runtime/expressions/operators/ContainsProcessorTest.php index bf21b1ff0..b88616f4c 100644 --- a/test/qtismtest/runtime/expressions/operators/ContainsProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/ContainsProcessorTest.php @@ -24,7 +24,7 @@ */ class ContainsProcessorTest extends QtiSmTestCase { - public function testPrimitiveOrderedTrailing() + public function testPrimitiveOrderedTrailing(): void { $expression = $this->createFakeExpression(); @@ -54,7 +54,7 @@ public function testPrimitiveOrderedTrailing() $this::assertFalse($result->getValue()); } - public function testPrimitiveOrderedLeading() + public function testPrimitiveOrderedLeading(): void { $expression = $this->createFakeExpression(); @@ -76,7 +76,7 @@ public function testPrimitiveOrderedLeading() $this::assertFalse($result->getValue()); } - public function testPrimitiveOrderedInBetween() + public function testPrimitiveOrderedInBetween(): void { $expression = $this->createFakeExpression(); @@ -106,7 +106,7 @@ public function testPrimitiveOrderedInBetween() $this::assertTrue($result->getValue()); } - public function testPrimitiveMultipleTrailing() + public function testPrimitiveMultipleTrailing(): void { $expression = $this->createFakeExpression(); @@ -136,7 +136,7 @@ public function testPrimitiveMultipleTrailing() $this::assertFalse($result->getValue()); } - public function testPrimitiveMultipleLeading() + public function testPrimitiveMultipleLeading(): void { $expression = $this->createFakeExpression(); @@ -158,7 +158,7 @@ public function testPrimitiveMultipleLeading() $this::assertTrue($result->getValue()); } - public function testPrimitiveMultipleInBetween() + public function testPrimitiveMultipleInBetween(): void { $expression = $this->createFakeExpression(); @@ -188,7 +188,7 @@ public function testPrimitiveMultipleInBetween() $this::assertTrue($result->getValue()); } - public function testComplexOrderedTrailing() + public function testComplexOrderedTrailing(): void { $expression = $this->createFakeExpression(); @@ -218,7 +218,7 @@ public function testComplexOrderedTrailing() $this::assertFalse($result->getValue()); } - public function testComplexOrderedLeading() + public function testComplexOrderedLeading(): void { $expression = $this->createFakeExpression(); @@ -240,7 +240,7 @@ public function testComplexOrderedLeading() $this::assertFalse($result->getValue()); } - public function testComplexOrderedInBetween() + public function testComplexOrderedInBetween(): void { $expression = $this->createFakeExpression(); @@ -270,7 +270,7 @@ public function testComplexOrderedInBetween() $this::assertTrue($result->getValue()); } - public function testComplexMultipleTrailing() + public function testComplexMultipleTrailing(): void { $expression = $this->createFakeExpression(); @@ -300,7 +300,7 @@ public function testComplexMultipleTrailing() $this::assertFalse($result->getValue()); } - public function testComplexMultipleLeading() + public function testComplexMultipleLeading(): void { $expression = $this->createFakeExpression(); @@ -330,7 +330,7 @@ public function testComplexMultipleLeading() $this::assertFalse($result->getValue()); } - public function testComplexMultipleInBetween() + public function testComplexMultipleInBetween(): void { $expression = $this->createFakeExpression(); @@ -360,7 +360,7 @@ public function testComplexMultipleInBetween() $this::assertTrue($result->getValue()); } - public function testMultipleOccurences() + public function testMultipleOccurences(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection( @@ -374,7 +374,7 @@ public function testMultipleOccurences() $this::assertTrue($result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([null, new MultipleContainer(BaseType::INTEGER, [new QtiInteger(25)])]); @@ -388,7 +388,7 @@ public function testNull() $this::assertNull($result); } - public function testNotSameBaseTypeOne() + public function testNotSameBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -399,7 +399,7 @@ public function testNotSameBaseTypeOne() $processor->process(); } - public function testNotSameBaseTypeTwo() + public function testNotSameBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -410,7 +410,7 @@ public function testNotSameBaseTypeTwo() $result = $processor->process(); } - public function testNotSameCardinality() + public function testNotSameCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -421,7 +421,7 @@ public function testNotSameCardinality() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -432,7 +432,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new MultipleContainer(BaseType::POINT, [new QtiPoint(1, 2)])]); @@ -440,7 +440,7 @@ public function testNotEnoughOperands() $processor = new ContainsProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -455,7 +455,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/DeleteProcessorTest.php b/test/qtismtest/runtime/expressions/operators/DeleteProcessorTest.php index c49c62bdc..8e36d8e7d 100644 --- a/test/qtismtest/runtime/expressions/operators/DeleteProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/DeleteProcessorTest.php @@ -20,7 +20,7 @@ */ class DeleteProcessorTest extends QtiSmTestCase { - public function testMultiple() + public function testMultiple(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -48,7 +48,7 @@ public function testMultiple() $this::assertFalse($result->contains(new QtiInteger(10))); } - public function testMultipleNotMatch() + public function testMultipleNotMatch(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -59,7 +59,7 @@ public function testMultipleNotMatch() $this::assertTrue($operands[1]->equals($result)); } - public function testEverythingRemoved() + public function testEverythingRemoved(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -71,7 +71,7 @@ public function testEverythingRemoved() $this::assertTrue($result->isNull()); } - public function testOrdered() + public function testOrdered(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -97,7 +97,7 @@ public function testOrdered() $this::assertFalse($result->contains(new QtiPoint(2, 4))); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -114,7 +114,7 @@ public function testNull() $this::assertNull($result); } - public function testDifferentBaseType() + public function testDifferentBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -125,7 +125,7 @@ public function testDifferentBaseType() $result = $processor->process(); } - public function testWrongCardinalityOne() + public function testWrongCardinalityOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -136,7 +136,7 @@ public function testWrongCardinalityOne() $result = $processor->process(); } - public function testWrongCardinalityTwo() + public function testWrongCardinalityTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -147,7 +147,7 @@ public function testWrongCardinalityTwo() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -155,7 +155,7 @@ public function testNotEnoughOperands() $processor = new DeleteProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -170,7 +170,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/DivideProcessorTest.php b/test/qtismtest/runtime/expressions/operators/DivideProcessorTest.php index 3f4375ae9..0a204ab6c 100644 --- a/test/qtismtest/runtime/expressions/operators/DivideProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/DivideProcessorTest.php @@ -20,7 +20,7 @@ */ class DivideProcessorTest extends QtiSmTestCase { - public function testDivide() + public function testDivide(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(1), new QtiInteger(1)]); @@ -54,7 +54,7 @@ public function testDivide() $this::assertEquals(2, $result->getValue()); } - public function testDivisionByZero() + public function testDivisionByZero(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(1), new QtiInteger(0)]); @@ -63,7 +63,7 @@ public function testDivisionByZero() $this::assertNull($result); } - public function testDivisionByInfinite() + public function testDivisionByInfinite(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(10), new QtiFloat(INF)]); @@ -79,7 +79,7 @@ public function testDivisionByInfinite() $this::assertEquals(-0, $result->getValue()); } - public function testInfiniteDividedByInfinite() + public function testInfiniteDividedByInfinite(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiFloat(INF), new QtiFloat(INF)]); @@ -88,7 +88,7 @@ public function testInfiniteDividedByInfinite() $this::assertNull($result); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString('string!'), new QtiBoolean(true)]); @@ -97,7 +97,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiPoint(1, 2), new QtiBoolean(true)]); @@ -106,7 +106,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new RecordContainer(['A' => new QtiInteger(1)]), new QtiInteger(10)]); @@ -115,7 +115,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -123,7 +123,7 @@ public function testNotEnoughOperands() $processor = new DivideProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(10), new QtiInteger(11), new QtiInteger(12)]); @@ -135,7 +135,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/DurationGTEProcessorTest.php b/test/qtismtest/runtime/expressions/operators/DurationGTEProcessorTest.php index 67a674261..0d7ef4c29 100644 --- a/test/qtismtest/runtime/expressions/operators/DurationGTEProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/DurationGTEProcessorTest.php @@ -19,7 +19,7 @@ */ class DurationGTEProcessorTest extends QtiSmTestCase { - public function testDurationGTE() + public function testDurationGTE(): void { // There is no need of intensive testing because // the main logic is contained in the Duration class. @@ -43,7 +43,7 @@ public function testDurationGTE() $this::assertTrue($result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiDuration('P1D'), null]); @@ -52,7 +52,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiDuration('P1D'), new QtiInteger(256)]); @@ -61,7 +61,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiDuration('P1D'), new MultipleContainer(BaseType::DURATION, [new QtiDuration('P2D')])]); @@ -70,7 +70,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -78,7 +78,7 @@ public function testNotEnoughOperands() $processor = new DurationGTEProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiDuration('P1D'), new QtiDuration('P2D'), new QtiDuration('P3D')]); @@ -90,7 +90,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/DurationLTProcessorTest.php b/test/qtismtest/runtime/expressions/operators/DurationLTProcessorTest.php index 36ab20fbf..5940222a1 100644 --- a/test/qtismtest/runtime/expressions/operators/DurationLTProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/DurationLTProcessorTest.php @@ -19,7 +19,7 @@ */ class DurationLTProcessorTest extends QtiSmTestCase { - public function testDurationLT() + public function testDurationLT(): void { // There is no need of intensive testing because // the main logic is contained in the Duration class. @@ -37,7 +37,7 @@ public function testDurationLT() $this::assertFalse($result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiDuration('P1D'), null]); @@ -46,7 +46,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiDuration('P1D'), new QtiInteger(256)]); @@ -55,7 +55,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiDuration('P1D'), new MultipleContainer(BaseType::DURATION, [new QtiDuration('P2D')])]); @@ -64,7 +64,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -72,7 +72,7 @@ public function testNotEnoughOperands() $processor = new DurationLTProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiDuration('P1D'), new QtiDuration('P2D'), new QtiDuration('P3D')]); @@ -84,7 +84,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/EqualProcessorTest.php b/test/qtismtest/runtime/expressions/operators/EqualProcessorTest.php index f18cdfaff..e9d3680a3 100644 --- a/test/qtismtest/runtime/expressions/operators/EqualProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/EqualProcessorTest.php @@ -24,7 +24,7 @@ */ class EqualProcessorTest extends QtiSmTestCase { - public function testExact() + public function testExact(): void { $expression = $this->createFakeExpression(ToleranceMode::EXACT); $operands = new OperandsCollection([new QtiInteger(10), new QtiInteger(10)]); @@ -52,7 +52,7 @@ public function testExact() $this::assertFalse($result->getValue()); } - public function testRelative() + public function testRelative(): void { // Only one tolerance attribute. $expression = $this->createFakeExpression(ToleranceMode::RELATIVE, [90]); @@ -114,7 +114,7 @@ public function testRelative() $this::assertFalse($result->getValue()); } - public function testAbsolute() + public function testAbsolute(): void { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, [0.1, 0.2]); $operands = new OperandsCollection([new QtiInteger(10), new QtiFloat(9.9)]); @@ -142,7 +142,7 @@ public function testAbsolute() $this::assertFalse($result->getValue()); } - public function testWithVariableRef() + public function testWithVariableRef(): void { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, ['t0', 't1']); $operands = new OperandsCollection([new QtiInteger(10), new QtiFloat(9.9)]); @@ -181,7 +181,7 @@ public function testWithVariableRef() $this::assertFalse($result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, [0.1, 0.2]); $operands = new OperandsCollection([new QtiInteger(10), null]); @@ -190,7 +190,7 @@ public function testNull() $this::assertNull($result); } - public function testNoVariableRef() + public function testNoVariableRef(): void { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, ['t0']); $operands = new OperandsCollection([new QtiInteger(10), new QtiFloat(9.9)]); @@ -202,7 +202,7 @@ public function testNoVariableRef() $processor->process(); } - public function testNoSecondVariableRef() + public function testNoSecondVariableRef(): void { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, ['t0', 't1']); $operands = new OperandsCollection([new QtiInteger(10), new QtiFloat(9.9)]); @@ -220,7 +220,7 @@ public function testNoSecondVariableRef() $this::assertFalse($result->getValue()); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, [0.1, 0.2]); $operands = new OperandsCollection([new QtiInteger(10), new QtiString('String!')]); @@ -229,7 +229,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, [0.1, 0.2]); $operands = new OperandsCollection([new RecordContainer(['A' => new QtiInteger(1)]), new QtiInteger(10)]); @@ -238,7 +238,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, [0.1, 0.2]); $operands = new OperandsCollection([new QtiInteger(10)]); @@ -246,7 +246,7 @@ public function testNotEnoughOperands() $processor = new EqualProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(ToleranceMode::ABSOLUTE, [0.1, 0.2]); $operands = new OperandsCollection([new QtiInteger(10), new QtiInteger(10), new QtiInteger(10)]); @@ -262,7 +262,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression($toleranceMode, array $tolerance = [], $includeLowerBound = true, $includeUpperBound = true) + public function createFakeExpression($toleranceMode, array $tolerance = [], $includeLowerBound = true, $includeUpperBound = true): QtiComponent { $tm = ($toleranceMode != ToleranceMode::EXACT) ? ('tolerance="' . implode(' ', $tolerance) . '"') : ''; $toleranceMode = ToleranceMode::getNameByConstant($toleranceMode); diff --git a/test/qtismtest/runtime/expressions/operators/EqualRoundedProcessorTest.php b/test/qtismtest/runtime/expressions/operators/EqualRoundedProcessorTest.php index 91345f13d..b9b47a910 100644 --- a/test/qtismtest/runtime/expressions/operators/EqualRoundedProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/EqualRoundedProcessorTest.php @@ -23,7 +23,7 @@ */ class EqualRoundedProcessorTest extends QtiSmTestCase { - public function testSignificantFigures() + public function testSignificantFigures(): void { $expression = $this->createFakeExpression(RoundingMode::SIGNIFICANT_FIGURES, 3); $operands = new OperandsCollection([new QtiFloat(3.175), new QtiFloat(3.183)]); @@ -37,7 +37,7 @@ public function testSignificantFigures() $this::assertFalse($result->getValue()); } - public function testDecimalPlaces() + public function testDecimalPlaces(): void { $expression = $this->createFakeExpression(RoundingMode::DECIMAL_PLACES, 2); $operands = new OperandsCollection([new QtiFloat(1.68572), new QtiFloat(1.69)]); @@ -51,7 +51,7 @@ public function testDecimalPlaces() $this::assertFalse($result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(RoundingMode::DECIMAL_PLACES, 2); $operands = new OperandsCollection([new QtiFloat(1.68572), null]); @@ -60,7 +60,7 @@ public function testNull() $this::assertNull($result); } - public function testVariableRef() + public function testVariableRef(): void { $expression = $this->createFakeExpression(RoundingMode::SIGNIFICANT_FIGURES, 'var1'); $operands = new OperandsCollection([new QtiFloat(3.175), new QtiFloat(3.183)]); @@ -74,7 +74,7 @@ public function testVariableRef() $this::assertTrue($result->getValue()); } - public function testUnknownVariableRef() + public function testUnknownVariableRef(): void { $expression = $this->createFakeExpression(RoundingMode::SIGNIFICANT_FIGURES, 'var1'); $operands = new OperandsCollection([new QtiFloat(3.175), new QtiFloat(3.183)]); @@ -89,7 +89,7 @@ public function testUnknownVariableRef() $this::assertTrue($result->getValue()); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(RoundingMode::DECIMAL_PLACES, 2); $operands = new OperandsCollection([new QtiPair('A', 'B'), new QtiInteger(3)]); @@ -98,7 +98,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(RoundingMode::DECIMAL_PLACES, 2); $operands = new OperandsCollection([new QtiInteger(10), new RecordContainer(['A' => new QtiInteger(1337)])]); @@ -107,7 +107,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(RoundingMode::DECIMAL_PLACES, 2); $operands = new OperandsCollection([new QtiInteger(10)]); @@ -115,7 +115,7 @@ public function testNotEnoughOperands() $processor = new EqualRoundedProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(RoundingMode::DECIMAL_PLACES, 2); $operands = new OperandsCollection([new QtiInteger(10), new QtiInteger(10), new QtiInteger(10)]); @@ -129,7 +129,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression($roundingMode, $figures) + public function createFakeExpression($roundingMode, $figures): QtiComponent { $roundingMode = RoundingMode::getNameByConstant($roundingMode); diff --git a/test/qtismtest/runtime/expressions/operators/FieldValueProcessorTest.php b/test/qtismtest/runtime/expressions/operators/FieldValueProcessorTest.php index aaae5e6ff..dc72bbb19 100644 --- a/test/qtismtest/runtime/expressions/operators/FieldValueProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/FieldValueProcessorTest.php @@ -19,7 +19,7 @@ */ class FieldValueProcessorTest extends QtiSmTestCase { - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -27,7 +27,7 @@ public function testNotEnoughOperands() $processor = new FieldValueProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -37,7 +37,7 @@ public function testTooMuchOperands() $processor = new FieldValueProcessor($expression, $operands); } - public function testNullOne() + public function testNullOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -49,7 +49,7 @@ public function testNullOne() $this::assertNull($result); } - public function testNullTwo() + public function testNullTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -60,7 +60,7 @@ public function testNullTwo() $result = $processor->process(); } - public function testWrongCardinalityOne() + public function testWrongCardinalityOne(): void { // primitive PHP. $expression = $this->createFakeExpression(); @@ -71,7 +71,7 @@ public function testWrongCardinalityOne() $result = $processor->process(); } - public function testWrongCardinalityTwo() + public function testWrongCardinalityTwo(): void { // primitive QTI (Point, Duration, ...) $expression = $this->createFakeExpression(); @@ -82,7 +82,7 @@ public function testWrongCardinalityTwo() $result = $processor->process(); } - public function testWrongCardinalityThree() + public function testWrongCardinalityThree(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -94,7 +94,7 @@ public function testWrongCardinalityThree() $result = $processor->process(); } - public function testFieldValue() + public function testFieldValue(): void { $expression = $this->createFakeExpression('B'); @@ -116,7 +116,7 @@ public function testFieldValue() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression($identifier = '') + public function createFakeExpression($identifier = ''): QtiComponent { // The following XML Component creation // underlines the need of a operator... :) diff --git a/test/qtismtest/runtime/expressions/operators/GcdProcessorTest.php b/test/qtismtest/runtime/expressions/operators/GcdProcessorTest.php index 774ecd4ef..cbc17eb0f 100644 --- a/test/qtismtest/runtime/expressions/operators/GcdProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/GcdProcessorTest.php @@ -27,7 +27,7 @@ class GcdProcessorTest extends QtiSmTestCase * @param int $expected * @throws MarshallerNotFoundException */ - public function testGcd(array $operands, $expected) + public function testGcd(array $operands, $expected): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection($operands); @@ -35,7 +35,7 @@ public function testGcd(array $operands, $expected) $this::assertSame($expected, $processor->process()->getValue()); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -43,7 +43,7 @@ public function testNotEnoughOperands() $processor = new GcdProcessor($expression, $operands); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new MultipleContainer(BaseType::STRING, [new QtiString('String!')]), new QtiInteger(10)]); @@ -52,7 +52,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(10), new QtiInteger(20), new RecordContainer(['A' => new QtiInteger(10)]), new QtiInteger(30)]); @@ -66,7 +66,7 @@ public function testWrongCardinality() * @param array $operands * @throws MarshallerNotFoundException */ - public function testGcdWithNullValues(array $operands) + public function testGcdWithNullValues(array $operands): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection($operands); @@ -77,7 +77,7 @@ public function testGcdWithNullValues(array $operands) /** * @return array */ - public function gcdProvider() + public function gcdProvider(): array { return [ [[new QtiInteger(45), new QtiInteger(60), new QtiInteger(330)], 15], @@ -98,7 +98,7 @@ public function gcdProvider() /** * @return array */ - public function gcdWithNullValuesProvider() + public function gcdWithNullValuesProvider(): array { return [ [[new QtiInteger(45), null, new QtiInteger(330)]], @@ -114,7 +114,7 @@ public function gcdWithNullValuesProvider() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/GtProcessorTest.php b/test/qtismtest/runtime/expressions/operators/GtProcessorTest.php index 1c5728b39..50c4a080e 100644 --- a/test/qtismtest/runtime/expressions/operators/GtProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/GtProcessorTest.php @@ -19,7 +19,7 @@ */ class GtProcessorTest extends QtiSmTestCase { - public function testGt() + public function testGt(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -45,7 +45,7 @@ public function testGt() $this::assertFalse($result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -56,7 +56,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -67,7 +67,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -78,7 +78,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -89,7 +89,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -97,7 +97,7 @@ public function testNotEnoughOperands() $processor = new GtProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(1), new QtiInteger(2), new QtiInteger(3)]); @@ -109,7 +109,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/GteProcessorTest.php b/test/qtismtest/runtime/expressions/operators/GteProcessorTest.php index d0834ac92..6ef2577c6 100644 --- a/test/qtismtest/runtime/expressions/operators/GteProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/GteProcessorTest.php @@ -19,7 +19,7 @@ */ class GteProcessorTest extends QtiSmTestCase { - public function testGte() + public function testGte(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -45,7 +45,7 @@ public function testGte() $this::assertTrue($result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -56,7 +56,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -67,7 +67,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -78,7 +78,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -89,7 +89,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -97,7 +97,7 @@ public function testNotEnoughOperands() $processor = new GteProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(1), new QtiInteger(2), new QtiInteger(3)]); @@ -109,7 +109,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/IndexProcessorTest.php b/test/qtismtest/runtime/expressions/operators/IndexProcessorTest.php index c93a6c352..96ae4d739 100644 --- a/test/qtismtest/runtime/expressions/operators/IndexProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/IndexProcessorTest.php @@ -22,7 +22,7 @@ */ class IndexProcessorTest extends QtiSmTestCase { - public function testIndexNumeric() + public function testIndexNumeric(): void { // first trial at the trail of the collection. $expression = $this->createFakeExpression(1); @@ -48,7 +48,7 @@ public function testIndexNumeric() $this::assertEquals(5, $result->getValue()); } - public function testIndexVariableReference() + public function testIndexVariableReference(): void { $expression = $this->createFakeExpression('variable1'); $operands = new OperandsCollection(); @@ -64,7 +64,7 @@ public function testIndexVariableReference() $this::assertEquals(3, $result->getValue()); } - public function testIndexVariableReferenceNotFound() + public function testIndexVariableReferenceNotFound(): void { $expression = $this->createFakeExpression('variable1'); $operands = new OperandsCollection(); @@ -78,7 +78,7 @@ public function testIndexVariableReferenceNotFound() $result = $processor->process(); } - public function testVariableReferenceNotInteger() + public function testVariableReferenceNotInteger(): void { $expression = $this->createFakeExpression('variable1'); $operands = new OperandsCollection(); @@ -92,7 +92,7 @@ public function testVariableReferenceNotInteger() $result = $processor->process(); } - public function testOutOfRangeOne() + public function testOutOfRangeOne(): void { // 1. non-zero integer $expression = $this->createFakeExpression(-3); @@ -103,7 +103,7 @@ public function testOutOfRangeOne() $result = $processor->process(); } - public function testOutOfRangeTwo() + public function testOutOfRangeTwo(): void { // 2. out of range $expression = $this->createFakeExpression(1000); @@ -114,7 +114,7 @@ public function testOutOfRangeTwo() $this::assertNull($result); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -124,7 +124,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -134,7 +134,7 @@ public function testNull() $this::assertNull($result); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -142,7 +142,7 @@ public function testNotEnoughOperands() $processor = new IndexProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -157,7 +157,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression($n = -1) + public function createFakeExpression($n = -1): QtiComponent { if ($n === -1) { $n = 3; diff --git a/test/qtismtest/runtime/expressions/operators/InsideProcessorTest.php b/test/qtismtest/runtime/expressions/operators/InsideProcessorTest.php index c5c4be5ba..6e8f5a64a 100644 --- a/test/qtismtest/runtime/expressions/operators/InsideProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/InsideProcessorTest.php @@ -22,7 +22,7 @@ */ class InsideProcessorTest extends QtiSmTestCase { - public function testRect() + public function testRect(): void { $coords = new QtiCoords(QtiShape::RECT, [0, 0, 5, 3]); $point = new QtiPoint(0, 0); // 0, 0 is inside. @@ -44,7 +44,7 @@ public function testRect() $this::assertFalse($result->getValue()); } - public function testPoly() + public function testPoly(): void { $coords = new QtiCoords(QtiShape::POLY, [0, 8, 7, 4, 2, 2, 8, -4, -2, 1]); $point = new QtiPoint(0, 8); // 0, 8 is inside. @@ -66,7 +66,7 @@ public function testPoly() $this::assertFalse($result->getValue()); } - public function testCircle() + public function testCircle(): void { $coords = new QtiCoords(QtiShape::CIRCLE, [5, 5, 5]); $point = new QtiPoint(3, 3); // 3,3 is inside @@ -88,7 +88,7 @@ public function testCircle() $this::assertFalse($result->getValue()); } - public function testNull() + public function testNull(): void { $coords = new QtiCoords(QtiShape::RECT, [0, 0, 5, 3]); $point = null; @@ -99,7 +99,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $coords = new QtiCoords(QtiShape::RECT, [0, 0, 5, 3]); $point = new QtiDuration('P1D'); @@ -110,7 +110,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $coords = new QtiCoords(QtiShape::RECT, [0, 0, 5, 3]); $point = new QtiInteger(10); @@ -121,7 +121,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $coords = new QtiCoords(QtiShape::RECT, [0, 0, 5, 3]); $point = new MultipleContainer(BaseType::POINT, [new QtiPoint(1, 2)]); @@ -132,7 +132,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $coords = new QtiCoords(QtiShape::RECT, [0, 0, 5, 3]); $point = new QtiPoint(1, 2); @@ -142,7 +142,7 @@ public function testNotEnoughOperands() $processor = new InsideProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $coords = new QtiCoords(QtiShape::RECT, [0, 0, 5, 3]); $point = new QtiPoint(1, 2); @@ -158,7 +158,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression($point = null, QtiCoords $coords = null) + public function createFakeExpression($point = null, QtiCoords $coords = null): QtiComponent { $point = ($point === null || !$point instanceof QtiPoint) ? new QtiPoint(2, 2) : $point; $coords = ($coords === null) ? new QtiCoords(QtiShape::RECT, [0, 0, 5, 3]) : $coords; diff --git a/test/qtismtest/runtime/expressions/operators/IntegerDivideProcessorTest.php b/test/qtismtest/runtime/expressions/operators/IntegerDivideProcessorTest.php index bb884a296..27a9ec6ac 100644 --- a/test/qtismtest/runtime/expressions/operators/IntegerDivideProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/IntegerDivideProcessorTest.php @@ -19,7 +19,7 @@ */ class IntegerDivideProcessorTest extends QtiSmTestCase { - public function testIntegerDivide() + public function testIntegerDivide(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(10), new QtiInteger(5)]); @@ -35,7 +35,7 @@ public function testIntegerDivide() $this::assertEquals(-10, $result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([null, new QtiInteger(5)]); @@ -44,7 +44,7 @@ public function testNull() $this::assertNull($result); } - public function testDivisionByZero() + public function testDivisionByZero(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(50), new QtiInteger(0)]); @@ -53,7 +53,7 @@ public function testDivisionByZero() $this::assertNull($result); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new MultipleContainer(BaseType::INTEGER, [new QtiInteger(10)]), new QtiInteger(5)]); @@ -62,7 +62,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString('ping!'), new QtiInteger(5)]); @@ -71,7 +71,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(5), new QtiDuration('P1D')]); @@ -80,7 +80,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(5)]); @@ -88,7 +88,7 @@ public function testNotEnoughOperands() $processor = new IntegerDivideProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(5), new QtiInteger(5), new QtiInteger(5)]); @@ -100,7 +100,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/IntegerModulusProcessorTest.php b/test/qtismtest/runtime/expressions/operators/IntegerModulusProcessorTest.php index eb1ad92f1..5a4532343 100644 --- a/test/qtismtest/runtime/expressions/operators/IntegerModulusProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/IntegerModulusProcessorTest.php @@ -19,7 +19,7 @@ */ class IntegerModulusProcessorTest extends QtiSmTestCase { - public function testIntegerModulus() + public function testIntegerModulus(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(10), new QtiInteger(5)]); @@ -41,7 +41,7 @@ public function testIntegerModulus() $this::assertEquals(1, $result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([null, new QtiInteger(5)]); @@ -50,7 +50,7 @@ public function testNull() $this::assertNull($result); } - public function testModulusByZero() + public function testModulusByZero(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(50), new QtiInteger(0)]); @@ -59,7 +59,7 @@ public function testModulusByZero() $this::assertNull($result); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new MultipleContainer(BaseType::INTEGER, [new QtiInteger(10)]), new QtiInteger(5)]); @@ -68,7 +68,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString('ping!'), new QtiInteger(5)]); @@ -77,7 +77,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(5), new QtiDuration('P1D')]); @@ -86,7 +86,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(5)]); @@ -94,7 +94,7 @@ public function testNotEnoughOperands() $processor = new IntegerModulusProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(5), new QtiInteger(5), new QtiInteger(5)]); @@ -106,7 +106,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/IntegerToFloatTest.php b/test/qtismtest/runtime/expressions/operators/IntegerToFloatTest.php index b6ddab891..8198a8e36 100644 --- a/test/qtismtest/runtime/expressions/operators/IntegerToFloatTest.php +++ b/test/qtismtest/runtime/expressions/operators/IntegerToFloatTest.php @@ -20,7 +20,7 @@ */ class IntegerToFloatProcessorTest extends QtiSmTestCase { - public function testIntegerToFloat() + public function testIntegerToFloat(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -50,7 +50,7 @@ public function testIntegerToFloat() $this::assertEquals(-0.0, $result->getValue()); } - public function testNullOne() + public function testNullOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -61,7 +61,7 @@ public function testNullOne() $this::assertNull($result); } - public function testNullTwo() + public function testNullTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -72,7 +72,7 @@ public function testNullTwo() $this::assertNull($result); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -83,7 +83,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -94,7 +94,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -105,7 +105,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -113,7 +113,7 @@ public function testNotEnoughOperands() $processor = new IntegerToFloatProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -127,7 +127,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/IsNullProcessorTest.php b/test/qtismtest/runtime/expressions/operators/IsNullProcessorTest.php index 01be72699..93e43937d 100644 --- a/test/qtismtest/runtime/expressions/operators/IsNullProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/IsNullProcessorTest.php @@ -23,7 +23,7 @@ */ class IsNullProcessorTest extends QtiSmTestCase { - public function testWithEmptyString() + public function testWithEmptyString(): void { $operands = new OperandsCollection(); $operands[] = new QtiString(''); @@ -33,7 +33,7 @@ public function testWithEmptyString() $this::assertTrue($processor->process()->getValue()); } - public function testWithNull() + public function testWithNull(): void { $operands = new OperandsCollection(); $operands[] = null; @@ -43,7 +43,7 @@ public function testWithNull() $this::assertTrue($processor->process()->getValue()); } - public function testEmptyContainers() + public function testEmptyContainers(): void { $operands = new OperandsCollection(); $operands[] = new MultipleContainer(BaseType::POINT); @@ -61,7 +61,7 @@ public function testEmptyContainers() $this::assertTrue($processor->process()->getValue()); } - public function testNotEmpty() + public function testNotEmpty(): void { $expression = $this->getFakeExpression(); $operands = new OperandsCollection([new QtiInteger(0)]); @@ -94,7 +94,7 @@ public function testNotEmpty() $this::assertFalse($processor->process()->getValue()); } - public function testLessThanNeededOperands() + public function testLessThanNeededOperands(): void { $this->expectException(ExpressionProcessingException::class); @@ -104,7 +104,7 @@ public function testLessThanNeededOperands() $result = $processor->process(); } - public function testMoreThanNeededOperands() + public function testMoreThanNeededOperands(): void { $this->expectException(ExpressionProcessingException::class); @@ -118,7 +118,7 @@ public function testMoreThanNeededOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - private function getFakeExpression() + private function getFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/LcmProcessorTest.php b/test/qtismtest/runtime/expressions/operators/LcmProcessorTest.php index 9954333e8..66ac2c4c4 100644 --- a/test/qtismtest/runtime/expressions/operators/LcmProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/LcmProcessorTest.php @@ -26,7 +26,7 @@ class LcmProcessorTest extends QtiSmTestCase * @param int $expected * @throws MarshallerNotFoundException */ - public function testLcm(array $operands, $expected) + public function testLcm(array $operands, $expected): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection($operands); @@ -34,7 +34,7 @@ public function testLcm(array $operands, $expected) $this::assertSame($expected, $processor->process()->getValue()); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -42,7 +42,7 @@ public function testNotEnoughOperands() $processor = new LcmProcessor($expression, $operands); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new MultipleContainer(BaseType::STRING, [new QtiString('String!')]), new QtiInteger(10)]); @@ -51,7 +51,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(10), new QtiInteger(20), new RecordContainer(['A' => new QtiInteger(10)]), new QtiInteger(30)]); @@ -65,7 +65,7 @@ public function testWrongCardinality() * @param array $operands * @throws MarshallerNotFoundException */ - public function testGcdWithNullValues(array $operands) + public function testGcdWithNullValues(array $operands): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection($operands); @@ -76,7 +76,7 @@ public function testGcdWithNullValues(array $operands) /** * @return array */ - public function lcmProvider() + public function lcmProvider(): array { return [ [[new QtiInteger(0)], 0], @@ -97,7 +97,7 @@ public function lcmProvider() /** * @return array */ - public function lcmWithNullValuesProvider() + public function lcmWithNullValuesProvider(): array { return [ [[null]], @@ -113,7 +113,7 @@ public function lcmWithNullValuesProvider() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/LtProcessorTest.php b/test/qtismtest/runtime/expressions/operators/LtProcessorTest.php index 6bf633dcd..1b0d8ac46 100644 --- a/test/qtismtest/runtime/expressions/operators/LtProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/LtProcessorTest.php @@ -19,7 +19,7 @@ */ class LtProcessorTest extends QtiSmTestCase { - public function testLt() + public function testLt(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -45,7 +45,7 @@ public function testLt() $this::assertFalse($result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -56,7 +56,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -67,7 +67,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -78,7 +78,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -89,7 +89,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -97,7 +97,7 @@ public function testNotEnoughOperands() $processor = new LtProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(1), new QtiInteger(2), new QtiInteger(3)]); @@ -109,7 +109,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/LteProcessorTest.php b/test/qtismtest/runtime/expressions/operators/LteProcessorTest.php index 493f3eb4e..e3264b0d2 100644 --- a/test/qtismtest/runtime/expressions/operators/LteProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/LteProcessorTest.php @@ -19,7 +19,7 @@ */ class LteProcessorTest extends QtiSmTestCase { - public function testLte() + public function testLte(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -45,7 +45,7 @@ public function testLte() $this::assertTrue($result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -56,7 +56,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -67,7 +67,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -78,7 +78,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -89,7 +89,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -97,7 +97,7 @@ public function testNotEnoughOperands() $processor = new LteProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(1), new QtiInteger(2), new QtiInteger(3)]); @@ -109,7 +109,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/MatchProcessorTest.php b/test/qtismtest/runtime/expressions/operators/MatchProcessorTest.php index 72cac27f1..1fc8f2fa0 100644 --- a/test/qtismtest/runtime/expressions/operators/MatchProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/MatchProcessorTest.php @@ -24,7 +24,7 @@ */ class MatchProcessorTest extends QtiSmTestCase { - public function testScalar() + public function testScalar(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(10), new QtiInteger(10)]); @@ -36,7 +36,7 @@ public function testScalar() $this::assertNotTrue($processor->process()->getValue()); } - public function testContainer() + public function testContainer(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -53,7 +53,7 @@ public function testContainer() $this::assertNotTrue($processor->process()->getValue()); } - public function testFile() + public function testFile(): void { $fManager = new FileSystemFileManager(); $expression = $this->createFakeExpression(); @@ -81,7 +81,7 @@ public function testFile() $fManager->delete($file2); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -92,7 +92,7 @@ public function testWrongBaseType() $processor->process(); } - public function testWrongBaseTypeCompliance() + public function testWrongBaseTypeCompliance(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -105,7 +105,7 @@ public function testWrongBaseTypeCompliance() $processor->process(); } - public function testDifferentBaseTypesScalar() + public function testDifferentBaseTypesScalar(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -116,7 +116,7 @@ public function testDifferentBaseTypesScalar() $result = $processor->process(); } - public function testDifferentBaseTypesContainer() + public function testDifferentBaseTypesContainer(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -127,7 +127,7 @@ public function testDifferentBaseTypesContainer() $result = $processor->process(); } - public function testDifferentBaseTypesMixed() + public function testDifferentBaseTypesMixed(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -138,7 +138,7 @@ public function testDifferentBaseTypesMixed() $result = $processor->process(); } - public function testDifferentCardinalitiesOne() + public function testDifferentCardinalitiesOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -149,7 +149,7 @@ public function testDifferentCardinalitiesOne() $result = $processor->process(); } - public function testDifferentCardinalitiesTwo() + public function testDifferentCardinalitiesTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -160,7 +160,7 @@ public function testDifferentCardinalitiesTwo() $result = $processor->process(); } - public function testDifferentCardinalitiesThree() + public function testDifferentCardinalitiesThree(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -171,7 +171,7 @@ public function testDifferentCardinalitiesThree() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(15)]); @@ -179,7 +179,7 @@ public function testNotEnoughOperands() $processor = new MatchProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(25), new QtiInteger(25), new QtiInteger(25)]); @@ -187,7 +187,7 @@ public function testTooMuchOperands() $processor = new MatchProcessor($expression, $operands); } - public function testNullScalar() + public function testNullScalar(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiFloat(15.0), null]); @@ -195,7 +195,7 @@ public function testNullScalar() $this::assertNull($processor->process()); } - public function testNullContainer() + public function testNullContainer(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -209,7 +209,7 @@ public function testNullContainer() * @return QtiComponent * @throws MarshallerNotFoundException */ - private function createFakeExpression() + private function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/MathOperatorProcessorTest.php b/test/qtismtest/runtime/expressions/operators/MathOperatorProcessorTest.php index 251216a7e..3ee6152fa 100644 --- a/test/qtismtest/runtime/expressions/operators/MathOperatorProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/MathOperatorProcessorTest.php @@ -27,7 +27,7 @@ class MathOperatorProcessorTest extends QtiSmTestCase * @param number $expected * @throws MarshallerNotFoundException */ - public function testSin($operand, $expected) + public function testSin($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::SIN); $operands = new OperandsCollection([$operand]); @@ -44,7 +44,7 @@ public function testSin($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testCos($operand, $expected) + public function testCos($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::COS); $operands = new OperandsCollection([$operand]); @@ -61,7 +61,7 @@ public function testCos($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testTan($operand, $expected) + public function testTan($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::TAN); $operands = new OperandsCollection([$operand]); @@ -78,7 +78,7 @@ public function testTan($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testSec($operand, $expected) + public function testSec($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::SEC); $operands = new OperandsCollection([$operand]); @@ -95,7 +95,7 @@ public function testSec($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testCsc($operand, $expected) + public function testCsc($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::CSC); $operands = new OperandsCollection([$operand]); @@ -112,7 +112,7 @@ public function testCsc($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testCot($operand, $expected) + public function testCot($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::COT); $operands = new OperandsCollection([$operand]); @@ -129,7 +129,7 @@ public function testCot($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testAsin($operand, $expected) + public function testAsin($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::ASIN); $operands = new OperandsCollection([$operand]); @@ -147,7 +147,7 @@ public function testAsin($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testAtan2($operand1, $operand2, $expected) + public function testAtan2($operand1, $operand2, $expected): void { $expression = $this->createFakeExpression(MathFunctions::ATAN2); $operands = new OperandsCollection([$operand1, $operand2]); @@ -164,7 +164,7 @@ public function testAtan2($operand1, $operand2, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testAsec($operand, $expected) + public function testAsec($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::ASEC); $operands = new OperandsCollection([$operand]); @@ -181,7 +181,7 @@ public function testAsec($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testAcsc($operand, $expected) + public function testAcsc($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::ACSC); $operands = new OperandsCollection([$operand]); @@ -198,7 +198,7 @@ public function testAcsc($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testAcot($operand, $expected) + public function testAcot($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::ACOT); $operands = new OperandsCollection([$operand]); @@ -215,7 +215,7 @@ public function testAcot($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testLog($operand, $expected) + public function testLog($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::LOG); $operands = new OperandsCollection([$operand]); @@ -232,7 +232,7 @@ public function testLog($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testLn($operand, $expected) + public function testLn($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::LN); $operands = new OperandsCollection([$operand]); @@ -249,7 +249,7 @@ public function testLn($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testSinh($operand, $expected) + public function testSinh($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::SINH); $operands = new OperandsCollection([$operand]); @@ -266,7 +266,7 @@ public function testSinh($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testCosh($operand, $expected) + public function testCosh($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::COSH); $operands = new OperandsCollection([$operand]); @@ -283,7 +283,7 @@ public function testCosh($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testTanh($operand, $expected) + public function testTanh($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::TANH); $operands = new OperandsCollection([$operand]); @@ -300,7 +300,7 @@ public function testTanh($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testSech($operand, $expected) + public function testSech($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::SECH); $operands = new OperandsCollection([$operand]); @@ -317,7 +317,7 @@ public function testSech($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testCsch($operand, $expected) + public function testCsch($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::CSCH); $operands = new OperandsCollection([$operand]); @@ -334,7 +334,7 @@ public function testCsch($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testCoth($operand, $expected) + public function testCoth($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::COTH); $operands = new OperandsCollection([$operand]); @@ -351,7 +351,7 @@ public function testCoth($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testAbs($operand, $expected) + public function testAbs($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::ABS); $operands = new OperandsCollection([$operand]); @@ -368,7 +368,7 @@ public function testAbs($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testExp($operand, $expected) + public function testExp($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::EXP); $operands = new OperandsCollection([$operand]); @@ -385,7 +385,7 @@ public function testExp($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testSignum($operand, $expected) + public function testSignum($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::SIGNUM); $operands = new OperandsCollection([$operand]); @@ -402,7 +402,7 @@ public function testSignum($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testFloor($operand, $expected) + public function testFloor($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::FLOOR); $operands = new OperandsCollection([$operand]); @@ -418,7 +418,7 @@ public function testFloor($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testCeil($operand, $expected) + public function testCeil($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::CEIL); $operands = new OperandsCollection([$operand]); @@ -434,7 +434,7 @@ public function testCeil($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testToDegrees($operand, $expected) + public function testToDegrees($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::TO_DEGREES); $operands = new OperandsCollection([$operand]); @@ -451,7 +451,7 @@ public function testToDegrees($operand, $expected) * @param number $expected * @throws MarshallerNotFoundException */ - public function testToRadians($operand, $expected) + public function testToRadians($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::TO_RADIANS); $operands = new OperandsCollection([$operand]); @@ -468,7 +468,7 @@ public function testToRadians($operand, $expected) * @param $expected * @throws MarshallerNotFoundException */ - public function testAcos($operand, $expected) + public function testAcos($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::ACOS); $operands = new OperandsCollection([$operand]); @@ -485,7 +485,7 @@ public function testAcos($operand, $expected) * @param $expected * @throws MarshallerNotFoundException */ - public function testAtan($operand, $expected) + public function testAtan($operand, $expected): void { $expression = $this->createFakeExpression(MathFunctions::ATAN); $operands = new OperandsCollection([$operand]); @@ -499,7 +499,7 @@ public function testAtan($operand, $expected) * @param $expected * @param $value */ - protected function assertEqualsRounded($expected, $value) + protected function assertEqualsRounded($expected, $value): void { if ($expected === null) { $this::assertNull($value); @@ -514,7 +514,7 @@ protected function assertEqualsRounded($expected, $value) } } - public function testNonSingleCardinalityOperand() + public function testNonSingleCardinalityOperand(): void { $expression = $this->createFakeExpression(MathFunctions::CEIL); $operands = new OperandsCollection( @@ -530,7 +530,7 @@ public function testNonSingleCardinalityOperand() $result = $processor->process(); } - public function testNonNumericOperand() + public function testNonNumericOperand(): void { $expression = $this->createFakeExpression(MathFunctions::CEIL); $operands = new OperandsCollection( @@ -546,7 +546,7 @@ public function testNonNumericOperand() $processor->process(); } - public function testAtan2SingleOperator() + public function testAtan2SingleOperator(): void { $expression = $this->createFakeExpression(MathFunctions::ATAN2); $operands = new OperandsCollection( @@ -562,7 +562,7 @@ public function testAtan2SingleOperator() $processor->process(); } - public function testAtan2ThreeOperators() + public function testAtan2ThreeOperators(): void { $expression = $this->createFakeExpression(MathFunctions::ATAN2); $operands = new OperandsCollection( @@ -583,7 +583,7 @@ public function testAtan2ThreeOperators() /** * @return array */ - public function sinProvider() + public function sinProvider(): array { return [ [new QtiFloat(1.5708), 1], @@ -594,7 +594,7 @@ public function sinProvider() /** * @return array */ - public function cosProvider() + public function cosProvider(): array { return [ [new QtiInteger(25), 0.99120281], @@ -605,7 +605,7 @@ public function cosProvider() /** * @return array */ - public function tanProvider() + public function tanProvider(): array { return [ [new QtiFloat(2.65), -0.53543566], @@ -616,7 +616,7 @@ public function tanProvider() /** * @return array */ - public function secProvider() + public function secProvider(): array { return [ [new QtiFloat(deg2rad(85)), 11.4737], @@ -626,7 +626,7 @@ public function secProvider() /** * @return array */ - public function cscProvider() + public function cscProvider(): array { return [ [new QtiFloat(deg2rad(31.67)), 1.904667], @@ -636,7 +636,7 @@ public function cscProvider() /** * @return array */ - public function cotProvider() + public function cotProvider(): array { return [ [new QtiFloat(2.09), -0.571505], @@ -646,7 +646,7 @@ public function cotProvider() /** * @return array */ - public function asinProvider() + public function asinProvider(): array { return [ [new QtiInteger(2), null], @@ -658,7 +658,7 @@ public function asinProvider() /** * @return array */ - public function acosProvider() + public function acosProvider(): array { return [ [new QtiFloat(0.3), 1.266103673], @@ -668,7 +668,7 @@ public function acosProvider() /** * @return array */ - public function atanProvider() + public function atanProvider(): array { return [ [new QtiInteger(2), 1.107148718], @@ -678,7 +678,7 @@ public function atanProvider() /** * @return array */ - public function atan2Provider() + public function atan2Provider(): array { $data = [ [new QtiFloat(NAN), new QtiInteger(10), null], @@ -710,7 +710,7 @@ public function atan2Provider() /** * @return array */ - public function asecProvider() + public function asecProvider(): array { return [ [new QtiInteger(-5), 1.7721], @@ -723,7 +723,7 @@ public function asecProvider() /** * @return array */ - public function acscProvider() + public function acscProvider(): array { return [ [new QtiInteger(-5), -0.20135], @@ -735,7 +735,7 @@ public function acscProvider() /** * @return array */ - public function acotProvider() + public function acotProvider(): array { return [ [new QtiInteger(-5), -0.197396], @@ -746,7 +746,7 @@ public function acotProvider() /** * @return array */ - public function sinhProvider() + public function sinhProvider(): array { return [ [new QtiInteger(5), 74.203210578], @@ -760,7 +760,7 @@ public function sinhProvider() /** * @return array */ - public function coshProvider() + public function coshProvider(): array { return [ [new QtiInteger(0), 1], @@ -775,7 +775,7 @@ public function coshProvider() /** * @return array */ - public function tanhProvider() + public function tanhProvider(): array { return [ [new QtiInteger(0), 0], @@ -789,7 +789,7 @@ public function tanhProvider() /** * @return array */ - public function sechProvider() + public function sechProvider(): array { return [ [new QtiFloat(NAN), null], @@ -804,7 +804,7 @@ public function sechProvider() /** * @return array */ - public function cschProvider() + public function cschProvider(): array { return [ [new QtiFloat(NAN), null], @@ -819,7 +819,7 @@ public function cschProvider() /** * @return array */ - public function cothProvider() + public function cothProvider(): array { return [ [new QtiFloat(NAN), null], @@ -835,7 +835,7 @@ public function cothProvider() /** * @return array */ - public function logProvider() + public function logProvider(): array { return [ [new QtiFloat(-0.5), null], @@ -848,7 +848,7 @@ public function logProvider() /** * @return array */ - public function lnProvider() + public function lnProvider(): array { return [ [new QtiFloat(-0.5), null], @@ -861,7 +861,7 @@ public function lnProvider() /** * @return array */ - public function expProvider() + public function expProvider(): array { return [ [new QtiFloat(NAN), null], @@ -876,7 +876,7 @@ public function expProvider() /** * @return array */ - public function absProvider() + public function absProvider(): array { return [ [new QtiInteger(0), 0], @@ -895,7 +895,7 @@ public function absProvider() /** * @return array */ - public function signumProvider() + public function signumProvider(): array { return [ [new QtiInteger(0), 0], @@ -912,7 +912,7 @@ public function signumProvider() /** * @return array */ - public function floorProvider() + public function floorProvider(): array { return [ [new QtiInteger(10), 10], @@ -930,7 +930,7 @@ public function floorProvider() /** * @return array */ - public function ceilProvider() + public function ceilProvider(): array { return [ [new QtiInteger(10), 10], @@ -948,7 +948,7 @@ public function ceilProvider() /** * @return array */ - public function toDegreesProvider() + public function toDegreesProvider(): array { return [ [new QtiFloat(NAN), null], @@ -964,7 +964,7 @@ public function toDegreesProvider() /** * @return array */ - public function toRadiansProvider() + public function toRadiansProvider(): array { return [ [new QtiFloat(NAN), null], @@ -984,7 +984,7 @@ public function toRadiansProvider() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression($constant) + public function createFakeExpression($constant): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/MaxProcessorTest.php b/test/qtismtest/runtime/expressions/operators/MaxProcessorTest.php index 18571e335..b06703648 100644 --- a/test/qtismtest/runtime/expressions/operators/MaxProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/MaxProcessorTest.php @@ -21,7 +21,7 @@ */ class MaxProcessorTest extends QtiSmTestCase { - public function testWrongBaseType() + public function testWrongBaseType(): void { // As per QTI spec, // If any of the sub-expressions is NULL, the result is NULL. @@ -35,7 +35,7 @@ public function testWrongBaseType() $this::assertNull($result); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -51,7 +51,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -68,7 +68,7 @@ public function testNull() $this::assertNull($result); } - public function testAllIntegers() + public function testAllIntegers(): void { // As per QTI spec, // if all sub-expressions are of integer type, a single integer (ndlr: is returned). @@ -89,7 +89,7 @@ public function testAllIntegers() $this::assertEquals(100002, $result->getValue()); } - public function testMixed() + public function testMixed(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(10), new QtiFloat(26.4), new QtiInteger(-4), new QtiFloat(25.3)]); @@ -111,7 +111,7 @@ public function testMixed() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/MemberProcessorTest.php b/test/qtismtest/runtime/expressions/operators/MemberProcessorTest.php index 94930f76b..86c17a58f 100644 --- a/test/qtismtest/runtime/expressions/operators/MemberProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/MemberProcessorTest.php @@ -25,7 +25,7 @@ */ class MemberProcessorTest extends QtiSmTestCase { - public function testMultiple() + public function testMultiple(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -43,7 +43,7 @@ public function testMultiple() $this::assertTrue($result->getValue()); } - public function testOrdered() + public function testOrdered(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -61,7 +61,7 @@ public function testOrdered() $this::assertTrue($result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -81,7 +81,7 @@ public function testNull() $this::assertNull($result); } - public function testDifferentBaseTypeOne() + public function testDifferentBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -93,7 +93,7 @@ public function testDifferentBaseTypeOne() $processor->process(); } - public function testDifferentBaseTypeTwo() + public function testDifferentBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -104,7 +104,7 @@ public function testDifferentBaseTypeTwo() $result = $processor->process(); } - public function testWrongCardinalityOne() + public function testWrongCardinalityOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -115,7 +115,7 @@ public function testWrongCardinalityOne() $result = $processor->process(); } - public function testWrongCardinalityTwo() + public function testWrongCardinalityTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -126,7 +126,7 @@ public function testWrongCardinalityTwo() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -135,7 +135,7 @@ public function testNotEnoughOperands() $processor = new MemberProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -146,7 +146,7 @@ public function testTooMuchOperands() $processor = new MemberProcessor($expression, $operands); } - public function testSingleCardinalitySecondOperand() + public function testSingleCardinalitySecondOperand(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -163,7 +163,7 @@ public function testSingleCardinalitySecondOperand() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/MinProcessorTest.php b/test/qtismtest/runtime/expressions/operators/MinProcessorTest.php index 9acb6337b..0d24bf835 100644 --- a/test/qtismtest/runtime/expressions/operators/MinProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/MinProcessorTest.php @@ -21,7 +21,7 @@ */ class MinProcessorTest extends QtiSmTestCase { - public function testWrongBaseType() + public function testWrongBaseType(): void { // As per QTI spec, // If any of the sub-expressions is NULL, the result is NULL. @@ -35,7 +35,7 @@ public function testWrongBaseType() $this::assertNull($result); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -51,7 +51,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -68,7 +68,7 @@ public function testNull() $this::assertNull($result); } - public function testAllIntegers() + public function testAllIntegers(): void { // As per QTI spec, // if all sub-expressions are of integer type, a single integer (ndlr: is returned). @@ -89,7 +89,7 @@ public function testAllIntegers() $this::assertEquals(2094, $result->getValue()); } - public function testMixed() + public function testMixed(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(10), new QtiFloat(26.4), new QtiInteger(-4), new QtiFloat(25.3)]); @@ -111,7 +111,7 @@ public function testMixed() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/MultipleProcessorTest.php b/test/qtismtest/runtime/expressions/operators/MultipleProcessorTest.php index 967aef68e..6c2e38958 100644 --- a/test/qtismtest/runtime/expressions/operators/MultipleProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/MultipleProcessorTest.php @@ -22,7 +22,7 @@ */ class MultipleProcessorTest extends QtiSmTestCase { - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -69,7 +69,7 @@ public function testNull() $this::assertNull($result); } - public function testScalar() + public function testScalar(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -92,7 +92,7 @@ public function testScalar() $this::assertCount(1, $result); } - public function testContainer() + public function testContainer(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -108,7 +108,7 @@ public function testContainer() $this::assertTrue($result[2]->equals(new QtiPoint(3, 4))); } - public function testMixed() + public function testMixed(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -123,7 +123,7 @@ public function testMixed() $this::assertTrue($result[1]->equals(new QtiPoint(3, 4))); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -136,7 +136,7 @@ public function testWrongBaseTypeOne() $processor->process(); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -149,7 +149,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -168,7 +168,7 @@ public function testWrongCardinality() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/NotProcessorTest.php b/test/qtismtest/runtime/expressions/operators/NotProcessorTest.php index 274dd5eb8..1958e5690 100644 --- a/test/qtismtest/runtime/expressions/operators/NotProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/NotProcessorTest.php @@ -19,7 +19,7 @@ */ class NotProcessorTest extends QtiSmTestCase { - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -27,7 +27,7 @@ public function testNotEnoughOperands() $processor = new NotProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiBoolean(true), new QtiBoolean(false)]); @@ -35,7 +35,7 @@ public function testTooMuchOperands() $processor = new NotProcessor($expression, $operands); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new MultipleContainer(BaseType::POINT, [new QtiPoint(1, 2)])]); @@ -44,7 +44,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(25)]); @@ -53,7 +53,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([null]); @@ -62,7 +62,7 @@ public function testNull() $this::assertNull($result); } - public function testTrue() + public function testTrue(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiBoolean(false)]); @@ -71,7 +71,7 @@ public function testTrue() $this::assertTrue($result->getValue()); } - public function testFalse() + public function testFalse(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiBoolean(true)]); @@ -85,7 +85,7 @@ public function testFalse() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/OperandsCollectionTest.php b/test/qtismtest/runtime/expressions/operators/OperandsCollectionTest.php index e30eff30b..cf841e1f6 100644 --- a/test/qtismtest/runtime/expressions/operators/OperandsCollectionTest.php +++ b/test/qtismtest/runtime/expressions/operators/OperandsCollectionTest.php @@ -38,18 +38,18 @@ public function tearDown(): void /** * @return OperandsCollection */ - protected function getOperands() + protected function getOperands(): OperandsCollection { return $this->operands; } - public function testContainsNullEmpty() + public function testContainsNullEmpty(): void { $operands = $this->getOperands(); $this::assertFalse($operands->containsNull()); } - public function testContainsNullFullSingleCardinality() + public function testContainsNullFullSingleCardinality(): void { $operands = $this->getOperands(); $operands[] = new QtiInteger(15); @@ -66,7 +66,7 @@ public function testContainsNullFullSingleCardinality() $this::assertTrue($operands->containsNull()); } - public function testContainsNullMixed() + public function testContainsNullMixed(): void { $operands = $this->getOperands(); $operands[] = new MultipleContainer(BaseType::FLOAT); @@ -89,7 +89,7 @@ public function testContainsNullMixed() $this::assertFalse($operands->containsNull()); } - public function testExclusivelyNumeric() + public function testExclusivelyNumeric(): void { $operands = $this->getOperands(); $this::assertFalse($operands->exclusivelyNumeric()); @@ -129,7 +129,7 @@ public function testExclusivelyNumeric() $this::assertFalse($operands->exclusivelyNumeric()); } - public function testExclusivelyInteger() + public function testExclusivelyInteger(): void { $operands = $this->getOperands(); $this::assertFalse($operands->exclusivelyInteger()); @@ -163,7 +163,7 @@ public function testExclusivelyInteger() $this::assertFalse($operands->exclusivelyInteger()); } - public function testExclusivelyPoint() + public function testExclusivelyPoint(): void { $operands = $this->getOperands(); $this::assertFalse($operands->exclusivelyPoint()); @@ -197,7 +197,7 @@ public function testExclusivelyPoint() $this::assertFalse($operands->exclusivelyPoint()); } - public function testExclusivelyDuration() + public function testExclusivelyDuration(): void { $operands = $this->getOperands(); $this::assertFalse($operands->exclusivelyDuration()); @@ -231,7 +231,7 @@ public function testExclusivelyDuration() $this::assertFalse($operands->exclusivelyDuration()); } - public function testAnythingButRecord() + public function testAnythingButRecord(): void { $operands = $this->getOperands(); $this::assertTrue($operands->anythingButRecord()); @@ -267,7 +267,7 @@ public function testAnythingButRecord() $this::assertFalse($operands->anythingButRecord()); } - public function testExclusivelyMultipleOrOrdered() + public function testExclusivelyMultipleOrOrdered(): void { $operands = $this->getOperands(); $this::assertFalse($operands->exclusivelyMultipleOrOrdered()); @@ -305,7 +305,7 @@ public function testExclusivelyMultipleOrOrdered() $this::assertTrue($operands->exclusivelyMultipleOrOrdered()); } - public function testExclusivelySingleOrOrdered() + public function testExclusivelySingleOrOrdered(): void { $operands = $this->getOperands(); $operands[] = null; @@ -327,7 +327,7 @@ public function testExclusivelySingleOrOrdered() $this::assertFalse($operands->exclusivelySingleOrOrdered()); } - public function testExclusivelySingleOrMultiple() + public function testExclusivelySingleOrMultiple(): void { $operands = $this->getOperands(); $operands[] = null; @@ -349,7 +349,7 @@ public function testExclusivelySingleOrMultiple() $this::assertFalse($operands->exclusivelySingleOrMultiple()); } - public function testSameBaseType() + public function testSameBaseType(): void { // If any of the values is null, false. $operands = new OperandsCollection([null, null, null]); @@ -401,7 +401,7 @@ public function testSameBaseType() $this::assertFalse($operands->sameBaseType()); } - public function testSameCardinality() + public function testSameCardinality(): void { $operands = new OperandsCollection(); $this::assertFalse($operands->sameCardinality()); @@ -419,7 +419,7 @@ public function testSameCardinality() $this::assertFalse($operands->sameCardinality()); } - public function testExclusivelyBoolean() + public function testExclusivelyBoolean(): void { $operands = new OperandsCollection(); $this::assertFalse($operands->exclusivelyBoolean()); @@ -463,7 +463,7 @@ public function testExclusivelyBoolean() $this::assertFalse($operands->exclusivelyBoolean()); } - public function testExclusivelyRecord() + public function testExclusivelyRecord(): void { $operands = $this->getOperands(); $this::assertFalse($operands->exclusivelyRecord()); @@ -491,7 +491,7 @@ public function testExclusivelyRecord() $this::assertFalse($operands->exclusivelyRecord()); } - public function testExclusivelyOrdered() + public function testExclusivelyOrdered(): void { $operands = $this->getOperands(); $this::assertFalse($operands->exclusivelyOrdered()); @@ -524,7 +524,7 @@ public function testExclusivelyOrdered() $this::assertFalse($operands->exclusivelyOrdered()); } - public function testInvalidDataType() + public function testInvalidDataType(): void { $operands = $this->getOperands(); @@ -534,22 +534,22 @@ public function testInvalidDataType() $operands[] = 999; } - public function testExclusivelySingleNoValues() + public function testExclusivelySingleNoValues(): void { $this::assertFalse($this->getOperands()->exclusivelySingle()); } - public function testExclusivelyStringNoValues() + public function testExclusivelyStringNoValues(): void { $this::assertFalse($this->getOperands()->exclusivelyString()); } - public function testExclusivelySingleOrMultipleNoValues() + public function testExclusivelySingleOrMultipleNoValues(): void { $this::assertFalse($this->getOperands()->exclusivelySingleOrMultiple()); } - public function testExclusivelySingleOrOrderedNoValues() + public function testExclusivelySingleOrOrderedNoValues(): void { $this::assertFalse($this->getOperands()->exclusivelySingleOrOrdered()); } diff --git a/test/qtismtest/runtime/expressions/operators/OperatorProcessorFactoryTest.php b/test/qtismtest/runtime/expressions/operators/OperatorProcessorFactoryTest.php index 7363a92d6..6a440f48c 100644 --- a/test/qtismtest/runtime/expressions/operators/OperatorProcessorFactoryTest.php +++ b/test/qtismtest/runtime/expressions/operators/OperatorProcessorFactoryTest.php @@ -35,7 +35,7 @@ public function tearDown(): void spl_autoload_unregister('custom_operator_autoloader'); } - public function testCreateProcessor() + public function testCreateProcessor(): void { // get a fake sum expression. $expression = $this->createComponentFromXml( @@ -53,7 +53,7 @@ public function testCreateProcessor() $this::assertEquals(4, $processor->process()->getValue()); // x) } - public function testInvalidOperatorClass() + public function testInvalidOperatorClass(): void { $expression = $this->createComponentFromXml('String!'); $factory = new OperatorProcessorFactory(); @@ -62,7 +62,7 @@ public function testInvalidOperatorClass() $processor = $factory->createProcessor($expression); } - public function testCustomOperator() + public function testCustomOperator(): void { // Fake expression... $expression = $this->createComponentFromXml( @@ -79,7 +79,7 @@ public function testCustomOperator() $this::assertTrue($processor->process()->equals(new OrderedContainer(BaseType::STRING, [new QtiString('this'), new QtiString('is'), new QtiString('a'), new QtiString('test')]))); } - public function testCustomOperatorWithoutClassAttribute() + public function testCustomOperatorWithoutClassAttribute(): void { // Fake expression... $expression = $this->createComponentFromXml( @@ -96,7 +96,7 @@ public function testCustomOperatorWithoutClassAttribute() $factory->createProcessor($expression); } - public function testUnknownCustomOperator() + public function testUnknownCustomOperator(): void { // Fake expression... $expression = $this->createComponentFromXml( diff --git a/test/qtismtest/runtime/expressions/operators/OperatorsUtilsTest.php b/test/qtismtest/runtime/expressions/operators/OperatorsUtilsTest.php index f78cf6870..132b6e709 100644 --- a/test/qtismtest/runtime/expressions/operators/OperatorsUtilsTest.php +++ b/test/qtismtest/runtime/expressions/operators/OperatorsUtilsTest.php @@ -18,7 +18,7 @@ class OperatorsUtilsTest extends QtiSmTestCase * @param int $b * @param int $expected */ - public function testGcd($a, $b, $expected) + public function testGcd($a, $b, $expected): void { $result = OperatorsUtils::gcd($a, $b); $this::assertIsInt($result); @@ -32,7 +32,7 @@ public function testGcd($a, $b, $expected) * @param int $b * @param int $expected */ - public function testLcm($a, $b, $expected) + public function testLcm($a, $b, $expected): void { $result = OperatorsUtils::lcm($a, $b); $this::assertIsInt($result); @@ -45,7 +45,7 @@ public function testLcm($a, $b, $expected) * @param array $sample * @param number $expected */ - public function testMean(array $sample, $expected) + public function testMean(array $sample, $expected): void { $result = OperatorsUtils::mean($sample); $this::assertSame($expected, $result); @@ -58,7 +58,7 @@ public function testMean(array $sample, $expected) * @param bool Apply Bessel's correction? * @param number $expected */ - public function testVariance(array $sample, $correction, $expected) + public function testVariance(array $sample, $correction, $expected): void { $result = OperatorsUtils::variance($sample, $correction); $this::assertSame($expected, $result); @@ -71,7 +71,7 @@ public function testVariance(array $sample, $correction, $expected) * @param bool Apply Bessel's standard correction? * @param number $expected */ - public function testStandardDeviation(array $sample, $correction, $expected) + public function testStandardDeviation(array $sample, $correction, $expected): void { $result = OperatorsUtils::standardDeviation($sample, $correction); @@ -89,7 +89,7 @@ public function testStandardDeviation(array $sample, $correction, $expected) * @param int $offset * @param int $expected Expected preceding backslashes count. */ - public function testGetPrecedingBackslashesCount($string, $offset, $expected) + public function testGetPrecedingBackslashesCount($string, $offset, $expected): void { $this::assertSame($expected, OperatorsUtils::getPrecedingBackslashesCount($string, $offset)); } @@ -100,7 +100,7 @@ public function testGetPrecedingBackslashesCount($string, $offset, $expected) * @param string $string * @param string $expected */ - public function testPregAddDelimiter($string, $expected) + public function testPregAddDelimiter($string, $expected): void { $this::assertSame($expected, OperatorsUtils::pregAddDelimiter($string)); } @@ -112,7 +112,7 @@ public function testPregAddDelimiter($string, $expected) * @param array|string $symbols * @param string $expected */ - public function testEscapeSymbols($string, $symbols, $expected) + public function testEscapeSymbols($string, $symbols, $expected): void { $this::assertSame($expected, OperatorsUtils::escapeSymbols($string, $symbols)); } @@ -123,7 +123,7 @@ public function testEscapeSymbols($string, $symbols, $expected) * @param string $customClass * @param string $expected */ - public function testValidCustomOperatorClassToPhpClass($customClass, $expected) + public function testValidCustomOperatorClassToPhpClass($customClass, $expected): void { $this::assertEquals($expected, OperatorsUtils::customOperatorClassToPhpClass($customClass)); } @@ -133,7 +133,7 @@ public function testValidCustomOperatorClassToPhpClass($customClass, $expected) * * @param string $customClass */ - public function testInvalidCustomOperatorClassToPhpClass($customClass) + public function testInvalidCustomOperatorClassToPhpClass($customClass): void { $this::assertFalse(OperatorsUtils::customOperatorClassToPhpClass($customClass)); } @@ -146,7 +146,7 @@ public function testInvalidCustomOperatorClassToPhpClass($customClass) * @param string $message * @param int $recursionLimit */ - public function testLastPregErrorMessage($pcre, $subject, $message, $recursionLimit = 0) + public function testLastPregErrorMessage($pcre, $subject, $message, $recursionLimit = 0): void { if ($recursionLimit > 0) { $prevRecursionLimit = ini_get('pcre.recursion_limit'); @@ -165,7 +165,7 @@ public function testLastPregErrorMessage($pcre, $subject, $message, $recursionLi /** * @dataProvider patternForPcreProvider */ - public function testPrepareXsdPatternForPcre($pattern, $expected) + public function testPrepareXsdPatternForPcre($pattern, $expected): void { $this->assertEquals($expected, OperatorsUtils::prepareXsdPatternForPcre($pattern)); } @@ -173,7 +173,7 @@ public function testPrepareXsdPatternForPcre($pattern, $expected) /** * @return array */ - public function pregAddDelimiterProvider() + public function pregAddDelimiterProvider(): array { return [ ['', '//'], @@ -193,7 +193,7 @@ public function pregAddDelimiterProvider() /** * @return array */ - public function escapeSymbolsProvider() + public function escapeSymbolsProvider(): array { return [ ['10$ are 10$', ['$', '^'], '10\\$ are 10\\$'], @@ -207,7 +207,7 @@ public function escapeSymbolsProvider() /** * @return array */ - public function getPrecedingBackslashesCountProvider() + public function getPrecedingBackslashesCountProvider(): array { return [ ['', 0, 0], @@ -224,7 +224,7 @@ public function getPrecedingBackslashesCountProvider() /** * @return array */ - public function gcdProvider() + public function gcdProvider(): array { return [ [60, 330, 30], @@ -239,7 +239,7 @@ public function gcdProvider() /** * @return array */ - public function lcmProvider() + public function lcmProvider(): array { return [ [4, 3, 12], @@ -253,7 +253,7 @@ public function lcmProvider() /** * @return array */ - public function meanProvider() + public function meanProvider(): array { return [ [[], false], @@ -273,7 +273,7 @@ public function meanProvider() /** * @return array */ - public function varianceProvider() + public function varianceProvider(): array { return [ // [0] = sample; [1] = Bessel's correction, [2] = expected result @@ -292,7 +292,7 @@ public function varianceProvider() /** * @return array */ - public function standardDeviationProvider() + public function standardDeviationProvider(): array { // The equality test will be done with 2 significant figures. return [ @@ -310,7 +310,7 @@ public function standardDeviationProvider() /** * @return array */ - public function validCustomOperatorClassToPhpClassProvider() + public function validCustomOperatorClassToPhpClassProvider(): array { return [ ['com.taotesting.operators.custom.explode', "com\\taotesting\\operators\\custom\\Explode"], @@ -322,7 +322,7 @@ public function validCustomOperatorClassToPhpClassProvider() /** * @return array */ - public function invalidCustomOperatorClassToPhpClassProvider() + public function invalidCustomOperatorClassToPhpClassProvider(): array { return [ ['taotesting'], @@ -336,7 +336,7 @@ public function invalidCustomOperatorClassToPhpClassProvider() /** * @return array */ - public function lastPregErrorMessageProvider() + public function lastPregErrorMessageProvider(): array { return [ ['', 'foobar', 'PCRE Engine internal error'], diff --git a/test/qtismtest/runtime/expressions/operators/OrProcessorTest.php b/test/qtismtest/runtime/expressions/operators/OrProcessorTest.php index 971f3e9c1..b8d5e7ec3 100644 --- a/test/qtismtest/runtime/expressions/operators/OrProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/OrProcessorTest.php @@ -21,7 +21,7 @@ */ class OrProcessorTest extends QtiSmTestCase { - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -30,7 +30,7 @@ public function testNotEnoughOperands() $result = $processor->process(); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiPoint(1, 2)]); @@ -39,7 +39,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinalityOne() + public function testWrongCardinalityOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new RecordContainer(['a' => new QtiString('string!')])]); @@ -48,7 +48,7 @@ public function testWrongCardinalityOne() $result = $processor->process(); } - public function testWrongCardinalityTwo() + public function testWrongCardinalityTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new MultipleContainer(BaseType::FLOAT, [new QtiFloat(25.0)])]); @@ -57,7 +57,7 @@ public function testWrongCardinalityTwo() $result = $processor->process(); } - public function testNullOperands() + public function testNullOperands(): void { $expression = $this->createFakeExpression(); @@ -80,7 +80,7 @@ public function testNullOperands() $this::assertTrue($result->getValue()); } - public function testTrue() + public function testTrue(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiBoolean(true)]); @@ -96,7 +96,7 @@ public function testTrue() $this::assertTrue($result->getValue()); } - public function testFalse() + public function testFalse(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiBoolean(false)]); @@ -116,7 +116,7 @@ public function testFalse() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/OrderedProcessorTest.php b/test/qtismtest/runtime/expressions/operators/OrderedProcessorTest.php index 0712ba567..83f4b4370 100644 --- a/test/qtismtest/runtime/expressions/operators/OrderedProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/OrderedProcessorTest.php @@ -22,7 +22,7 @@ */ class OrderedProcessorTest extends QtiSmTestCase { - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -69,7 +69,7 @@ public function testNull() $this::assertNull($result); } - public function testScalar() + public function testScalar(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -92,7 +92,7 @@ public function testScalar() $this::assertCount(1, $result); } - public function testContainer() + public function testContainer(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -108,7 +108,7 @@ public function testContainer() $this::assertTrue($result[2]->equals(new QtiPoint(3, 4))); } - public function testMixed() + public function testMixed(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -123,7 +123,7 @@ public function testMixed() $this::assertTrue($result[1]->equals(new QtiPoint(3, 4))); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -136,7 +136,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -149,7 +149,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -168,7 +168,7 @@ public function testWrongCardinality() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/PatternMatchProcessorTest.php b/test/qtismtest/runtime/expressions/operators/PatternMatchProcessorTest.php index f1fd79c25..20ca6f46b 100644 --- a/test/qtismtest/runtime/expressions/operators/PatternMatchProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/PatternMatchProcessorTest.php @@ -28,7 +28,7 @@ class PatternMatchProcessorTest extends QtiSmTestCase * @param bool $expected * @throws MarshallerNotFoundException */ - public function testPatternMatch($string, $pattern, $expected) + public function testPatternMatch($string, $pattern, $expected): void { $expression = $this->createFakeExpression($pattern); $operands = new OperandsCollection([$string]); @@ -43,7 +43,7 @@ public function testPatternMatch($string, $pattern, $expected) * @param string $pattern * @throws MarshallerNotFoundException */ - public function testNull($string, $pattern) + public function testNull($string, $pattern): void { $expression = $this->createFakeExpression($pattern); $operands = new OperandsCollection([$string]); @@ -51,7 +51,7 @@ public function testNull($string, $pattern) $this::assertNull($processor->process()); } - public function testNotEnougOperands() + public function testNotEnougOperands(): void { $expression = $this->createFakeExpression('abc'); $operands = new OperandsCollection(); @@ -59,7 +59,7 @@ public function testNotEnougOperands() $processor = new PatternMatchProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression('abc'); $operands = new OperandsCollection([new QtiString('string'), new QtiString('string')]); @@ -67,7 +67,7 @@ public function testTooMuchOperands() $processor = new PatternMatchProcessor($expression, $operands); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression('abc'); $operands = new OperandsCollection([new RecordContainer(['A' => new QtiInteger(1)])]); @@ -76,7 +76,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression('abc'); $operands = new OperandsCollection([new QtiFloat(255.34)]); @@ -85,7 +85,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testInternalError() + public function testInternalError(): void { $expression = $this->createFakeExpression('['); $operands = new OperandsCollection([new QtiString('string!')]); @@ -102,7 +102,7 @@ public function testInternalError() /** * @return array */ - public function patternMatchProvider() + public function patternMatchProvider(): array { return [ [new QtiString('string'), 'string', true], @@ -122,7 +122,7 @@ public function patternMatchProvider() /** * @return array */ - public function nullProvider() + public function nullProvider(): array { return [ [null, '\d{1,2}'], @@ -136,7 +136,7 @@ public function nullProvider() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression($pattern) + public function createFakeExpression($pattern): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/PowerProcessorTest.php b/test/qtismtest/runtime/expressions/operators/PowerProcessorTest.php index e67a401ac..b8daff3a8 100644 --- a/test/qtismtest/runtime/expressions/operators/PowerProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/PowerProcessorTest.php @@ -19,7 +19,7 @@ */ class PowerProcessorTest extends QtiSmTestCase { - public function testPowerNormal() + public function testPowerNormal(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(0), new QtiInteger(0)]); @@ -64,7 +64,7 @@ public function testPowerNormal() $this::assertEquals(26515, (int)$result->getValue()); } - public function testOverflow() + public function testOverflow(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(2), new QtiInteger(100000000)]); @@ -73,7 +73,7 @@ public function testOverflow() $this::assertNull($result); } - public function testUnderflow() + public function testUnderflow(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(-2), new QtiInteger(333333333)]); @@ -82,7 +82,7 @@ public function testUnderflow() $this::assertNull($result); } - public function testInfinite() + public function testInfinite(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiFloat(INF), new QtiFloat(INF)]); @@ -91,7 +91,7 @@ public function testInfinite() $this::assertTrue(is_infinite($result->getValue())); } - public function testNull() + public function testNull(): void { // exp as a float is NaN when negative base is used. $expression = $this->createFakeExpression(); @@ -113,7 +113,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(-20), new QtiString('String!')]); @@ -122,7 +122,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(-20), new MultipleContainer(BaseType::INTEGER, [new QtiInteger(10)])]); @@ -131,7 +131,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(-20)]); @@ -139,7 +139,7 @@ public function testNotEnoughOperands() $processor = new PowerProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(-20), new QtiInteger(20), new QtiInteger(30)]); @@ -151,7 +151,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/ProductProcessorTest.php b/test/qtismtest/runtime/expressions/operators/ProductProcessorTest.php index 1f7c97e49..30ab5bb18 100644 --- a/test/qtismtest/runtime/expressions/operators/ProductProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/ProductProcessorTest.php @@ -22,7 +22,7 @@ */ class ProductProcessorTest extends QtiSmTestCase { - public function testSimple() + public function testSimple(): void { $product = $this->createFakeProductComponent(); @@ -35,7 +35,7 @@ public function testSimple() $this::assertEquals(1, $result->getValue()); } - public function testNary() + public function testNary(): void { $product = $this->createFakeProductComponent(); @@ -47,7 +47,7 @@ public function testNary() $this::assertEquals(-96, $result->getValue()); } - public function testComplex() + public function testComplex(): void { $product = $this->createFakeProductComponent(); @@ -61,7 +61,7 @@ public function testComplex() $this::assertEquals(-1354.5, $result->getValue()); } - public function testInvalidOperandsOne() + public function testInvalidOperandsOne(): void { $product = $this->createFakeProductComponent(); @@ -72,7 +72,7 @@ public function testInvalidOperandsOne() $result = $productProcessor->process(); } - public function testInvalidOperandsTwo() + public function testInvalidOperandsTwo(): void { $product = $this->createFakeProductComponent(); $operands = new OperandsCollection(); @@ -83,7 +83,7 @@ public function testInvalidOperandsTwo() $result = $productProcessor->process(); } - public function testNullInvolved() + public function testNullInvolved(): void { $product = $this->createFakeProductComponent(); $operands = new OperandsCollection([new QtiInteger(10), new QtiInteger(10), null]); @@ -92,7 +92,7 @@ public function testNullInvolved() $this::assertNull($result); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $product = $this->createFakeProductComponent(); $operands = new OperandsCollection(); @@ -104,7 +104,7 @@ public function testNotEnoughOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - private function createFakeProductComponent() + private function createFakeProductComponent(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/RandomProcessorTest.php b/test/qtismtest/runtime/expressions/operators/RandomProcessorTest.php index ec564fad4..18059fe26 100644 --- a/test/qtismtest/runtime/expressions/operators/RandomProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/RandomProcessorTest.php @@ -23,7 +23,7 @@ */ class RandomProcessorTest extends QtiSmTestCase { - public function testPrimitiveMultiple() + public function testPrimitiveMultiple(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -35,7 +35,7 @@ public function testPrimitiveMultiple() $this::assertLessThanOrEqual(3.0, $result->getValue()); } - public function testPrimitiveOrdered() + public function testPrimitiveOrdered(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -46,7 +46,7 @@ public function testPrimitiveOrdered() $this::assertTrue($result->equals(new QtiString('s1')) || $result->equals(new QtiString('s2')) || $result->equals(new QtiString('s3'))); } - public function testComplexMultiple() + public function testComplexMultiple(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -58,7 +58,7 @@ public function testComplexMultiple() $this::assertLessThanOrEqual(3, $result->getDays()); } - public function testComplexOrdered() + public function testComplexOrdered(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -70,7 +70,7 @@ public function testComplexOrdered() $this::assertLessThanOrEqual(3, $result->getY()); } - public function testOnlyOneInContainer() + public function testOnlyOneInContainer(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -82,7 +82,7 @@ public function testOnlyOneInContainer() $this::assertEquals(33, $result->getY()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -92,7 +92,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongCardinalityOne() + public function testWrongCardinalityOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -102,7 +102,7 @@ public function testWrongCardinalityOne() $result = $processor->process(); } - public function testWrongCardinalityTwo() + public function testWrongCardinalityTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -112,7 +112,7 @@ public function testWrongCardinalityTwo() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -121,7 +121,7 @@ public function testNotEnoughOperands() $result = $processor->process(); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -136,7 +136,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/RepeatProcessorTest.php b/test/qtismtest/runtime/expressions/operators/RepeatProcessorTest.php index e6ad4cf05..4e61b8010 100644 --- a/test/qtismtest/runtime/expressions/operators/RepeatProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/RepeatProcessorTest.php @@ -27,7 +27,7 @@ */ class RepeatProcessorTest extends QtiSmTestCase { - public function testRepeatScalarOnly() + public function testRepeatScalarOnly(): void { $initialVal = [new QtiInteger(1), new QtiInteger(2), new QtiInteger(3)]; $expression = $this->createFakeExpression(1); @@ -42,7 +42,7 @@ public function testRepeatScalarOnly() $this::assertTrue($result->equals(new OrderedContainer(BaseType::INTEGER, array_merge($initialVal, $initialVal)))); } - public function testRepeatVariableRef() + public function testRepeatVariableRef(): void { $initialVal = [new QtiInteger(1), new QtiInteger(2), new QtiInteger(3)]; $expression = $this->createFakeExpression('repeat'); @@ -54,7 +54,7 @@ public function testRepeatVariableRef() $this::assertTrue($result->equals(new OrderedContainer(BaseType::INTEGER, array_merge($initialVal, $initialVal)))); } - public function testRepeatVariableRefNullRef() + public function testRepeatVariableRefNullRef(): void { $initialVal = [new QtiInteger(1), new QtiInteger(2), new QtiInteger(3)]; $expression = $this->createFakeExpression('repeat'); @@ -67,7 +67,7 @@ public function testRepeatVariableRefNullRef() $processor->process(); } - public function testRepeatVariableRefNonIntegerRef() + public function testRepeatVariableRefNonIntegerRef(): void { $initialVal = [new QtiInteger(1), new QtiInteger(2), new QtiInteger(3)]; $expression = $this->createFakeExpression('repeat'); @@ -81,7 +81,7 @@ public function testRepeatVariableRefNonIntegerRef() $processor->process(); } - public function testOrderedOnly() + public function testOrderedOnly(): void { $expression = $this->createFakeExpression(2); $ordered1 = new OrderedContainer(BaseType::INTEGER, [new QtiInteger(1), new QtiInteger(2), new QtiInteger(3)]); @@ -94,7 +94,7 @@ public function testOrderedOnly() $this::assertTrue($comparison->equals($result)); } - public function testMixed() + public function testMixed(): void { $expression = $this->createFakeExpression(2); $operands = new OperandsCollection(); @@ -113,7 +113,7 @@ public function testMixed() $this::assertTrue($comparison->equals($result)); } - public function testNull() + public function testNull(): void { // If all sub-expressions are NULL, the result is NULL. $expression = $this->createFakeExpression(1); @@ -131,7 +131,7 @@ public function testNull() $this::assertTrue($result->equals($comparison)); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(1); $operands = new OperandsCollection(); @@ -146,7 +146,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new MultipleContainer(BaseType::INTEGER, [new QtiInteger(10)])]); @@ -155,7 +155,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new OrderedContainer(BaseType::INTEGER, [new QtiInteger(10)]), new QtiFloat(10.3)]); @@ -164,7 +164,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -177,7 +177,7 @@ public function testNotEnoughOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression($numberRepeats = 1) + public function createFakeExpression($numberRepeats = 1): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/RoundProcessorTest.php b/test/qtismtest/runtime/expressions/operators/RoundProcessorTest.php index be8174988..e04ddf49d 100644 --- a/test/qtismtest/runtime/expressions/operators/RoundProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/RoundProcessorTest.php @@ -20,7 +20,7 @@ */ class RoundProcessorTest extends QtiSmTestCase { - public function testRound() + public function testRound(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -86,7 +86,7 @@ public function testRound() $this::assertEquals(0, $result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -96,7 +96,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -106,7 +106,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -116,7 +116,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -126,7 +126,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -134,7 +134,7 @@ public function testNotEnoughOperands() $processor = new RoundProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -148,7 +148,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/RoundToProcessorTest.php b/test/qtismtest/runtime/expressions/operators/RoundToProcessorTest.php index 67e7c57d4..efa31bc76 100644 --- a/test/qtismtest/runtime/expressions/operators/RoundToProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/RoundToProcessorTest.php @@ -20,7 +20,7 @@ */ class RoundToProcessorTest extends QtiSmTestCase { - public function testSignificantFigures() + public function testSignificantFigures(): void { $expr = $this->createComponentFromXml(' @@ -66,7 +66,7 @@ public function testSignificantFigures() $this::assertEquals(round(-12.1, 1), round($result->getValue(), 1)); } - public function testFiguresFromRef() + public function testFiguresFromRef(): void { $expr = $this->createComponentFromXml(' @@ -89,7 +89,7 @@ public function testFiguresFromRef() $this::assertEquals(round(1240000), round($result->getValue())); } - public function testFiguresFromRefNoRef() + public function testFiguresFromRefNoRef(): void { $this->expectException(ExpressionProcessingException::class); @@ -105,7 +105,7 @@ public function testFiguresFromRefNoRef() $result = $processor->process(); } - public function testFiguresFromRefNonIntegerRef() + public function testFiguresFromRefNonIntegerRef(): void { $this->expectException(ExpressionProcessingException::class); @@ -130,7 +130,7 @@ public function testFiguresFromRefNonIntegerRef() $this::assertEquals(round(1240000), round($result->getValue())); } - public function testFiguresFromRefNegativeWhenSignificantFigureInUse() + public function testFiguresFromRefNegativeWhenSignificantFigureInUse(): void { $this->expectException(ExpressionProcessingException::class); @@ -155,7 +155,7 @@ public function testFiguresFromRefNegativeWhenSignificantFigureInUse() $this::assertEquals(round(1240000), round($result->getValue())); } - public function testDecimalPlaces() + public function testDecimalPlaces(): void { $expr = $this->createComponentFromXml(' @@ -203,7 +203,7 @@ public function testDecimalPlaces() $this::assertEquals(5.06, $result->getValue()); } - public function testNoOperands() + public function testNoOperands(): void { $this->expectException(ExpressionProcessingException::class); @@ -217,7 +217,7 @@ public function testNoOperands() $result = $processor->process(); } - public function testOperandsContainNull() + public function testOperandsContainNull(): void { $expr = $this->createComponentFromXml(' @@ -231,7 +231,7 @@ public function testOperandsContainNull() $this::assertNull($result); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $this->expectException(ExpressionProcessingException::class); @@ -245,7 +245,7 @@ public function testTooMuchOperands() $result = $processor->process(); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $this->expectException(ExpressionProcessingException::class); @@ -259,7 +259,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $this->expectException(ExpressionProcessingException::class); @@ -273,7 +273,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testWrongFiguresOne() + public function testWrongFiguresOne(): void { $this->expectException(ExpressionProcessingException::class); @@ -288,7 +288,7 @@ public function testWrongFiguresOne() $result = $processor->process(); } - public function testWrongFiguresTwo() + public function testWrongFiguresTwo(): void { $this->expectException(ExpressionProcessingException::class); @@ -302,7 +302,7 @@ public function testWrongFiguresTwo() $result = $processor->process(); } - public function testNan() + public function testNan(): void { $expr = $this->createComponentFromXml(' @@ -315,7 +315,7 @@ public function testNan() $this::assertNull($result); } - public function testInfinity() + public function testInfinity(): void { $expr = $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/StatsOperatorProcessorTest.php b/test/qtismtest/runtime/expressions/operators/StatsOperatorProcessorTest.php index 0dc270708..12e917f29 100644 --- a/test/qtismtest/runtime/expressions/operators/StatsOperatorProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/StatsOperatorProcessorTest.php @@ -31,7 +31,7 @@ class StatsOperatorProcessorTest extends QtiSmTestCase * @param float|null $expected * @throws MarshallerNotFoundException */ - public function testMean(Container $container = null, $expected) + public function testMean(Container $container = null, $expected): void { $expression = $this->createFakeExpression(Statistics::MEAN); $operands = new OperandsCollection([$container]); @@ -46,7 +46,7 @@ public function testMean(Container $container = null, $expected) * @param float|null $expected * @throws MarshallerNotFoundException */ - public function testSampleVariance(Container $container = null, $expected) + public function testSampleVariance(Container $container = null, $expected): void { $expression = $this->createFakeExpression(Statistics::SAMPLE_VARIANCE); $operands = new OperandsCollection([$container]); @@ -61,7 +61,7 @@ public function testSampleVariance(Container $container = null, $expected) * @param float|null $expected * @throws MarshallerNotFoundException */ - public function testSampleSD(Container $container = null, $expected) + public function testSampleSD(Container $container = null, $expected): void { $expression = $this->createFakeExpression(Statistics::SAMPLE_SD); $operands = new OperandsCollection([$container]); @@ -76,7 +76,7 @@ public function testSampleSD(Container $container = null, $expected) * @param float|null $expected * @throws MarshallerNotFoundException */ - public function testPopVariance(Container $container = null, $expected) + public function testPopVariance(Container $container = null, $expected): void { $expression = $this->createFakeExpression(Statistics::POP_VARIANCE); $operands = new OperandsCollection([$container]); @@ -91,7 +91,7 @@ public function testPopVariance(Container $container = null, $expected) * @param float|null $expected * @throws MarshallerNotFoundException */ - public function testPopSD(Container $container = null, $expected) + public function testPopSD(Container $container = null, $expected): void { $expression = $this->createFakeExpression(Statistics::POP_SD); $operands = new OperandsCollection([$container]); @@ -104,7 +104,7 @@ public function testPopSD(Container $container = null, $expected) * @param array $operands * @throws MarshallerNotFoundException */ - public function testWrongCardinality(array $operands) + public function testWrongCardinality(array $operands): void { $expression = $this->createFakeExpression(Statistics::MEAN); $operands = new OperandsCollection($operands); @@ -125,7 +125,7 @@ public function testWrongCardinality(array $operands) * @param array $operands * @throws MarshallerNotFoundException */ - public function testWrongBaseType(array $operands) + public function testWrongBaseType(array $operands): void { $expression = $this->createFakeExpression(Statistics::MEAN); $operands = new OperandsCollection($operands); @@ -140,7 +140,7 @@ public function testWrongBaseType(array $operands) } } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(Statistics::MEAN); $operands = new OperandsCollection(); @@ -148,7 +148,7 @@ public function testNotEnoughOperands() $processor = new StatsOperatorProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(Statistics::MEAN); $operands = new OperandsCollection([new OrderedContainer(BaseType::INTEGER, [new QtiInteger(10)]), new MultipleContainer(BaseType::FLOAT, [new QtiFloat(10.0)])]); @@ -160,7 +160,7 @@ public function testTooMuchOperands() * @param $expected * @param $value */ - protected function check($expected, $value) + protected function check($expected, $value): void { if ($expected === null) { $this::assertNull($value); @@ -173,7 +173,7 @@ protected function check($expected, $value) /** * @return array */ - public function meanProvider() + public function meanProvider(): array { return [ [new OrderedContainer(BaseType::FLOAT, [new QtiFloat(10.0), new QtiFloat(20.0), new QtiFloat(30.0)]), 20.0], @@ -186,7 +186,7 @@ public function meanProvider() /** * @return array */ - public function sampleVarianceProvider() + public function sampleVarianceProvider(): array { return [ [new OrderedContainer(BaseType::FLOAT, [new QtiFloat(10.0)]), null], // fails because containerSize <= 1 @@ -199,7 +199,7 @@ public function sampleVarianceProvider() /** * @return array */ - public function sampleSDProvider() + public function sampleSDProvider(): array { return [ [new OrderedContainer(BaseType::INTEGER, [new QtiInteger(10)]), null], // containerSize <= 1 @@ -212,7 +212,7 @@ public function sampleSDProvider() /** * @return array */ - public function popVarianceProvider() + public function popVarianceProvider(): array { return [ [new OrderedContainer(BaseType::INTEGER, [new QtiInteger(10)]), 0], // containerSize <= 1 but applied on a population -> OK. @@ -224,7 +224,7 @@ public function popVarianceProvider() /** * @return array */ - public function popSDProvider() + public function popSDProvider(): array { return [ [new OrderedContainer(BaseType::INTEGER, [new QtiInteger(10)]), 0], // containerSize <= 1 but applied on population @@ -236,7 +236,7 @@ public function popSDProvider() /** * @return array */ - public function wrongCardinalityProvider() + public function wrongCardinalityProvider(): array { return [ [[new QtiFloat(25.3)]], @@ -248,7 +248,7 @@ public function wrongCardinalityProvider() /** * @return array */ - public function wrongBaseTypeProvider() + public function wrongBaseTypeProvider(): array { return [ [[new MultipleContainer(BaseType::POINT, [new QtiPoint(1, 2)])]], @@ -261,7 +261,7 @@ public function wrongBaseTypeProvider() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression($name) + public function createFakeExpression($name): QtiComponent { $name = Statistics::getNameByConstant($name); diff --git a/test/qtismtest/runtime/expressions/operators/StringMatchProcessorTest.php b/test/qtismtest/runtime/expressions/operators/StringMatchProcessorTest.php index 0479a4d96..3a11de4c3 100644 --- a/test/qtismtest/runtime/expressions/operators/StringMatchProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/StringMatchProcessorTest.php @@ -19,7 +19,7 @@ */ class StringMatchProcessorTest extends QtiSmTestCase { - public function testStringMatch() + public function testStringMatch(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString('one'), new QtiString('one')]); @@ -54,7 +54,7 @@ public function testStringMatch() $this::assertFalse($result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString(''), null]); @@ -63,7 +63,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString('String!'), new MultipleContainer(BaseType::STRING, [new QtiString('String!')])]); @@ -72,7 +72,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString('String!'), new QtiInteger(25)]); @@ -81,7 +81,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString('String!')]); @@ -89,7 +89,7 @@ public function testNotEnoughOperands() $processor = new StringMatchProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString('String!'), new QtiString('String!'), new QtiString('String!')]); @@ -102,7 +102,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression($caseSensitive = true) + public function createFakeExpression($caseSensitive = true): QtiComponent { $str = ($caseSensitive === true) ? 'true' : 'false'; diff --git a/test/qtismtest/runtime/expressions/operators/SubstringProcessorTest.php b/test/qtismtest/runtime/expressions/operators/SubstringProcessorTest.php index 20485f8be..89907255f 100644 --- a/test/qtismtest/runtime/expressions/operators/SubstringProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/SubstringProcessorTest.php @@ -19,7 +19,7 @@ */ class SubstringProcessorTest extends QtiSmTestCase { - public function testCaseSensitive() + public function testCaseSensitive(): void { $expression = $this->createFakeExpression(true); $operands = new OperandsCollection(); @@ -38,7 +38,7 @@ public function testCaseSensitive() $this::assertFalse($result->getValue()); } - public function testCaseInsensitive() + public function testCaseInsensitive(): void { $expression = $this->createFakeExpression(false); $operands = new OperandsCollection(); @@ -86,7 +86,7 @@ public function testCaseInsensitive() $this::assertFalse($result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(false); $operands = new OperandsCollection(); @@ -103,7 +103,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(false); $operands = new OperandsCollection(); @@ -114,7 +114,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(false); $operands = new OperandsCollection(); @@ -125,7 +125,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(false); $operands = new OperandsCollection([new QtiString('only 1 operand')]); @@ -133,7 +133,7 @@ public function testNotEnoughOperands() $processor = new SubstringProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(false); $operands = new OperandsCollection([new QtiString('exactly'), new QtiString('three'), new QtiString('operands')]); @@ -146,7 +146,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression($caseSensitive = true) + public function createFakeExpression($caseSensitive = true): QtiComponent { $str = ($caseSensitive === true) ? 'true' : 'false'; diff --git a/test/qtismtest/runtime/expressions/operators/SubtractProcessorTest.php b/test/qtismtest/runtime/expressions/operators/SubtractProcessorTest.php index b4e0a338a..4cee8811d 100644 --- a/test/qtismtest/runtime/expressions/operators/SubtractProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/SubtractProcessorTest.php @@ -19,7 +19,7 @@ */ class SubtractProcessorTest extends QtiSmTestCase { - public function testSubtract() + public function testSubtract(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(10), new QtiInteger(256)]); @@ -35,7 +35,7 @@ public function testSubtract() $this::assertEquals(5, $result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(10), null]); @@ -49,7 +49,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(10), new QtiPoint(1, 2)]); @@ -58,7 +58,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new MultipleContainer(BaseType::INTEGER, [new QtiInteger(10)]), new QtiInteger(20)]); @@ -67,7 +67,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -75,7 +75,7 @@ public function testNotEnoughOperands() $processor = new SubtractProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(10), new QtiInteger(20), new QtiInteger(30), new QtiInteger(40)]); @@ -87,7 +87,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/SumProcessorTest.php b/test/qtismtest/runtime/expressions/operators/SumProcessorTest.php index c57b2dbe3..cb0d67aad 100644 --- a/test/qtismtest/runtime/expressions/operators/SumProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/SumProcessorTest.php @@ -21,7 +21,7 @@ */ class SumProcessorTest extends QtiSmTestCase { - public function testSimple() + public function testSimple(): void { $sum = $this->createFakeSumComponent(); @@ -34,7 +34,7 @@ public function testSimple() $this::assertEquals(2, $result->getValue()); } - public function testNary() + public function testNary(): void { $sum = $this->createFakeSumComponent(); @@ -46,7 +46,7 @@ public function testNary() $this::assertEquals(20, $result->getValue()); } - public function testComplex() + public function testComplex(): void { $sum = $this->createFakeSumComponent(); @@ -60,7 +60,7 @@ public function testComplex() $this::assertEquals(31.4, $result->getValue()); } - public function testZero() + public function testZero(): void { $sum = $this->createFakeSumComponent(); @@ -72,7 +72,7 @@ public function testZero() $this::assertEquals(6.0, $result->getValue()); } - public function testInvalidOperandsOne() + public function testInvalidOperandsOne(): void { $sum = $this->createFakeSumComponent(); @@ -83,7 +83,7 @@ public function testInvalidOperandsOne() $result = $sumProcessor->process(); } - public function testInvalidOperandsTwo() + public function testInvalidOperandsTwo(): void { $sum = $this->createFakeSumComponent(); $operands = new OperandsCollection(); @@ -94,7 +94,7 @@ public function testInvalidOperandsTwo() $result = $sumProcessor->process(); } - public function testNullInvolved() + public function testNullInvolved(): void { $sum = $this->createFakeSumComponent(); $operands = new OperandsCollection([new QtiInteger(10), new QtiInteger(10), null]); @@ -107,7 +107,7 @@ public function testNullInvolved() * @return QtiComponent * @throws MarshallerNotFoundException */ - private function createFakeSumComponent() + private function createFakeSumComponent(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/TruncateProcessorTest.php b/test/qtismtest/runtime/expressions/operators/TruncateProcessorTest.php index 82540ef31..f26ac5975 100644 --- a/test/qtismtest/runtime/expressions/operators/TruncateProcessorTest.php +++ b/test/qtismtest/runtime/expressions/operators/TruncateProcessorTest.php @@ -20,7 +20,7 @@ */ class TruncateProcessorTest extends QtiSmTestCase { - public function testRound() + public function testRound(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -109,7 +109,7 @@ public function testRound() $this::assertEquals(INF, $result->getValue()); } - public function testNull() + public function testNull(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -119,7 +119,7 @@ public function testNull() $this::assertNull($result); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -129,7 +129,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testWrongBaseTypeOne() + public function testWrongBaseTypeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -139,7 +139,7 @@ public function testWrongBaseTypeOne() $result = $processor->process(); } - public function testWrongBaseTypeTwo() + public function testWrongBaseTypeTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -149,7 +149,7 @@ public function testWrongBaseTypeTwo() $result = $processor->process(); } - public function testNotEnoughOperands() + public function testNotEnoughOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -157,7 +157,7 @@ public function testNotEnoughOperands() $processor = new TruncateProcessor($expression, $operands); } - public function testTooMuchOperands() + public function testTooMuchOperands(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -171,7 +171,7 @@ public function testTooMuchOperands() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' @@ -183,7 +183,7 @@ public function createFakeExpression() /** * @return array */ - public function provider() + public function provider(): array { return [ [97.2, 97], @@ -199,7 +199,7 @@ public function provider() * @param int $expected * @throws MarshallerNotFoundException */ - public function testForProvider($val, $expected) + public function testForProvider($val, $expected): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); diff --git a/test/qtismtest/runtime/expressions/operators/custom/CsvToMultipleTest.php b/test/qtismtest/runtime/expressions/operators/custom/CsvToMultipleTest.php index 7f43e70e0..abd3c8008 100644 --- a/test/qtismtest/runtime/expressions/operators/custom/CsvToMultipleTest.php +++ b/test/qtismtest/runtime/expressions/operators/custom/CsvToMultipleTest.php @@ -39,7 +39,7 @@ */ class CsvToMultipleTest extends QtiSmTestCase { - public function testSimple() { + public function testSimple(): void { $baseValue = new BaseValue(BaseType::STRING, 'Boba,Fett'); $customOperator = new CustomOperator( new ExpressionCollection(array($baseValue)), @@ -63,7 +63,7 @@ public function testSimple() { /** * @depends testSimple */ - public function testSingleStringValue() { + public function testSingleStringValue(): void { $baseValue = new BaseValue(BaseType::STRING, 'Boba'); $customOperator = new CustomOperator( new ExpressionCollection(array($baseValue)), @@ -86,7 +86,7 @@ public function testSingleStringValue() { /** * @depends testSimple */ - public function testReturnsNull() { + public function testReturnsNull(): void { $baseValue = new BaseValue(BaseType::BOOLEAN, false); $customOperator = new CustomOperator( new ExpressionCollection(array($baseValue)), @@ -102,7 +102,7 @@ public function testReturnsNull() { /** * @depends testSimple */ - public function testEmptyStringValue() { + public function testEmptyStringValue(): void { $baseValue = new BaseValue(BaseType::STRING, ''); $customOperator = new CustomOperator( new ExpressionCollection(array($baseValue)), diff --git a/test/qtismtest/runtime/expressions/operators/custom/CsvToOrderedTest.php b/test/qtismtest/runtime/expressions/operators/custom/CsvToOrderedTest.php index 8204252d6..83b540a6b 100644 --- a/test/qtismtest/runtime/expressions/operators/custom/CsvToOrderedTest.php +++ b/test/qtismtest/runtime/expressions/operators/custom/CsvToOrderedTest.php @@ -39,7 +39,7 @@ */ class CsvToOrderedTest extends QtiSmTestCase { - public function testSimple() { + public function testSimple(): void { $baseValue = new BaseValue(BaseType::STRING, 'Boba,Fett'); $customOperator = new CustomOperator( new ExpressionCollection(array($baseValue)), @@ -63,7 +63,7 @@ public function testSimple() { /** * @depends testSimple */ - public function testSingleStringValue() { + public function testSingleStringValue(): void { $baseValue = new BaseValue(BaseType::STRING, 'Boba'); $customOperator = new CustomOperator( new ExpressionCollection(array($baseValue)), @@ -86,7 +86,7 @@ public function testSingleStringValue() { /** * @depends testSimple */ - public function testReturnsNull() { + public function testReturnsNull(): void { $baseValue = new BaseValue(BaseType::BOOLEAN, false); $customOperator = new CustomOperator( new ExpressionCollection(array($baseValue)), @@ -102,7 +102,7 @@ public function testReturnsNull() { /** * @depends testSimple */ - public function testEmptyStringValue() { + public function testEmptyStringValue(): void { $baseValue = new BaseValue(BaseType::STRING, ''); $customOperator = new CustomOperator( new ExpressionCollection(array($baseValue)), diff --git a/test/qtismtest/runtime/expressions/operators/custom/ExplodeTest.php b/test/qtismtest/runtime/expressions/operators/custom/ExplodeTest.php index 7bd5f2435..5db790359 100644 --- a/test/qtismtest/runtime/expressions/operators/custom/ExplodeTest.php +++ b/test/qtismtest/runtime/expressions/operators/custom/ExplodeTest.php @@ -22,7 +22,7 @@ */ class ExplodeProcessorTest extends QtiSmTestCase { - public function testNotEnoughOperandsOne() + public function testNotEnoughOperandsOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -33,7 +33,7 @@ public function testNotEnoughOperandsOne() $result = $processor->process(); } - public function testNotEnoughOperandsTwo() + public function testNotEnoughOperandsTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString('Hello-World!')]); @@ -44,7 +44,7 @@ public function testNotEnoughOperandsTwo() $result = $processor->process(); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(2), new QtiPoint(0, 0)]); @@ -54,7 +54,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinality() + public function testWrongCardinality(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new RecordContainer(['a' => new QtiString('String!')]), new QtiString('Hey!')]); @@ -64,7 +64,7 @@ public function testWrongCardinality() $result = $processor->process(); } - public function testNullOperands() + public function testNullOperands(): void { $expression = $this->createFakeExpression(); @@ -75,7 +75,7 @@ public function testNullOperands() $this::assertNull($result); } - public function testExplodeOne() + public function testExplodeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString('-'), new QtiString('Hello-World-This-Is-Me')]); @@ -87,7 +87,7 @@ public function testExplodeOne() $this::assertEquals(['Hello', 'World', 'This', 'Is', 'Me'], $result->getArrayCopy()); } - public function testExplodeTwo() + public function testExplodeTwo(): void { // Specific case, the delimiter is not found in the original string. $expression = $this->createFakeExpression(); @@ -100,7 +100,7 @@ public function testExplodeTwo() $this::assertEquals(['Hello World!'], $result->getArrayCopy()); } - public function testExplodeThree() + public function testExplodeThree(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString(' '), new QtiString('Hello World!')]); @@ -116,7 +116,7 @@ public function testExplodeThree() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/custom/ImplodeTest.php b/test/qtismtest/runtime/expressions/operators/custom/ImplodeTest.php index 52dd9661c..d047a87c6 100644 --- a/test/qtismtest/runtime/expressions/operators/custom/ImplodeTest.php +++ b/test/qtismtest/runtime/expressions/operators/custom/ImplodeTest.php @@ -20,7 +20,7 @@ */ class ImplodeProcessorTest extends QtiSmTestCase { - public function testNotEnoughOperandsOne() + public function testNotEnoughOperandsOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection(); @@ -31,7 +31,7 @@ public function testNotEnoughOperandsOne() $result = $processor->process(); } - public function testNotEnoughOperandsTwo() + public function testNotEnoughOperandsTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString('Hello-World!')]); @@ -42,7 +42,7 @@ public function testNotEnoughOperandsTwo() $result = $processor->process(); } - public function testWrongBaseType() + public function testWrongBaseType(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiInteger(2), new QtiPoint(0, 0)]); @@ -52,7 +52,7 @@ public function testWrongBaseType() $result = $processor->process(); } - public function testWrongCardinalityOne() + public function testWrongCardinalityOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new MultipleContainer(BaseType::STRING, [new QtiString('String!')]), new QtiString('Hello World!')]); @@ -62,7 +62,7 @@ public function testWrongCardinalityOne() $result = $processor->process(); } - public function testWrongCardinalityTwo() + public function testWrongCardinalityTwo(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString('-'), new QtiString('Hello-World!')]); @@ -72,7 +72,7 @@ public function testWrongCardinalityTwo() $result = $processor->process(); } - public function testNullOperands() + public function testNullOperands(): void { $expression = $this->createFakeExpression(); @@ -82,7 +82,7 @@ public function testNullOperands() $this::assertNull($result); } - public function testImplodeOne() + public function testImplodeOne(): void { $expression = $this->createFakeExpression(); $operands = new OperandsCollection([new QtiString('-'), new MultipleContainer(BaseType::STRING, [new QtiString('Hello'), new QtiString('World')])]); @@ -97,7 +97,7 @@ public function testImplodeOne() * @return QtiComponent * @throws MarshallerNotFoundException */ - public function createFakeExpression() + public function createFakeExpression(): QtiComponent { return $this->createComponentFromXml(' diff --git a/test/qtismtest/runtime/expressions/operators/custom/custom_operator_autoloader.php b/test/qtismtest/runtime/expressions/operators/custom/custom_operator_autoloader.php index e18d3f5d8..df252cf1d 100644 --- a/test/qtismtest/runtime/expressions/operators/custom/custom_operator_autoloader.php +++ b/test/qtismtest/runtime/expressions/operators/custom/custom_operator_autoloader.php @@ -3,7 +3,7 @@ /** * @param $class */ -function custom_operator_autoloader($class) +function custom_operator_autoloader($class): void { $class = str_replace("\\", DIRECTORY_SEPARATOR, $class); $path = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php'; diff --git a/test/qtismtest/runtime/expressions/operators/custom/math/fraction/DenominatorTest.php b/test/qtismtest/runtime/expressions/operators/custom/math/fraction/DenominatorTest.php index af7da3962..77d946dd6 100644 --- a/test/qtismtest/runtime/expressions/operators/custom/math/fraction/DenominatorTest.php +++ b/test/qtismtest/runtime/expressions/operators/custom/math/fraction/DenominatorTest.php @@ -38,7 +38,7 @@ */ class DenominatorTest extends QtiSmTestCase { - public function testSimple() + public function testSimple(): void { $baseValue = new BaseValue(BaseType::STRING, '1/2'); $customOperator = new CustomOperator( @@ -52,7 +52,7 @@ public function testSimple() $this::assertEquals(2, $result->getValue()); } - public function testReturnsNullOne() + public function testReturnsNullOne(): void { $baseValue = new BaseValue(BaseType::BOOLEAN, false); $customOperator = new CustomOperator( @@ -66,7 +66,7 @@ public function testReturnsNullOne() $this::assertNull($result); } - public function testReturnsNullTwo() + public function testReturnsNullTwo(): void { $baseValue = new BaseValue(BaseType::BOOLEAN, false); $customOperator = new CustomOperator( diff --git a/test/qtismtest/runtime/expressions/operators/custom/math/fraction/NumeratorTest.php b/test/qtismtest/runtime/expressions/operators/custom/math/fraction/NumeratorTest.php index f03335e99..7f5086834 100644 --- a/test/qtismtest/runtime/expressions/operators/custom/math/fraction/NumeratorTest.php +++ b/test/qtismtest/runtime/expressions/operators/custom/math/fraction/NumeratorTest.php @@ -38,7 +38,7 @@ */ class NumeratorTest extends QtiSmTestCase { - public function testSimple() + public function testSimple(): void { $baseValue = new BaseValue(BaseType::STRING, '1/2'); $customOperator = new CustomOperator( @@ -52,7 +52,7 @@ public function testSimple() $this::assertEquals(1, $result->getValue()); } - public function testReturnsNullOne() + public function testReturnsNullOne(): void { $baseValue = new BaseValue(BaseType::BOOLEAN, false); $customOperator = new CustomOperator( @@ -66,7 +66,7 @@ public function testReturnsNullOne() $this::assertNull($result); } - public function testReturnsNullTwo() + public function testReturnsNullTwo(): void { $baseValue = new BaseValue(BaseType::BOOLEAN, false); $customOperator = new CustomOperator( diff --git a/test/qtismtest/runtime/expressions/operators/custom/math/graph/CountPointsThatSatisfyEquationTest.php b/test/qtismtest/runtime/expressions/operators/custom/math/graph/CountPointsThatSatisfyEquationTest.php index 0aeb8894b..faf87caa1 100644 --- a/test/qtismtest/runtime/expressions/operators/custom/math/graph/CountPointsThatSatisfyEquationTest.php +++ b/test/qtismtest/runtime/expressions/operators/custom/math/graph/CountPointsThatSatisfyEquationTest.php @@ -43,7 +43,7 @@ */ class CountPointsThatSatisfyEquationTest extends QtiSmTestCase { - public function testSimpleOne() + public function testSimpleOne(): void { // --- Build Custom Operator PHP Expression Model. $points = new Multiple( @@ -109,7 +109,7 @@ public function testSimpleOne() $this::assertEquals(8, $result->getValue()); } - public function testSimpleOneWithStrings() + public function testSimpleOneWithStrings(): void { // --- Build Custom Operator PHP Expression Model. $points = new Multiple( @@ -175,7 +175,7 @@ public function testSimpleOneWithStrings() $this::assertEquals(8, $result->getValue()); } - public function testSimpleTwo() + public function testSimpleTwo(): void { // --- Build Custom Operator PHP Expression Model. $points = new Multiple( @@ -241,7 +241,7 @@ public function testSimpleTwo() $this::assertEquals(6, $result->getValue()); } - public function testInvalidEquation() + public function testInvalidEquation(): void { // --- Build Custom Operator PHP Expression Model. $points = new Multiple( @@ -307,7 +307,7 @@ public function testInvalidEquation() $this::assertNull($result); } - public function testWrongEquationType() + public function testWrongEquationType(): void { // --- Build Custom Operator PHP Expression Model. $points = new Multiple( @@ -352,7 +352,7 @@ public function testWrongEquationType() $this::assertNull($result); } - public function testNullEquation() + public function testNullEquation(): void { // --- Build Custom Operator PHP Expression Model. $points = new Multiple( @@ -397,7 +397,7 @@ public function testNullEquation() $this::assertNull($result); } - public function testWrongPointsType() + public function testWrongPointsType(): void { // --- Build Custom Operator PHP Expression Model. $points = new Multiple( diff --git a/test/qtismtest/runtime/expressions/operators/custom/org/qtism/test/Explode.php b/test/qtismtest/runtime/expressions/operators/custom/org/qtism/test/Explode.php index 1a8aeb0fe..de931e570 100644 --- a/test/qtismtest/runtime/expressions/operators/custom/org/qtism/test/Explode.php +++ b/test/qtismtest/runtime/expressions/operators/custom/org/qtism/test/Explode.php @@ -17,7 +17,7 @@ class Explode extends CustomOperatorProcessor /** * @param OperandsCollection $operands */ - public function setOperands(OperandsCollection $operands) + public function setOperands(OperandsCollection $operands): void { $count = count($operands); diff --git a/test/qtismtest/runtime/expressions/operators/custom/text/StringToNumberTest.php b/test/qtismtest/runtime/expressions/operators/custom/text/StringToNumberTest.php index 07da96077..5c79c7f2f 100644 --- a/test/qtismtest/runtime/expressions/operators/custom/text/StringToNumberTest.php +++ b/test/qtismtest/runtime/expressions/operators/custom/text/StringToNumberTest.php @@ -38,7 +38,7 @@ */ class StringToNumberTest extends QtiSmTestCase { - public function testSimpleOne() { + public function testSimpleOne(): void { $baseValue = new BaseValue(BaseType::STRING, '13,37'); $customOperator = new CustomOperator( new ExpressionCollection(array($baseValue)), @@ -53,7 +53,7 @@ public function testSimpleOne() { $this::assertEquals($result->getValue(), (float)1337); } - public function testSimpleTwo() { + public function testSimpleTwo(): void { $baseValue = new BaseValue(BaseType::STRING, '13.37'); $customOperator = new CustomOperator( new ExpressionCollection(array($baseValue)), @@ -68,7 +68,7 @@ public function testSimpleTwo() { $this::assertEquals(round($result->getValue(), 2), round(13.37, 2)); } - public function testReturnsNull() { + public function testReturnsNull(): void { $baseValue = new BaseValue(BaseType::BOOLEAN, false); $customOperator = new CustomOperator( new ExpressionCollection(array($baseValue)), diff --git a/test/qtismtest/runtime/pci/json/JsonMarshallerTest.php b/test/qtismtest/runtime/pci/json/JsonMarshallerTest.php index a1c7b1fe5..723219480 100644 --- a/test/qtismtest/runtime/pci/json/JsonMarshallerTest.php +++ b/test/qtismtest/runtime/pci/json/JsonMarshallerTest.php @@ -41,7 +41,7 @@ class JsonMarshallerTest extends QtiSmTestCase * @param string $expectedJson * @throws MarshallingException */ - public function testMarshallScalar($scalar, $expectedJson) + public function testMarshallScalar($scalar, $expectedJson): void { $marshaller = new Marshaller(); $this::assertEquals($expectedJson, $marshaller->marshall($scalar)); @@ -54,7 +54,7 @@ public function testMarshallScalar($scalar, $expectedJson) * @param string $expectedJson * @throws MarshallingException */ - public function testMarshallComplex(QtiDatatype $complex, $expectedJson) + public function testMarshallComplex(QtiDatatype $complex, $expectedJson): void { $marshaller = new Marshaller(); $this::assertEquals($expectedJson, $marshaller->marshall($complex)); @@ -67,7 +67,7 @@ public function testMarshallComplex(QtiDatatype $complex, $expectedJson) * @param string $expectedJson * @throws MarshallingException */ - public function testMarshallMultiple(MultipleContainer $multiple, $expectedJson) + public function testMarshallMultiple(MultipleContainer $multiple, $expectedJson): void { $marshaller = new Marshaller(); $this::assertEquals($expectedJson, $marshaller->marshall($multiple)); @@ -80,7 +80,7 @@ public function testMarshallMultiple(MultipleContainer $multiple, $expectedJson) * @param string $expectedJson * @throws MarshallingException */ - public function testMarshallOrdered(OrderedContainer $ordered, $expectedJson) + public function testMarshallOrdered(OrderedContainer $ordered, $expectedJson): void { $marshaller = new Marshaller(); $this::assertEquals($expectedJson, $marshaller->marshall($ordered)); @@ -93,7 +93,7 @@ public function testMarshallOrdered(OrderedContainer $ordered, $expectedJson) * @param string $expectedJson * @throws MarshallingException */ - public function testMarshallRecord(RecordContainer $record, $expectedJson) + public function testMarshallRecord(RecordContainer $record, $expectedJson): void { $marshaller = new Marshaller(); $this::assertEquals($expectedJson, $marshaller->marshall($record)); @@ -106,7 +106,7 @@ public function testMarshallRecord(RecordContainer $record, $expectedJson) * @param string $expectedJson * @throws MarshallingException */ - public function testMarshallState(State $state, $expectedJson) + public function testMarshallState(State $state, $expectedJson): void { $marshaller = new Marshaller(); $this::assertEquals($expectedJson, $marshaller->marshall($state)); @@ -118,7 +118,7 @@ public function testMarshallState(State $state, $expectedJson) * @param mixed $input * @throws MarshallingException */ - public function testMarshallInvalidInput($input) + public function testMarshallInvalidInput($input): void { $this->expectException(MarshallingException::class); $this->expectExceptionMessage("The '" . Marshaller::class . "::marshall' method only takes State, QtiDatatype and null values as arguments"); @@ -127,7 +127,7 @@ public function testMarshallInvalidInput($input) $marshaller->marshall($input); } - public function testMarshallAsArray() + public function testMarshallAsArray(): void { $marshaller = new Marshaller(); $data = $marshaller->marshall(new QtiInteger(12), Marshaller::MARSHALL_ARRAY); @@ -137,7 +137,7 @@ public function testMarshallAsArray() /** * @return array */ - public function marshallScalarProvider() + public function marshallScalarProvider(): array { return [ [new QtiBoolean(true), json_encode(['base' => ['boolean' => true]])], @@ -157,7 +157,7 @@ public function marshallScalarProvider() /** * @return array */ - public function marshallComplexProvider() + public function marshallComplexProvider(): array { $samples = self::samplesDir(); @@ -189,7 +189,7 @@ public function marshallComplexProvider() /** * @return array */ - public function marshallMultipleProvider() + public function marshallMultipleProvider(): array { $returnValue = []; @@ -269,7 +269,7 @@ public function marshallMultipleProvider() /** * @return array */ - public function marshallOrderedProvider() + public function marshallOrderedProvider(): array { $returnValue = []; @@ -299,7 +299,7 @@ public function marshallOrderedProvider() /** * @return array */ - public function marshallRecordProvider() + public function marshallRecordProvider(): array { $returnValue = []; @@ -334,7 +334,7 @@ public function marshallRecordProvider() /** * @return array */ - public function marshallStateProvider() + public function marshallStateProvider(): array { $returnValue = []; @@ -369,7 +369,7 @@ public function marshallStateProvider() /** * @return array */ - public function marshallInvalidInputProvider() + public function marshallInvalidInputProvider(): array { return [ [10], diff --git a/test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php b/test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php index 742f604d7..63921d4ea 100644 --- a/test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php +++ b/test/qtismtest/runtime/pci/json/JsonUnmarshallerTest.php @@ -35,7 +35,7 @@ class JsonUnmarshallerTest extends QtiSmTestCase /** * @return Unmarshaller */ - protected static function createUnmarshaller() + protected static function createUnmarshaller(): Unmarshaller { return new Unmarshaller(new FileSystemFileManager()); } @@ -48,7 +48,7 @@ protected static function createUnmarshaller() * @throws UnmarshallingException * @throws FileManagerException */ - public function testUnmarshallScalar(QtiScalar $expectedScalar = null, $json) + public function testUnmarshallScalar(QtiScalar $expectedScalar = null, $json): void { $unmarshaller = self::createUnmarshaller(); if ($expectedScalar !== null) { @@ -66,7 +66,7 @@ public function testUnmarshallScalar(QtiScalar $expectedScalar = null, $json) * @throws UnmarshallingException * @throws FileManagerException */ - public function testUnmarshallComplex(QtiDatatype $expectedComplex, $json) + public function testUnmarshallComplex(QtiDatatype $expectedComplex, $json): void { $unmarshaller = self::createUnmarshaller(); $value = $unmarshaller->unmarshall($json); @@ -81,7 +81,7 @@ public function testUnmarshallComplex(QtiDatatype $expectedComplex, $json) * @throws UnmarshallingException * @throws FileManagerException */ - public function testUnmarshallFile(FileSystemFile $expectedFile, $json) + public function testUnmarshallFile(FileSystemFile $expectedFile, $json): void { $unmarshaller = self::createUnmarshaller(); $value = $unmarshaller->unmarshall($json); @@ -92,7 +92,7 @@ public function testUnmarshallFile(FileSystemFile $expectedFile, $json) $fileManager->delete($value); } - public function testUnmarshallFileHash() + public function testUnmarshallFileHash(): void { $id = 'http://some.cloud.storage/path/to/file.txt'; $mimeType = 'text/plain'; @@ -127,13 +127,13 @@ public function testUnmarshallFileHash() * @throws UnmarshallingException * @throws FileManagerException */ - public function testUnmarshallList(MultipleContainer $expectedContainer, $json) + public function testUnmarshallList(MultipleContainer $expectedContainer, $json): void { $unmarshaller = self::createUnmarshaller(); $this::assertTrue($expectedContainer->equals($unmarshaller->unmarshall($json))); } - public function testUnmarshallListException() + public function testUnmarshallListException(): void { $this->expectException(UnmarshallingException::class); @@ -150,7 +150,7 @@ public function testUnmarshallListException() * @throws UnmarshallingException * @throws FileManagerException */ - public function testUnmarshallRecord(RecordContainer $expectedRecord, $json) + public function testUnmarshallRecord(RecordContainer $expectedRecord, $json): void { $unmarshaller = self::createUnmarshaller(); $this::assertTrue($expectedRecord->equals($unmarshaller->unmarshall($json))); @@ -163,14 +163,14 @@ public function testUnmarshallRecord(RecordContainer $expectedRecord, $json) * @throws UnmarshallingException * @throws FileManagerException */ - public function testUnmarshallInvalid($input) + public function testUnmarshallInvalid($input): void { $unmarshaller = self::createUnmarshaller(); $this->expectException(UnmarshallingException::class); $unmarshaller->unmarshall($input); } - public function testUnmarshallNoAssociative() + public function testUnmarshallNoAssociative(): void { $unmarshaller = self::createUnmarshaller(); $this->expectException(UnmarshallingException::class); @@ -178,7 +178,7 @@ public function testUnmarshallNoAssociative() $unmarshaller->unmarshall(true); } - public function testUnmarshallListUnknownBaseType() + public function testUnmarshallListUnknownBaseType(): void { $unmarshaller = self::createUnmarshaller(); @@ -188,7 +188,7 @@ public function testUnmarshallListUnknownBaseType() $unmarshaller->unmarshall('{ "list" : { "unknownbasetype" : ["_id1", "id2", "ID3"] } }'); } - public function testUnmarshallListNonBaseTypeCompliantValue() + public function testUnmarshallListNonBaseTypeCompliantValue(): void { $unmarshaller = self::createUnmarshaller(); @@ -198,7 +198,7 @@ public function testUnmarshallListNonBaseTypeCompliantValue() $unmarshaller->unmarshall('{ "list" : { "identifier" : [true, "id2", "ID3"] } }'); } - public function testUnmarshallState() + public function testUnmarshallState(): void { $json = ' { @@ -228,7 +228,7 @@ public function testUnmarshallState() /** * @return array */ - public function unmarshallScalarProvider() + public function unmarshallScalarProvider(): array { return [ [new QtiBoolean(true), '{ "base" : {"boolean" : true } }'], @@ -248,7 +248,7 @@ public function unmarshallScalarProvider() /** * @return array */ - public function unmarshallComplexProvider() + public function unmarshallComplexProvider(): array { $returnValue = []; @@ -264,7 +264,7 @@ public function unmarshallComplexProvider() * @return array * @throws FileManagerException */ - public function unmarshallFileProvider() + public function unmarshallFileProvider(): array { $returnValue = []; $samples = self::samplesDir(); @@ -291,7 +291,7 @@ public function unmarshallFileProvider() /** * @return array */ - public function unmarshallListProvider() + public function unmarshallListProvider(): array { $returnValue = []; @@ -337,7 +337,7 @@ public function unmarshallListProvider() /** * @return array */ - public function unmarshallRecordProvider() + public function unmarshallRecordProvider(): array { $returnValue = []; @@ -363,7 +363,7 @@ public function unmarshallRecordProvider() /** * @return array */ - public function unmarshallInvalidProvider() + public function unmarshallInvalidProvider(): array { return [ [new stdClass()], @@ -380,7 +380,7 @@ public function unmarshallInvalidProvider() ]; } - public function testUnmarshallListWithinRecord() + public function testUnmarshallListWithinRecord(): void { $unmarshaller = self::createUnmarshaller(); $json = ' diff --git a/test/qtismtest/runtime/processing/OutcomeProcessingEngineTest.php b/test/qtismtest/runtime/processing/OutcomeProcessingEngineTest.php index 734d5c983..cf9762a8c 100644 --- a/test/qtismtest/runtime/processing/OutcomeProcessingEngineTest.php +++ b/test/qtismtest/runtime/processing/OutcomeProcessingEngineTest.php @@ -18,7 +18,7 @@ */ class OutcomeProcessingEngineTest extends QtiSmTestCase { - public function testResponseProcessingMatchCorrect() + public function testResponseProcessingMatchCorrect(): void { $outcomeProcessing = $this->createComponentFromXml(' Average loading time is %.8f seconds.', $avg)); } @@ -97,7 +97,7 @@ function outputAverage($avg) /** * @param $msg */ -function outputDescription($msg) +function outputDescription($msg): void { output(" + ${msg}"); } @@ -105,7 +105,7 @@ function outputDescription($msg) /** * @param $msg */ -function output($msg) +function output($msg): void { echo "${msg}\n"; } @@ -115,7 +115,7 @@ function output($msg) * @param $end * @return mixed */ -function spentTime($start, $end) +function spentTime($start, $end): mixed { $startTime = explode(' ', $start); $endTime = explode(' ', $end); diff --git a/test/scripts/XmlVsPhpResponseProcessing.php b/test/scripts/XmlVsPhpResponseProcessing.php index 93fa9c731..f6d489e50 100644 --- a/test/scripts/XmlVsPhpResponseProcessing.php +++ b/test/scripts/XmlVsPhpResponseProcessing.php @@ -10,7 +10,7 @@ * @param $end * @return mixed */ -function spentTime($start, $end) +function spentTime($start, $end): mixed { $startTime = explode(' ', $start); $endTime = explode(' ', $end);