diff --git a/.github/workflows/exercise-lint-phpcs-psr-12.yml b/.github/workflows/exercise-lint-phpcs-psr-12.yml
index df4885d0..6139e55a 100644
--- a/.github/workflows/exercise-lint-phpcs-psr-12.yml
+++ b/.github/workflows/exercise-lint-phpcs-psr-12.yml
@@ -29,8 +29,9 @@ jobs:
- uses: shivammathur/setup-php@46fc8a2fd7cba50512858026dc8f0947c8a7a0e8
with:
- version: ${{ matrix.php-version }}
+ php-version: ${{ matrix.php-version }}
extensions: gmp
+ tools: composer
- name: Install dependencies
shell: bash
@@ -38,9 +39,9 @@ jobs:
curl -Lo bin/phpcs.phar https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
chmod +x bin/phpcs.phar
+ - name: Install composer packages
+ run: composer install
+
- name: Lint exercises
shell: bash
- env:
- PHPCS_BIN: 'bin/phpcs.phar'
- PHPCS_RULES: 'phpcs-php.xml'
- run: bin/lint.sh
+ run: composer lint:check
diff --git a/.gitignore b/.gitignore
index 72aa4a12..378b241b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,6 @@ tmp
.phpunit.result.cache
bin/configlet
bin/configlet.exe
+
+/vendor/
+composer.lock
diff --git a/composer.json b/composer.json
new file mode 100644
index 00000000..a601bf74
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,16 @@
+{
+ "name": "exercism/php",
+ "autoload": {
+ "Exercism\\": "src",
+ "Exercism\\Exercises\\": "exercises"
+ },
+ "require-dev": {
+ "php": "^7.4|^8.0",
+ "slevomat/coding-standard": "^7.0",
+ "squizlabs/php_codesniffer": "^3.6"
+ },
+ "scripts": {
+ "lint:check": "./vendor/bin/phpcs --standard=phpcs-php.xml ./exercises",
+ "lint:fix": "./vendor/bin/phpcbf --standard=phpcs-php.xml ./exercises"
+ }
+}
diff --git a/exercises/practice/accumulate/.meta/example.php b/exercises/practice/accumulate/.meta/example.php
index b1b571bb..b762cc54 100644
--- a/exercises/practice/accumulate/.meta/example.php
+++ b/exercises/practice/accumulate/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* Given the input array and operation returns an array
* containing the result of applying that operation
diff --git a/exercises/practice/accumulate/Accumulate.php b/exercises/practice/accumulate/Accumulate.php
index 82822607..a1dae7f6 100644
--- a/exercises/practice/accumulate/Accumulate.php
+++ b/exercises/practice/accumulate/Accumulate.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function accumulate(array $input, callable $accumulator): array
{
throw new \BadFunctionCallException("Implement the accumulate function");
diff --git a/exercises/practice/accumulate/AccumulateTest.php b/exercises/practice/accumulate/AccumulateTest.php
index 389d9f25..29ae9d9a 100644
--- a/exercises/practice/accumulate/AccumulateTest.php
+++ b/exercises/practice/accumulate/AccumulateTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class AccumulateTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/acronym/.meta/example.php b/exercises/practice/acronym/.meta/example.php
index e237ae42..f0da6efe 100644
--- a/exercises/practice/acronym/.meta/example.php
+++ b/exercises/practice/acronym/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* Abbreviates a phrase.
*
diff --git a/exercises/practice/acronym/Acronym.php b/exercises/practice/acronym/Acronym.php
index 85af5977..412460d4 100644
--- a/exercises/practice/acronym/Acronym.php
+++ b/exercises/practice/acronym/Acronym.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function acronym(string $text): string
{
throw new \BadFunctionCallException("Implement the acronym function");
diff --git a/exercises/practice/acronym/AcronymTest.php b/exercises/practice/acronym/AcronymTest.php
index 563e42f9..99d1e3fb 100644
--- a/exercises/practice/acronym/AcronymTest.php
+++ b/exercises/practice/acronym/AcronymTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class AcronymTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/affine-cipher/.meta/example.php b/exercises/practice/affine-cipher/.meta/example.php
index 947fbcd4..95a07ef1 100644
--- a/exercises/practice/affine-cipher/.meta/example.php
+++ b/exercises/practice/affine-cipher/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function encode($text, $a, $b)
{
$alphabet = range('a', 'z');
diff --git a/exercises/practice/affine-cipher/AffineCipher.php b/exercises/practice/affine-cipher/AffineCipher.php
index 356c4145..08c7f65d 100644
--- a/exercises/practice/affine-cipher/AffineCipher.php
+++ b/exercises/practice/affine-cipher/AffineCipher.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function encode(string $text, int $num1, int $num2): string
{
throw new \BadFunctionCallException("Implement the encode function");
diff --git a/exercises/practice/affine-cipher/AffineCipherTest.php b/exercises/practice/affine-cipher/AffineCipherTest.php
index 652a1888..15b494f5 100644
--- a/exercises/practice/affine-cipher/AffineCipherTest.php
+++ b/exercises/practice/affine-cipher/AffineCipherTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* The test are divided into two groups:
*
diff --git a/exercises/practice/all-your-base/.meta/example.php b/exercises/practice/all-your-base/.meta/example.php
index 85fcca16..0a6616f5 100644
--- a/exercises/practice/all-your-base/.meta/example.php
+++ b/exercises/practice/all-your-base/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function rebase(int $fromBase, array $digits, int $toBase)
{
if (empty($digits) || $digits[0] == 0 || $fromBase <= 1 || $toBase <= 1) {
diff --git a/exercises/practice/all-your-base/AllYourBase.php b/exercises/practice/all-your-base/AllYourBase.php
index 49b23f80..18e33cc4 100644
--- a/exercises/practice/all-your-base/AllYourBase.php
+++ b/exercises/practice/all-your-base/AllYourBase.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function rebase(int $number, array $sequence, int $base)
{
throw new \BadFunctionCallException("Implement the rebase function");
diff --git a/exercises/practice/all-your-base/AllYourBaseTest.php b/exercises/practice/all-your-base/AllYourBaseTest.php
index da375d37..f24b0fc3 100644
--- a/exercises/practice/all-your-base/AllYourBaseTest.php
+++ b/exercises/practice/all-your-base/AllYourBaseTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* These tests are adapted from the canonical data in the
* `problem-specifications` repository.
diff --git a/exercises/practice/allergies/.meta/example.php b/exercises/practice/allergies/.meta/example.php
index bfe2ffb9..d60bd762 100644
--- a/exercises/practice/allergies/.meta/example.php
+++ b/exercises/practice/allergies/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Allergies
{
private $score;
diff --git a/exercises/practice/allergies/Allergies.php b/exercises/practice/allergies/Allergies.php
index a4fec532..3e35b88c 100644
--- a/exercises/practice/allergies/Allergies.php
+++ b/exercises/practice/allergies/Allergies.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Allergies
{
public function __construct(int $score)
diff --git a/exercises/practice/allergies/AllergiesTest.php b/exercises/practice/allergies/AllergiesTest.php
index d06ccdec..7c5ebad7 100644
--- a/exercises/practice/allergies/AllergiesTest.php
+++ b/exercises/practice/allergies/AllergiesTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class AllergiesTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/anagram/.meta/example.php b/exercises/practice/anagram/.meta/example.php
index 74d6a2d8..30747f9e 100644
--- a/exercises/practice/anagram/.meta/example.php
+++ b/exercises/practice/anagram/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function detectAnagrams($anagram, array $possibleMatches)
{
$matches = [];
diff --git a/exercises/practice/anagram/Anagram.php b/exercises/practice/anagram/Anagram.php
index 8f70b4eb..f8fcd6ae 100644
--- a/exercises/practice/anagram/Anagram.php
+++ b/exercises/practice/anagram/Anagram.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function detectAnagrams(string $word, array $anagrams): array
{
throw new \BadFunctionCallException("Implement the detectAnagrams function");
diff --git a/exercises/practice/anagram/AnagramTest.php b/exercises/practice/anagram/AnagramTest.php
index 8419d65b..5fd75e82 100644
--- a/exercises/practice/anagram/AnagramTest.php
+++ b/exercises/practice/anagram/AnagramTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class AnagramTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/armstrong-numbers/.meta/example.php b/exercises/practice/armstrong-numbers/.meta/example.php
index 1131bd27..2d61033e 100644
--- a/exercises/practice/armstrong-numbers/.meta/example.php
+++ b/exercises/practice/armstrong-numbers/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function isArmstrongNumber(int $number): bool
{
$total = 0;
diff --git a/exercises/practice/armstrong-numbers/ArmstrongNumbers.php b/exercises/practice/armstrong-numbers/ArmstrongNumbers.php
index c000a9ad..d1859145 100644
--- a/exercises/practice/armstrong-numbers/ArmstrongNumbers.php
+++ b/exercises/practice/armstrong-numbers/ArmstrongNumbers.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function isArmstrongNumber(int $number): bool
{
throw new \BadFunctionCallException("Implement the isArmstrongNumber function");
diff --git a/exercises/practice/armstrong-numbers/ArmstrongNumbersTest.php b/exercises/practice/armstrong-numbers/ArmstrongNumbersTest.php
index 6efb2393..9623f77a 100644
--- a/exercises/practice/armstrong-numbers/ArmstrongNumbersTest.php
+++ b/exercises/practice/armstrong-numbers/ArmstrongNumbersTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class ArmstrongNumbersTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/atbash-cipher/.meta/example.php b/exercises/practice/atbash-cipher/.meta/example.php
index f69eed56..9fdcf18b 100644
--- a/exercises/practice/atbash-cipher/.meta/example.php
+++ b/exercises/practice/atbash-cipher/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function encode($string)
{
$a_z = range('a', 'z');
diff --git a/exercises/practice/atbash-cipher/AtbashCipher.php b/exercises/practice/atbash-cipher/AtbashCipher.php
index cc8894bc..90dfadd4 100644
--- a/exercises/practice/atbash-cipher/AtbashCipher.php
+++ b/exercises/practice/atbash-cipher/AtbashCipher.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function encode(string $text): string
{
throw new \BadFunctionCallException("Implement the encode function");
diff --git a/exercises/practice/atbash-cipher/AtbashCipherTest.php b/exercises/practice/atbash-cipher/AtbashCipherTest.php
index e89f714d..a7ec016b 100644
--- a/exercises/practice/atbash-cipher/AtbashCipherTest.php
+++ b/exercises/practice/atbash-cipher/AtbashCipherTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class AtbashCipherTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/beer-song/.meta/example.php b/exercises/practice/beer-song/.meta/example.php
index 84573356..6a4d2d89 100644
--- a/exercises/practice/beer-song/.meta/example.php
+++ b/exercises/practice/beer-song/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class BeerSong
{
public function verse($number): string
diff --git a/exercises/practice/beer-song/BeerSong.php b/exercises/practice/beer-song/BeerSong.php
index ab114cd0..5ef7325c 100644
--- a/exercises/practice/beer-song/BeerSong.php
+++ b/exercises/practice/beer-song/BeerSong.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class BeerSong
{
public function verse(int $number): string
diff --git a/exercises/practice/beer-song/BeerSongTest.php b/exercises/practice/beer-song/BeerSongTest.php
index bef1eea8..8f5d79df 100644
--- a/exercises/practice/beer-song/BeerSongTest.php
+++ b/exercises/practice/beer-song/BeerSongTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class BeerSongTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/binary-search/.meta/example.php b/exercises/practice/binary-search/.meta/example.php
index c1da0060..a67c0ce7 100644
--- a/exercises/practice/binary-search/.meta/example.php
+++ b/exercises/practice/binary-search/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function find($needle, $haystack)
{
$left = 0;
diff --git a/exercises/practice/binary-search/BinarySearch.php b/exercises/practice/binary-search/BinarySearch.php
index 7466dbb5..fdae118f 100644
--- a/exercises/practice/binary-search/BinarySearch.php
+++ b/exercises/practice/binary-search/BinarySearch.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function find(int $needle, array $haystack): int
{
throw new \BadFunctionCallException("Implement the find function");
diff --git a/exercises/practice/binary-search/BinarySearchTest.php b/exercises/practice/binary-search/BinarySearchTest.php
index 207d360d..f7546253 100644
--- a/exercises/practice/binary-search/BinarySearchTest.php
+++ b/exercises/practice/binary-search/BinarySearchTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class BinarySearchTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/binary/.meta/example.php b/exercises/practice/binary/.meta/example.php
index 057cd94b..5ff19a31 100644
--- a/exercises/practice/binary/.meta/example.php
+++ b/exercises/practice/binary/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* Converts binary value to a decimal.
*
diff --git a/exercises/practice/binary/Binary.php b/exercises/practice/binary/Binary.php
index 6c7bd395..81592d44 100644
--- a/exercises/practice/binary/Binary.php
+++ b/exercises/practice/binary/Binary.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function parse_binary(string $binary): int
{
throw new \BadFunctionCallException("Implement the parse_binary function");
diff --git a/exercises/practice/binary/BinaryTest.php b/exercises/practice/binary/BinaryTest.php
index 12a6cc04..a9ddf7dc 100644
--- a/exercises/practice/binary/BinaryTest.php
+++ b/exercises/practice/binary/BinaryTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class BinaryTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/bob/.meta/example.php b/exercises/practice/bob/.meta/example.php
index cafcfacc..fbc38e55 100644
--- a/exercises/practice/bob/.meta/example.php
+++ b/exercises/practice/bob/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Bob
{
/**
diff --git a/exercises/practice/bob/Bob.php b/exercises/practice/bob/Bob.php
index 58218350..aa0abc6e 100644
--- a/exercises/practice/bob/Bob.php
+++ b/exercises/practice/bob/Bob.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Bob
{
public function respondTo(string $str): string
diff --git a/exercises/practice/bob/BobTest.php b/exercises/practice/bob/BobTest.php
index 1bd84fd1..9828e46e 100644
--- a/exercises/practice/bob/BobTest.php
+++ b/exercises/practice/bob/BobTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class BobTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/book-store/.meta/example.php b/exercises/practice/book-store/.meta/example.php
index 33305194..5e4f94a8 100644
--- a/exercises/practice/book-store/.meta/example.php
+++ b/exercises/practice/book-store/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function total($items)
{
return calculate($items, 0);
diff --git a/exercises/practice/book-store/BookStore.php b/exercises/practice/book-store/BookStore.php
index ba9157fb..4a4efd9d 100644
--- a/exercises/practice/book-store/BookStore.php
+++ b/exercises/practice/book-store/BookStore.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function total(array $items): float
{
throw new \BadFunctionCallException("Implement the total function");
diff --git a/exercises/practice/book-store/BookStoreTest.php b/exercises/practice/book-store/BookStoreTest.php
index 8d1d47ed..b99588e8 100644
--- a/exercises/practice/book-store/BookStoreTest.php
+++ b/exercises/practice/book-store/BookStoreTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* Calculate lowest price for shopping basket only
* containing books from a single series. There is no
diff --git a/exercises/practice/bowling/.meta/example.php b/exercises/practice/bowling/.meta/example.php
index c723be2e..5fc82f24 100644
--- a/exercises/practice/bowling/.meta/example.php
+++ b/exercises/practice/bowling/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* Translated from original source:
* http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata
diff --git a/exercises/practice/bowling/Bowling.php b/exercises/practice/bowling/Bowling.php
index ac6512cc..6810f2c1 100644
--- a/exercises/practice/bowling/Bowling.php
+++ b/exercises/practice/bowling/Bowling.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Game
{
public function score(): int
diff --git a/exercises/practice/bowling/BowlingTest.php b/exercises/practice/bowling/BowlingTest.php
index 494f9e9e..1072356a 100644
--- a/exercises/practice/bowling/BowlingTest.php
+++ b/exercises/practice/bowling/BowlingTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* Translated from original source:
* http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata
diff --git a/exercises/practice/change/.meta/example.php b/exercises/practice/change/.meta/example.php
index a847248b..b8af1ce6 100644
--- a/exercises/practice/change/.meta/example.php
+++ b/exercises/practice/change/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
// adapted from the python example
function findFewestCoins(array $coins, int $total_change): array
{
diff --git a/exercises/practice/change/Change.php b/exercises/practice/change/Change.php
index c6f19da3..9629c401 100644
--- a/exercises/practice/change/Change.php
+++ b/exercises/practice/change/Change.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function findFewestCoins(array $coins, int $amount): array
{
throw new \BadFunctionCallException("Implement the findFewestCoins function");
diff --git a/exercises/practice/change/ChangeTest.php b/exercises/practice/change/ChangeTest.php
index a749394c..6746da6e 100644
--- a/exercises/practice/change/ChangeTest.php
+++ b/exercises/practice/change/ChangeTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class ChangeTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/clock/.meta/example.php b/exercises/practice/clock/.meta/example.php
index 3bced89a..35cb4ee8 100644
--- a/exercises/practice/clock/.meta/example.php
+++ b/exercises/practice/clock/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Clock
{
/**
diff --git a/exercises/practice/clock/Clock.php b/exercises/practice/clock/Clock.php
index 26aa6b67..5e5b669e 100644
--- a/exercises/practice/clock/Clock.php
+++ b/exercises/practice/clock/Clock.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Clock
{
public function __toString(): string
diff --git a/exercises/practice/clock/ClockTest.php b/exercises/practice/clock/ClockTest.php
index 8a7f4a4f..b3af516f 100644
--- a/exercises/practice/clock/ClockTest.php
+++ b/exercises/practice/clock/ClockTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class ClockTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/collatz-conjecture/.meta/example.php b/exercises/practice/collatz-conjecture/.meta/example.php
index 8b79c154..502da2d0 100644
--- a/exercises/practice/collatz-conjecture/.meta/example.php
+++ b/exercises/practice/collatz-conjecture/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function steps($number)
{
$stepCount = 0;
diff --git a/exercises/practice/collatz-conjecture/CollatzConjecture.php b/exercises/practice/collatz-conjecture/CollatzConjecture.php
index accd1d1b..54112f8d 100644
--- a/exercises/practice/collatz-conjecture/CollatzConjecture.php
+++ b/exercises/practice/collatz-conjecture/CollatzConjecture.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function steps(int $number): int
{
throw new \BadFunctionCallException("Implement the steps function");
diff --git a/exercises/practice/collatz-conjecture/CollatzConjectureTest.php b/exercises/practice/collatz-conjecture/CollatzConjectureTest.php
index 9c9386f0..387fd65e 100644
--- a/exercises/practice/collatz-conjecture/CollatzConjectureTest.php
+++ b/exercises/practice/collatz-conjecture/CollatzConjectureTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class CollatzConjectureTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/connect/.meta/example.php b/exercises/practice/connect/.meta/example.php
index a0e70bb6..527dabb9 100644
--- a/exercises/practice/connect/.meta/example.php
+++ b/exercises/practice/connect/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
const NOTHING = 0;
const WHITE = 1;
const BLACK = 2;
diff --git a/exercises/practice/connect/Connect.php b/exercises/practice/connect/Connect.php
index ef75ab61..7acea120 100644
--- a/exercises/practice/connect/Connect.php
+++ b/exercises/practice/connect/Connect.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function resultFor(array $lines)
{
throw new \BadFunctionCallException("Implement the resultFor method");
diff --git a/exercises/practice/connect/ConnectTest.php b/exercises/practice/connect/ConnectTest.php
index 00b90aa3..862e9758 100644
--- a/exercises/practice/connect/ConnectTest.php
+++ b/exercises/practice/connect/ConnectTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class ConnectTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/crypto-square/.meta/example.php b/exercises/practice/crypto-square/.meta/example.php
index 61da62f1..1fbb9da1 100644
--- a/exercises/practice/crypto-square/.meta/example.php
+++ b/exercises/practice/crypto-square/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function crypto_square($plaintext)
{
$normalized = preg_replace('/\W*/', '', strtolower($plaintext));
diff --git a/exercises/practice/crypto-square/CryptoSquare.php b/exercises/practice/crypto-square/CryptoSquare.php
index 70573b6b..f551508e 100644
--- a/exercises/practice/crypto-square/CryptoSquare.php
+++ b/exercises/practice/crypto-square/CryptoSquare.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function crypto_square(string $plaintext): string
{
throw new \BadFunctionCallException("Implement the crypto_square function");
diff --git a/exercises/practice/crypto-square/CryptoSquareTest.php b/exercises/practice/crypto-square/CryptoSquareTest.php
index 0a1afae3..e21a3d33 100644
--- a/exercises/practice/crypto-square/CryptoSquareTest.php
+++ b/exercises/practice/crypto-square/CryptoSquareTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class CryptoSquareTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/diamond/.meta/example.php b/exercises/practice/diamond/.meta/example.php
index 1834b585..8f4b7a8c 100644
--- a/exercises/practice/diamond/.meta/example.php
+++ b/exercises/practice/diamond/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function diamond($limit)
{
$alphabet = range('A', $limit);
diff --git a/exercises/practice/diamond/Diamond.php b/exercises/practice/diamond/Diamond.php
index c272cfc7..f76ea953 100644
--- a/exercises/practice/diamond/Diamond.php
+++ b/exercises/practice/diamond/Diamond.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function diamond(string $letter): array
{
throw new \BadFunctionCallException("Implement the diamond function");
diff --git a/exercises/practice/diamond/DiamondTest.php b/exercises/practice/diamond/DiamondTest.php
index 92efe3c5..40c35b9a 100644
--- a/exercises/practice/diamond/DiamondTest.php
+++ b/exercises/practice/diamond/DiamondTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class DiamondTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/difference-of-squares/.meta/example.php b/exercises/practice/difference-of-squares/.meta/example.php
index e323e9e7..f336ed5a 100644
--- a/exercises/practice/difference-of-squares/.meta/example.php
+++ b/exercises/practice/difference-of-squares/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function squareOfSum($max)
{
$sum = 0;
diff --git a/exercises/practice/difference-of-squares/DifferenceOfSquares.php b/exercises/practice/difference-of-squares/DifferenceOfSquares.php
index fd706e7a..fabc2745 100644
--- a/exercises/practice/difference-of-squares/DifferenceOfSquares.php
+++ b/exercises/practice/difference-of-squares/DifferenceOfSquares.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function squareOfSum(int $max): int
{
throw new \BadFunctionCallException("Implement the squareOfSum function");
diff --git a/exercises/practice/difference-of-squares/DifferenceOfSquaresTest.php b/exercises/practice/difference-of-squares/DifferenceOfSquaresTest.php
index 729cb011..06b80b83 100644
--- a/exercises/practice/difference-of-squares/DifferenceOfSquaresTest.php
+++ b/exercises/practice/difference-of-squares/DifferenceOfSquaresTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class DifferenceOfSquaresTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/etl/.meta/example.php b/exercises/practice/etl/.meta/example.php
index 77dcc9ad..611723a4 100644
--- a/exercises/practice/etl/.meta/example.php
+++ b/exercises/practice/etl/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function transform($old)
{
$new = [];
diff --git a/exercises/practice/etl/Etl.php b/exercises/practice/etl/Etl.php
index ede11a8e..069d208e 100644
--- a/exercises/practice/etl/Etl.php
+++ b/exercises/practice/etl/Etl.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function transform(array $input): array
{
throw new \BadFunctionCallException("Implement the transform function");
diff --git a/exercises/practice/etl/EtlTest.php b/exercises/practice/etl/EtlTest.php
index 330bb06b..93aff504 100644
--- a/exercises/practice/etl/EtlTest.php
+++ b/exercises/practice/etl/EtlTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class EtlTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/flatten-array/.meta/example.php b/exercises/practice/flatten-array/.meta/example.php
index 3ba5ebeb..8c20f140 100644
--- a/exercises/practice/flatten-array/.meta/example.php
+++ b/exercises/practice/flatten-array/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function flatten($array = [])
{
$return = [];
diff --git a/exercises/practice/flatten-array/FlattenArray.php b/exercises/practice/flatten-array/FlattenArray.php
index 24ef945b..ea39046e 100644
--- a/exercises/practice/flatten-array/FlattenArray.php
+++ b/exercises/practice/flatten-array/FlattenArray.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function flatten(array $input): array
{
throw new \BadFunctionCallException("Implement the flatten function");
diff --git a/exercises/practice/flatten-array/FlattenArrayTest.php b/exercises/practice/flatten-array/FlattenArrayTest.php
index 6466814f..af1fdfc7 100644
--- a/exercises/practice/flatten-array/FlattenArrayTest.php
+++ b/exercises/practice/flatten-array/FlattenArrayTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class FlattenArrayTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/gigasecond/.meta/example.php b/exercises/practice/gigasecond/.meta/example.php
index 9cd7205e..8242932a 100644
--- a/exercises/practice/gigasecond/.meta/example.php
+++ b/exercises/practice/gigasecond/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function from(DateTimeImmutable $from): DateTimeImmutable
{
$interval = new DateInterval('PT1000000000S');
diff --git a/exercises/practice/gigasecond/Gigasecond.php b/exercises/practice/gigasecond/Gigasecond.php
index 4b5a736f..70aec171 100644
--- a/exercises/practice/gigasecond/Gigasecond.php
+++ b/exercises/practice/gigasecond/Gigasecond.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function from(DateTimeImmutable $date): DateTimeImmutable
{
throw new \BadFunctionCallException("Implement the from function");
diff --git a/exercises/practice/gigasecond/GigasecondTest.php b/exercises/practice/gigasecond/GigasecondTest.php
index 1c5175c3..6f2bee16 100644
--- a/exercises/practice/gigasecond/GigasecondTest.php
+++ b/exercises/practice/gigasecond/GigasecondTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class GigasecondTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/grade-school/.meta/example.php b/exercises/practice/grade-school/.meta/example.php
index 9834371b..dcda6e4a 100644
--- a/exercises/practice/grade-school/.meta/example.php
+++ b/exercises/practice/grade-school/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class School
{
private $students = [];
diff --git a/exercises/practice/grade-school/GradeSchool.php b/exercises/practice/grade-school/GradeSchool.php
index 122ba24a..f143fbfc 100644
--- a/exercises/practice/grade-school/GradeSchool.php
+++ b/exercises/practice/grade-school/GradeSchool.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class School
{
public function add(string $name, int $grade): void
diff --git a/exercises/practice/grade-school/GradeSchoolTest.php b/exercises/practice/grade-school/GradeSchoolTest.php
index 449a7221..baea548b 100644
--- a/exercises/practice/grade-school/GradeSchoolTest.php
+++ b/exercises/practice/grade-school/GradeSchoolTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
use PHPUnit\Framework\TestCase;
class GradeSchoolTest extends TestCase
diff --git a/exercises/practice/grains/.meta/example.php b/exercises/practice/grains/.meta/example.php
index 6bab142d..72f006ba 100644
--- a/exercises/practice/grains/.meta/example.php
+++ b/exercises/practice/grains/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
*
Here is the simplest solution. But King hates floats.
diff --git a/exercises/practice/grains/Grains.php b/exercises/practice/grains/Grains.php
index 4c3e73a9..909bb1f5 100644
--- a/exercises/practice/grains/Grains.php
+++ b/exercises/practice/grains/Grains.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function square(int $number): string
{
throw new \BadFunctionCallException("Implement the square function");
diff --git a/exercises/practice/grains/GrainsTest.php b/exercises/practice/grains/GrainsTest.php
index 758c69e2..2f170a95 100644
--- a/exercises/practice/grains/GrainsTest.php
+++ b/exercises/practice/grains/GrainsTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class GrainsTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/hamming/.meta/example.php b/exercises/practice/hamming/.meta/example.php
index 012fe839..b6671e35 100644
--- a/exercises/practice/hamming/.meta/example.php
+++ b/exercises/practice/hamming/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* @param string $a
* @param string $b
diff --git a/exercises/practice/hamming/Hamming.php b/exercises/practice/hamming/Hamming.php
index f2f0f708..9b7ef0ea 100644
--- a/exercises/practice/hamming/Hamming.php
+++ b/exercises/practice/hamming/Hamming.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function distance(string $strandA, string $strandB): int
{
throw new \BadFunctionCallException("Implement the distance function");
diff --git a/exercises/practice/hamming/HammingTest.php b/exercises/practice/hamming/HammingTest.php
index b05a3a66..88e2ab7a 100644
--- a/exercises/practice/hamming/HammingTest.php
+++ b/exercises/practice/hamming/HammingTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class HammingTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/hello-world/.meta/example.php b/exercises/practice/hello-world/.meta/example.php
index 80d86e86..519b5597 100644
--- a/exercises/practice/hello-world/.meta/example.php
+++ b/exercises/practice/hello-world/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function helloWorld($name = 'World')
{
return "Hello, $name!";
diff --git a/exercises/practice/hello-world/HelloWorld.php b/exercises/practice/hello-world/HelloWorld.php
index 6f8ce238..f33ef709 100644
--- a/exercises/practice/hello-world/HelloWorld.php
+++ b/exercises/practice/hello-world/HelloWorld.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
//
// This is only a SKELETON file for the "Hello World" exercise.
// It's been provided as a convenience to get you started writing code faster.
diff --git a/exercises/practice/hello-world/HelloWorldTest.php b/exercises/practice/hello-world/HelloWorldTest.php
index 96ee8a30..d5dbdf37 100644
--- a/exercises/practice/hello-world/HelloWorldTest.php
+++ b/exercises/practice/hello-world/HelloWorldTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class HelloWorldTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/isogram/.meta/example.php b/exercises/practice/isogram/.meta/example.php
index 74dbe67c..44149a7c 100644
--- a/exercises/practice/isogram/.meta/example.php
+++ b/exercises/practice/isogram/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function isIsogram($string)
{
$string = str_replace(['-', ' '], '', mb_strtolower($string));
diff --git a/exercises/practice/isogram/Isogram.php b/exercises/practice/isogram/Isogram.php
index 2815d0c1..437215b6 100644
--- a/exercises/practice/isogram/Isogram.php
+++ b/exercises/practice/isogram/Isogram.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function isogram(string $word): bool
{
throw new \BadFunctionCallException("Implement the isogram function");
diff --git a/exercises/practice/isogram/IsogramTest.php b/exercises/practice/isogram/IsogramTest.php
index d24e6ea9..af887307 100644
--- a/exercises/practice/isogram/IsogramTest.php
+++ b/exercises/practice/isogram/IsogramTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class IsogramTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/largest-series-product/.meta/example.php b/exercises/practice/largest-series-product/.meta/example.php
index 15387158..a747f11c 100644
--- a/exercises/practice/largest-series-product/.meta/example.php
+++ b/exercises/practice/largest-series-product/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Series
{
/**
diff --git a/exercises/practice/largest-series-product/LargestSeriesProduct.php b/exercises/practice/largest-series-product/LargestSeriesProduct.php
index a7a008fc..154e0377 100644
--- a/exercises/practice/largest-series-product/LargestSeriesProduct.php
+++ b/exercises/practice/largest-series-product/LargestSeriesProduct.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Series
{
public function largestProduct(int $span): int
diff --git a/exercises/practice/largest-series-product/LargestSeriesProductTest.php b/exercises/practice/largest-series-product/LargestSeriesProductTest.php
index 36d62a50..5e5c2034 100644
--- a/exercises/practice/largest-series-product/LargestSeriesProductTest.php
+++ b/exercises/practice/largest-series-product/LargestSeriesProductTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class LargestSeriesProductTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
@@ -22,25 +46,25 @@ public function testCanFindTheLargestProductOf2WithNumbersInOrder(): void
public function testCanFindTheLargestProductOf2(): void
{
- $series = new Series(576802143);
+ $series = new Series("576802143");
$this->assertEquals(48, $series->largestProduct(2));
}
public function testFindsTheLargestProductIfSpanEqualsLength(): void
{
- $series = new Series(29);
+ $series = new Series("29");
$this->assertEquals(18, $series->largestProduct(2));
}
public function testCanFindTheLargestProductOf3WithNumbersInOrder(): void
{
- $series = new Series(123456789);
+ $series = new Series("123456789");
$this->assertEquals(504, $series->largestProduct(3));
}
public function testCanFindTheLargestProductOf3(): void
{
- $series = new Series(1027839564);
+ $series = new Series("1027839564");
$this->assertEquals(270, $series->largestProduct(3));
}
@@ -82,7 +106,7 @@ public function testReportsZeroIfTheOnlyDigitsAreZero(): void
public function testReportsZeroIfAllSpansIncludeZero(): void
{
- $series = new Series(99099);
+ $series = new Series("99099");
$this->assertEquals(0, $series->largestProduct(3));
}
@@ -90,7 +114,7 @@ public function testRejectsSpanLongerThanStringLength(): void
{
$this->expectException(InvalidArgumentException::class);
- $series = new Series(123);
+ $series = new Series("123");
$series->largestProduct(4);
}
diff --git a/exercises/practice/leap/.meta/example.php b/exercises/practice/leap/.meta/example.php
index 8a75a315..c30d694a 100644
--- a/exercises/practice/leap/.meta/example.php
+++ b/exercises/practice/leap/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* @return bool
*/
diff --git a/exercises/practice/leap/Leap.php b/exercises/practice/leap/Leap.php
index 88c6c9de..36f23da2 100644
--- a/exercises/practice/leap/Leap.php
+++ b/exercises/practice/leap/Leap.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function isLeap(int $year): bool
{
throw new \BadFunctionCallException("Implement the isLeap function");
diff --git a/exercises/practice/leap/LeapTest.php b/exercises/practice/leap/LeapTest.php
index 37e7746e..b901b55e 100644
--- a/exercises/practice/leap/LeapTest.php
+++ b/exercises/practice/leap/LeapTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class LeapTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/luhn/.meta/example.php b/exercises/practice/luhn/.meta/example.php
index db27c805..01ccc7e5 100644
--- a/exercises/practice/luhn/.meta/example.php
+++ b/exercises/practice/luhn/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function isValid($candidate)
{
$sanitizedCandidate = str_replace(" ", "", $candidate) ;
diff --git a/exercises/practice/luhn/Luhn.php b/exercises/practice/luhn/Luhn.php
index 0de5fac5..e075e550 100644
--- a/exercises/practice/luhn/Luhn.php
+++ b/exercises/practice/luhn/Luhn.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function isValid(string $number): bool
{
throw new \BadFunctionCallException("Implement the isValid function");
diff --git a/exercises/practice/luhn/LuhnTest.php b/exercises/practice/luhn/LuhnTest.php
index 420fb428..36632b44 100644
--- a/exercises/practice/luhn/LuhnTest.php
+++ b/exercises/practice/luhn/LuhnTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class LuhnTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/markdown/.meta/example.php b/exercises/practice/markdown/.meta/example.php
index 5c3ef0fb..5f3a447c 100644
--- a/exercises/practice/markdown/.meta/example.php
+++ b/exercises/practice/markdown/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function parseMarkdown($markdown)
{
$lines = explode("\n", $markdown);
diff --git a/exercises/practice/markdown/Markdown.php b/exercises/practice/markdown/Markdown.php
index 92a0748f..961d8914 100644
--- a/exercises/practice/markdown/Markdown.php
+++ b/exercises/practice/markdown/Markdown.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function parseMarkdown($markdown)
{
$lines = explode("\n", $markdown);
diff --git a/exercises/practice/markdown/MarkdownTest.php b/exercises/practice/markdown/MarkdownTest.php
index 832a18e2..e069db94 100644
--- a/exercises/practice/markdown/MarkdownTest.php
+++ b/exercises/practice/markdown/MarkdownTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class MarkdownTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/mask-credit-card/.meta/example.php b/exercises/practice/mask-credit-card/.meta/example.php
index ce0bd415..ec364a42 100644
--- a/exercises/practice/mask-credit-card/.meta/example.php
+++ b/exercises/practice/mask-credit-card/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function maskify(string $cc): string
{
// Do no mask if cc less than 6 or empty string
diff --git a/exercises/practice/mask-credit-card/MaskCreditCard.php b/exercises/practice/mask-credit-card/MaskCreditCard.php
index 23a90763..e436a1b2 100644
--- a/exercises/practice/mask-credit-card/MaskCreditCard.php
+++ b/exercises/practice/mask-credit-card/MaskCreditCard.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function maskify(string $cc): string
{
throw new \BadFunctionCallException("Implement the maskify function");
diff --git a/exercises/practice/mask-credit-card/MaskCreditCardTest.php b/exercises/practice/mask-credit-card/MaskCreditCardTest.php
index 93266646..8610a674 100644
--- a/exercises/practice/mask-credit-card/MaskCreditCardTest.php
+++ b/exercises/practice/mask-credit-card/MaskCreditCardTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class MaskCreditCardTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/matching-brackets/.meta/example.php b/exercises/practice/matching-brackets/.meta/example.php
index 61bd4dff..8650fe7a 100644
--- a/exercises/practice/matching-brackets/.meta/example.php
+++ b/exercises/practice/matching-brackets/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function brackets_match(string $input): bool
{
$characters = str_split($input);
diff --git a/exercises/practice/matching-brackets/MatchingBrackets.php b/exercises/practice/matching-brackets/MatchingBrackets.php
index 564776d1..01f5f01a 100644
--- a/exercises/practice/matching-brackets/MatchingBrackets.php
+++ b/exercises/practice/matching-brackets/MatchingBrackets.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function brackets_match(string $input): bool
{
throw new \BadFunctionCallException("Implement the brackets_match function");
diff --git a/exercises/practice/matching-brackets/MatchingBracketsTest.php b/exercises/practice/matching-brackets/MatchingBracketsTest.php
index 9043ff6c..e89f0122 100644
--- a/exercises/practice/matching-brackets/MatchingBracketsTest.php
+++ b/exercises/practice/matching-brackets/MatchingBracketsTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class MatchingBracketsTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/meetup/.meta/example.php b/exercises/practice/meetup/.meta/example.php
index b0f0a9ee..3072d0b4 100644
--- a/exercises/practice/meetup/.meta/example.php
+++ b/exercises/practice/meetup/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function meetup_day($year, $month, $which, $weekday)
{
$monthName = DateTimeImmutable::createFromFormat("!m", $month)->format('F');
diff --git a/exercises/practice/meetup/Meetup.php b/exercises/practice/meetup/Meetup.php
index 08d6194a..471ff548 100644
--- a/exercises/practice/meetup/Meetup.php
+++ b/exercises/practice/meetup/Meetup.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function meetup_day(int $year, int $month, string $which, string $weekday): DateTimeImmutable
{
throw new \BadFunctionCallException("Implement the meetup_day function");
diff --git a/exercises/practice/meetup/MeetupTest.php b/exercises/practice/meetup/MeetupTest.php
index b885f2e8..ec602455 100644
--- a/exercises/practice/meetup/MeetupTest.php
+++ b/exercises/practice/meetup/MeetupTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class MeetupTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
@@ -9,476 +33,476 @@ public static function setUpBeforeClass(): void
public function testMonteenthOfMay2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/5/13"), meetup_day(2013, 5, "teenth", "Monday"));
+ $this->assertEquals(new DateTimeImmutable("2013/5/13"), meetup_day(2013, "5", "teenth", "Monday"));
}
public function testMonteenthOfAugust2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/8/19"), meetup_day(2013, 8, "teenth", "Monday"));
+ $this->assertEquals(new DateTimeImmutable("2013/8/19"), meetup_day(2013, "8", "teenth", "Monday"));
}
public function testMonteenthOfSeptember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/9/16"), meetup_day(2013, 9, "teenth", "Monday"));
+ $this->assertEquals(new DateTimeImmutable("2013/9/16"), meetup_day(2013, "9", "teenth", "Monday"));
}
public function testTuesteenthOfMarch2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/3/19"), meetup_day(2013, 3, "teenth", "Tuesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/3/19"), meetup_day(2013, "3", "teenth", "Tuesday"));
}
public function testTuesteenthOfApril2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/4/16"), meetup_day(2013, 4, "teenth", "Tuesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/4/16"), meetup_day(2013, "4", "teenth", "Tuesday"));
}
public function testTuesteenthOfAugust2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/8/13"), meetup_day(2013, 8, "teenth", "Tuesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/8/13"), meetup_day(2013, "8", "teenth", "Tuesday"));
}
public function testWednesteenthOfJanuary2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/1/16"), meetup_day(2013, 1, "teenth", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/1/16"), meetup_day(2013, "1", "teenth", "Wednesday"));
}
public function testWednesteenthOfFebruary2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/2/13"), meetup_day(2013, 2, "teenth", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/2/13"), meetup_day(2013, "2", "teenth", "Wednesday"));
}
public function testWednesteenthOfJune2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/6/19"), meetup_day(2013, 6, "teenth", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/6/19"), meetup_day(2013, "6", "teenth", "Wednesday"));
}
public function testThursteenthOfMay2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/5/16"), meetup_day(2013, 5, "teenth", "Thursday"));
+ $this->assertEquals(new DateTimeImmutable("2013/5/16"), meetup_day(2013, "5", "teenth", "Thursday"));
}
public function testThursteenthOfJune2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/6/13"), meetup_day(2013, 6, "teenth", "Thursday"));
+ $this->assertEquals(new DateTimeImmutable("2013/6/13"), meetup_day(2013, "6", "teenth", "Thursday"));
}
public function testThursteenthOfSeptember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/9/19"), meetup_day(2013, 9, "teenth", "Thursday"));
+ $this->assertEquals(new DateTimeImmutable("2013/9/19"), meetup_day(2013, "9", "teenth", "Thursday"));
}
public function testFriteenthOfApril2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/4/19"), meetup_day(2013, 4, "teenth", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2013/4/19"), meetup_day(2013, "4", "teenth", "Friday"));
}
public function testFriteenthOfAugust2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/8/16"), meetup_day(2013, 8, "teenth", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2013/8/16"), meetup_day(2013, "8", "teenth", "Friday"));
}
public function testFriteenthOfSeptember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/9/13"), meetup_day(2013, 9, "teenth", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2013/9/13"), meetup_day(2013, "9", "teenth", "Friday"));
}
public function testSaturteenthOfFebruary2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/2/16"), meetup_day(2013, 2, "teenth", "Saturday"));
+ $this->assertEquals(new DateTimeImmutable("2013/2/16"), meetup_day(2013, "2", "teenth", "Saturday"));
}
public function testSaturteenthOfApril2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/4/13"), meetup_day(2013, 4, "teenth", "Saturday"));
+ $this->assertEquals(new DateTimeImmutable("2013/4/13"), meetup_day(2013, "4", "teenth", "Saturday"));
}
public function testSaturteenthOfOctober2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/10/19"), meetup_day(2013, 10, "teenth", "Saturday"));
+ $this->assertEquals(new DateTimeImmutable("2013/10/19"), meetup_day(2013, "10", "teenth", "Saturday"));
}
public function testSunteenthOfMay2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/5/19"), meetup_day(2013, 5, "teenth", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2013/5/19"), meetup_day(2013, "5", "teenth", "Sunday"));
}
public function testSunteenthOfJune2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/6/16"), meetup_day(2013, 6, "teenth", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2013/6/16"), meetup_day(2013, "6", "teenth", "Sunday"));
}
public function testSunteenthOfOctober2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/10/13"), meetup_day(2013, 10, "teenth", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2013/10/13"), meetup_day(2013, "10", "teenth", "Sunday"));
}
public function testFirstMondayOfMarch2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/3/4"), meetup_day(2013, 3, "first", "Monday"));
+ $this->assertEquals(new DateTimeImmutable("2013/3/4"), meetup_day(2013, "3", "first", "Monday"));
}
public function testFirstMondayOfApril2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/4/1"), meetup_day(2013, 4, "first", "Monday"));
+ $this->assertEquals(new DateTimeImmutable("2013/4/1"), meetup_day(2013, "4", "first", "Monday"));
}
public function testFirstTuesdayOfMay2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/5/7"), meetup_day(2013, 5, "first", "Tuesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/5/7"), meetup_day(2013, "5", "first", "Tuesday"));
}
public function testFirstTuesdayOfJune2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/6/4"), meetup_day(2013, 6, "first", "Tuesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/6/4"), meetup_day(2013, "6", "first", "Tuesday"));
}
public function testFirstWednesdayOfJuly2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/7/3"), meetup_day(2013, 7, "first", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/7/3"), meetup_day(2013, "7", "first", "Wednesday"));
}
public function testFirstWednesdayOfAugust2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/8/7"), meetup_day(2013, 8, "first", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/8/7"), meetup_day(2013, "8", "first", "Wednesday"));
}
public function testFirstThursdayOfSeptember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/9/5"), meetup_day(2013, 9, "first", "Thursday"));
+ $this->assertEquals(new DateTimeImmutable("2013/9/5"), meetup_day(2013, "9", "first", "Thursday"));
}
public function testFirstThursdayOfOctober2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/10/3"), meetup_day(2013, 10, "first", "Thursday"));
+ $this->assertEquals(new DateTimeImmutable("2013/10/3"), meetup_day(2013, "10", "first", "Thursday"));
}
public function testFirstFridayOfNovember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/11/1"), meetup_day(2013, 11, "first", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2013/11/1"), meetup_day(2013, "11", "first", "Friday"));
}
public function testFirstFridayOfDecember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/12/6"), meetup_day(2013, 12, "first", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2013/12/6"), meetup_day(2013, "12", "first", "Friday"));
}
public function testFirstSaturdayOfJanuary2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/1/5"), meetup_day(2013, 1, "first", "Saturday"));
+ $this->assertEquals(new DateTimeImmutable("2013/1/5"), meetup_day(2013, "1", "first", "Saturday"));
}
public function testFirstSaturdayOfFebruary2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/2/2"), meetup_day(2013, 2, "first", "Saturday"));
+ $this->assertEquals(new DateTimeImmutable("2013/2/2"), meetup_day(2013, "2", "first", "Saturday"));
}
public function testFirstSundayOfMarch2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/3/3"), meetup_day(2013, 3, "first", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2013/3/3"), meetup_day(2013, "3", "first", "Sunday"));
}
public function testFirstSundayOfApril2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/4/7"), meetup_day(2013, 4, "first", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2013/4/7"), meetup_day(2013, "4", "first", "Sunday"));
}
public function testSecondMondayOfMarch2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/3/11"), meetup_day(2013, 3, "second", "Monday"));
+ $this->assertEquals(new DateTimeImmutable("2013/3/11"), meetup_day(2013, "3", "second", "Monday"));
}
public function testSecondMondayOfApril2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/4/8"), meetup_day(2013, 4, "second", "Monday"));
+ $this->assertEquals(new DateTimeImmutable("2013/4/8"), meetup_day(2013, "4", "second", "Monday"));
}
public function testSecondTuesdayOfMay2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/5/14"), meetup_day(2013, 5, "second", "Tuesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/5/14"), meetup_day(2013, "5", "second", "Tuesday"));
}
public function testSecondTuesdayOfJune2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/6/11"), meetup_day(2013, 6, "second", "Tuesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/6/11"), meetup_day(2013, "6", "second", "Tuesday"));
}
public function testSecondWednesdayOfJuly2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/7/10"), meetup_day(2013, 7, "second", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/7/10"), meetup_day(2013, "7", "second", "Wednesday"));
}
public function testSecondWednesdayOfAugust2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/8/14"), meetup_day(2013, 8, "second", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/8/14"), meetup_day(2013, "8", "second", "Wednesday"));
}
public function testSecondThursdayOfSeptember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/9/12"), meetup_day(2013, 9, "second", "Thursday"));
+ $this->assertEquals(new DateTimeImmutable("2013/9/12"), meetup_day(2013, "9", "second", "Thursday"));
}
public function testSecondThursdayOfOctober2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/10/10"), meetup_day(2013, 10, "second", "Thursday"));
+ $this->assertEquals(new DateTimeImmutable("2013/10/10"), meetup_day(2013, "10", "second", "Thursday"));
}
public function testSecondFridayOfNovember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/11/8"), meetup_day(2013, 11, "second", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2013/11/8"), meetup_day(2013, "11", "second", "Friday"));
}
public function testSecondFridayOfDecember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/12/13"), meetup_day(2013, 12, "second", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2013/12/13"), meetup_day(2013, "12", "second", "Friday"));
}
public function testSecondSaturdayOfJanuary2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/1/12"), meetup_day(2013, 1, "second", "Saturday"));
+ $this->assertEquals(new DateTimeImmutable("2013/1/12"), meetup_day(2013, "1", "second", "Saturday"));
}
public function testSecondSaturdayOfFebruary2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/2/9"), meetup_day(2013, 2, "second", "Saturday"));
+ $this->assertEquals(new DateTimeImmutable("2013/2/9"), meetup_day(2013, "2", "second", "Saturday"));
}
public function testSecondSundayOfMarch2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/3/10"), meetup_day(2013, 3, "second", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2013/3/10"), meetup_day(2013, "3", "second", "Sunday"));
}
public function testSecondSundayOfApril2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/4/14"), meetup_day(2013, 4, "second", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2013/4/14"), meetup_day(2013, "4", "second", "Sunday"));
}
public function testThirdMondayOfMarch2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/3/18"), meetup_day(2013, 3, "third", "Monday"));
+ $this->assertEquals(new DateTimeImmutable("2013/3/18"), meetup_day(2013, "3", "third", "Monday"));
}
public function testThirdMondayOfApril2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/4/15"), meetup_day(2013, 4, "third", "Monday"));
+ $this->assertEquals(new DateTimeImmutable("2013/4/15"), meetup_day(2013, "4", "third", "Monday"));
}
public function testThirdTuesdayOfMay2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/5/21"), meetup_day(2013, 5, "third", "Tuesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/5/21"), meetup_day(2013, "5", "third", "Tuesday"));
}
public function testThirdTuesdayOfJune2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/6/18"), meetup_day(2013, 6, "third", "Tuesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/6/18"), meetup_day(2013, "6", "third", "Tuesday"));
}
public function testThirdWednesdayOfJuly2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/7/17"), meetup_day(2013, 7, "third", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/7/17"), meetup_day(2013, "7", "third", "Wednesday"));
}
public function testThirdWednesdayOfAugust2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/8/21"), meetup_day(2013, 8, "third", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/8/21"), meetup_day(2013, "8", "third", "Wednesday"));
}
public function testThirdThursdayOfSeptember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/9/19"), meetup_day(2013, 9, "third", "Thursday"));
+ $this->assertEquals(new DateTimeImmutable("2013/9/19"), meetup_day(2013, "9", "third", "Thursday"));
}
public function testThirdThursdayOfOctober2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/10/17"), meetup_day(2013, 10, "third", "Thursday"));
+ $this->assertEquals(new DateTimeImmutable("2013/10/17"), meetup_day(2013, "10", "third", "Thursday"));
}
public function testThirdFridayOfNovember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/11/15"), meetup_day(2013, 11, "third", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2013/11/15"), meetup_day(2013, "11", "third", "Friday"));
}
public function testThirdFridayOfDecember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/12/20"), meetup_day(2013, 12, "third", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2013/12/20"), meetup_day(2013, "12", "third", "Friday"));
}
public function testThirdSaturdayOfJanuary2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/1/19"), meetup_day(2013, 1, "third", "Saturday"));
+ $this->assertEquals(new DateTimeImmutable("2013/1/19"), meetup_day(2013, "1", "third", "Saturday"));
}
public function testThirdSaturdayOfFebruary2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/2/16"), meetup_day(2013, 2, "third", "Saturday"));
+ $this->assertEquals(new DateTimeImmutable("2013/2/16"), meetup_day(2013, "2", "third", "Saturday"));
}
public function testThirdSundayOfMarch2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/3/17"), meetup_day(2013, 3, "third", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2013/3/17"), meetup_day(2013, "3", "third", "Sunday"));
}
public function testThirdSundayOfApril2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/4/21"), meetup_day(2013, 4, "third", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2013/4/21"), meetup_day(2013, "4", "third", "Sunday"));
}
public function testFourthMondayOfMarch2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/3/25"), meetup_day(2013, 3, "fourth", "Monday"));
+ $this->assertEquals(new DateTimeImmutable("2013/3/25"), meetup_day(2013, "3", "fourth", "Monday"));
}
public function testFourthMondayOfApril2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/4/22"), meetup_day(2013, 4, "fourth", "Monday"));
+ $this->assertEquals(new DateTimeImmutable("2013/4/22"), meetup_day(2013, "4", "fourth", "Monday"));
}
public function testFourthTuesdayOfMay2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/5/28"), meetup_day(2013, 5, "fourth", "Tuesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/5/28"), meetup_day(2013, "5", "fourth", "Tuesday"));
}
public function testFourthTuesdayOfJune2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/6/25"), meetup_day(2013, 6, "fourth", "Tuesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/6/25"), meetup_day(2013, "6", "fourth", "Tuesday"));
}
public function testFourthWednesdayOfJuly2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/7/24"), meetup_day(2013, 7, "fourth", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/7/24"), meetup_day(2013, "7", "fourth", "Wednesday"));
}
public function testFourthWednesdayOfAugust2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/8/28"), meetup_day(2013, 8, "fourth", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/8/28"), meetup_day(2013, "8", "fourth", "Wednesday"));
}
public function testFourthThursdayOfSeptember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/9/26"), meetup_day(2013, 9, "fourth", "Thursday"));
+ $this->assertEquals(new DateTimeImmutable("2013/9/26"), meetup_day(2013, "9", "fourth", "Thursday"));
}
public function testFourthThursdayOfOctober2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/10/24"), meetup_day(2013, 10, "fourth", "Thursday"));
+ $this->assertEquals(new DateTimeImmutable("2013/10/24"), meetup_day(2013, "10", "fourth", "Thursday"));
}
public function testFourthFridayOfNovember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/11/22"), meetup_day(2013, 11, "fourth", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2013/11/22"), meetup_day(2013, "11", "fourth", "Friday"));
}
public function testFourthFridayOfDecember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/12/27"), meetup_day(2013, 12, "fourth", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2013/12/27"), meetup_day(2013, "12", "fourth", "Friday"));
}
public function testFourthSaturdayOfJanuary2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/1/26"), meetup_day(2013, 1, "fourth", "Saturday"));
+ $this->assertEquals(new DateTimeImmutable("2013/1/26"), meetup_day(2013, "1", "fourth", "Saturday"));
}
public function testFourthSaturdayOfFebruary2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/2/23"), meetup_day(2013, 2, "fourth", "Saturday"));
+ $this->assertEquals(new DateTimeImmutable("2013/2/23"), meetup_day(2013, "2", "fourth", "Saturday"));
}
public function testFourthSundayOfMarch2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/3/24"), meetup_day(2013, 3, "fourth", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2013/3/24"), meetup_day(2013, "3", "fourth", "Sunday"));
}
public function testFourthSundayOfApril2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/4/28"), meetup_day(2013, 4, "fourth", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2013/4/28"), meetup_day(2013, "4", "fourth", "Sunday"));
}
public function testLastMondayOfMarch2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/3/25"), meetup_day(2013, 3, "last", "Monday"));
+ $this->assertEquals(new DateTimeImmutable("2013/3/25"), meetup_day(2013, "3", "last", "Monday"));
}
public function testLastMondayOfApril2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/4/29"), meetup_day(2013, 4, "last", "Monday"));
+ $this->assertEquals(new DateTimeImmutable("2013/4/29"), meetup_day(2013, "4", "last", "Monday"));
}
public function testLastTuesdayOfMay2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/5/28"), meetup_day(2013, 5, "last", "Tuesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/5/28"), meetup_day(2013, "5", "last", "Tuesday"));
}
public function testLastTuesdayOfJune2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/6/25"), meetup_day(2013, 6, "last", "Tuesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/6/25"), meetup_day(2013, "6", "last", "Tuesday"));
}
public function testLastWednesdayOfJuly2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/7/31"), meetup_day(2013, 7, "last", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/7/31"), meetup_day(2013, "7", "last", "Wednesday"));
}
public function testLastWednesdayOfAugust2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/8/28"), meetup_day(2013, 8, "last", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2013/8/28"), meetup_day(2013, "8", "last", "Wednesday"));
}
public function testLastThursdayOfSeptember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/9/26"), meetup_day(2013, 9, "last", "Thursday"));
+ $this->assertEquals(new DateTimeImmutable("2013/9/26"), meetup_day(2013, "9", "last", "Thursday"));
}
public function testLastThursdayOfOctober2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/10/31"), meetup_day(2013, 10, "last", "Thursday"));
+ $this->assertEquals(new DateTimeImmutable("2013/10/31"), meetup_day(2013, "10", "last", "Thursday"));
}
public function testLastFridayOfNovember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/11/29"), meetup_day(2013, 11, "last", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2013/11/29"), meetup_day(2013, "11", "last", "Friday"));
}
public function testLastFridayOfDecember2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/12/27"), meetup_day(2013, 12, "last", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2013/12/27"), meetup_day(2013, "12", "last", "Friday"));
}
public function testLastSaturdayOfJanuary2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/1/26"), meetup_day(2013, 1, "last", "Saturday"));
+ $this->assertEquals(new DateTimeImmutable("2013/1/26"), meetup_day(2013, "1", "last", "Saturday"));
}
public function testLastSaturdayOfFebruary2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/2/23"), meetup_day(2013, 2, "last", "Saturday"));
+ $this->assertEquals(new DateTimeImmutable("2013/2/23"), meetup_day(2013, "2", "last", "Saturday"));
}
public function testLastSundayOfMarch2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/3/31"), meetup_day(2013, 3, "last", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2013/3/31"), meetup_day(2013, "3", "last", "Sunday"));
}
public function testLastSundayOfApril2013(): void
{
- $this->assertEquals(new DateTimeImmutable("2013/4/28"), meetup_day(2013, 4, "last", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2013/4/28"), meetup_day(2013, "4", "last", "Sunday"));
}
public function testLastWednesdayOfFebruary2012(): void
{
- $this->assertEquals(new DateTimeImmutable("2012/2/29"), meetup_day(2012, 2, "last", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2012/2/29"), meetup_day(2012, "2", "last", "Wednesday"));
}
public function testLastWednesdayOfDecember2014(): void
{
- $this->assertEquals(new DateTimeImmutable("2014/12/31"), meetup_day(2014, 12, "last", "Wednesday"));
+ $this->assertEquals(new DateTimeImmutable("2014/12/31"), meetup_day(2014, "12", "last", "Wednesday"));
}
public function testLastSundayOfFebruary2015(): void
{
- $this->assertEquals(new DateTimeImmutable("2015/2/22"), meetup_day(2015, 2, "last", "Sunday"));
+ $this->assertEquals(new DateTimeImmutable("2015/2/22"), meetup_day(2015, "2", "last", "Sunday"));
}
public function testFirstFridayOfDecember2012(): void
{
- $this->assertEquals(new DateTimeImmutable("2012/12/7"), meetup_day(2012, 12, "first", "Friday"));
+ $this->assertEquals(new DateTimeImmutable("2012/12/7"), meetup_day(2012, "12", "first", "Friday"));
}
}
diff --git a/exercises/practice/minesweeper/.meta/example.php b/exercises/practice/minesweeper/.meta/example.php
index dcd05c33..8bb42129 100644
--- a/exercises/practice/minesweeper/.meta/example.php
+++ b/exercises/practice/minesweeper/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function solve($minesweeperBoard)
{
$minesweeperBoard = makeBoardFromString($minesweeperBoard);
diff --git a/exercises/practice/minesweeper/Minesweeper.php b/exercises/practice/minesweeper/Minesweeper.php
index 09aaf360..5ffee1e2 100644
--- a/exercises/practice/minesweeper/Minesweeper.php
+++ b/exercises/practice/minesweeper/Minesweeper.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function solve(string $minesweeperBoard): string
{
throw new \BadFunctionCallException("Implement the solve function");
diff --git a/exercises/practice/minesweeper/MinesweeperTest.php b/exercises/practice/minesweeper/MinesweeperTest.php
index 8306a25a..e4d3dedc 100644
--- a/exercises/practice/minesweeper/MinesweeperTest.php
+++ b/exercises/practice/minesweeper/MinesweeperTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class MinesweeperTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/nth-prime/.meta/example.php b/exercises/practice/nth-prime/.meta/example.php
index 43cbd2c1..17d2c8fc 100644
--- a/exercises/practice/nth-prime/.meta/example.php
+++ b/exercises/practice/nth-prime/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function prime($count)
{
if ($count < 1) {
diff --git a/exercises/practice/nth-prime/NthPrime.php b/exercises/practice/nth-prime/NthPrime.php
index c1a92fb4..cad25236 100644
--- a/exercises/practice/nth-prime/NthPrime.php
+++ b/exercises/practice/nth-prime/NthPrime.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function prime(int $number)
{
throw new \BadFunctionCallException("Implement the prime function");
diff --git a/exercises/practice/nth-prime/NthPrimeTest.php b/exercises/practice/nth-prime/NthPrimeTest.php
index 5c616cf6..a36ba998 100644
--- a/exercises/practice/nth-prime/NthPrimeTest.php
+++ b/exercises/practice/nth-prime/NthPrimeTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class NthPrimeTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/nucleotide-count/.meta/example.php b/exercises/practice/nucleotide-count/.meta/example.php
index 33815bf2..5915a24f 100644
--- a/exercises/practice/nucleotide-count/.meta/example.php
+++ b/exercises/practice/nucleotide-count/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function nucleotideCount($dna)
{
$nucleotides = [];
diff --git a/exercises/practice/nucleotide-count/NucleotideCount.php b/exercises/practice/nucleotide-count/NucleotideCount.php
index 736e884f..77d459a3 100644
--- a/exercises/practice/nucleotide-count/NucleotideCount.php
+++ b/exercises/practice/nucleotide-count/NucleotideCount.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function nucleotideCount(string $input): array
{
throw new \BadFunctionCallException("Implement the nucleotideCount function");
diff --git a/exercises/practice/nucleotide-count/NucleotideCountTest.php b/exercises/practice/nucleotide-count/NucleotideCountTest.php
index 54f1632a..50ba9419 100644
--- a/exercises/practice/nucleotide-count/NucleotideCountTest.php
+++ b/exercises/practice/nucleotide-count/NucleotideCountTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class NucleotideCountTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/ocr-numbers/.meta/example.php b/exercises/practice/ocr-numbers/.meta/example.php
index b57b3845..0fdd8434 100644
--- a/exercises/practice/ocr-numbers/.meta/example.php
+++ b/exercises/practice/ocr-numbers/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function recognize($ocr)
{
return (new OcrBlock($ocr))->recognize();
diff --git a/exercises/practice/ocr-numbers/OcrNumbers.php b/exercises/practice/ocr-numbers/OcrNumbers.php
index 3068f415..00be91b5 100644
--- a/exercises/practice/ocr-numbers/OcrNumbers.php
+++ b/exercises/practice/ocr-numbers/OcrNumbers.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function recognize(array $input): string
{
throw new \BadFunctionCallException("Implement the recognize function");
diff --git a/exercises/practice/ocr-numbers/OcrNumbersTest.php b/exercises/practice/ocr-numbers/OcrNumbersTest.php
index ae0918ae..69145a15 100644
--- a/exercises/practice/ocr-numbers/OcrNumbersTest.php
+++ b/exercises/practice/ocr-numbers/OcrNumbersTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class OcrNumbersTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/ordinal-number/.meta/example.php b/exercises/practice/ordinal-number/.meta/example.php
index 5d422e16..e0ce3e25 100644
--- a/exercises/practice/ordinal-number/.meta/example.php
+++ b/exercises/practice/ordinal-number/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function toOrdinal(int $number): string
{
if (0 === $number) {
diff --git a/exercises/practice/ordinal-number/OrdinalNumber.php b/exercises/practice/ordinal-number/OrdinalNumber.php
index b5bfc558..b2c4bdd2 100644
--- a/exercises/practice/ordinal-number/OrdinalNumber.php
+++ b/exercises/practice/ordinal-number/OrdinalNumber.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function toOrdinal(int $number): string
{
throw new \BadFunctionCallException("Implement the toOrdinal function");
diff --git a/exercises/practice/ordinal-number/OrdinalNumberTest.php b/exercises/practice/ordinal-number/OrdinalNumberTest.php
index 4b6000ce..a3f0cf33 100644
--- a/exercises/practice/ordinal-number/OrdinalNumberTest.php
+++ b/exercises/practice/ordinal-number/OrdinalNumberTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class OrdinalNumberTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/palindrome-products/.meta/example.php b/exercises/practice/palindrome-products/.meta/example.php
index 9a29f8d4..0cf31d8e 100644
--- a/exercises/practice/palindrome-products/.meta/example.php
+++ b/exercises/practice/palindrome-products/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function generatePalindromeProduct(array $range): ?int
{
$palindromes = [];
diff --git a/exercises/practice/palindrome-products/PalindromeProducts.php b/exercises/practice/palindrome-products/PalindromeProducts.php
index f28d7e76..d9aaa41e 100644
--- a/exercises/practice/palindrome-products/PalindromeProducts.php
+++ b/exercises/practice/palindrome-products/PalindromeProducts.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function smallest(int $min, int $max): array
{
throw new \BadFunctionCallException("Implement the smallest function");
diff --git a/exercises/practice/palindrome-products/PalindromeProductsTest.php b/exercises/practice/palindrome-products/PalindromeProductsTest.php
index c259ae71..b73c2a81 100644
--- a/exercises/practice/palindrome-products/PalindromeProductsTest.php
+++ b/exercises/practice/palindrome-products/PalindromeProductsTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class PalindromeProductsTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/pangram/.meta/example.php b/exercises/practice/pangram/.meta/example.php
index 4965f2ee..061c2be1 100644
--- a/exercises/practice/pangram/.meta/example.php
+++ b/exercises/practice/pangram/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function isPangram($string)
{
$string = str_replace(['-', ' '], '', mb_strtolower($string));
diff --git a/exercises/practice/pangram/Pangram.php b/exercises/practice/pangram/Pangram.php
index a2cf4267..78592055 100644
--- a/exercises/practice/pangram/Pangram.php
+++ b/exercises/practice/pangram/Pangram.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function isPangram(string $string): bool
{
throw new \BadFunctionCallException("Implement the isPangram function");
diff --git a/exercises/practice/pangram/PangramTest.php b/exercises/practice/pangram/PangramTest.php
index cb881b08..764de683 100644
--- a/exercises/practice/pangram/PangramTest.php
+++ b/exercises/practice/pangram/PangramTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class PangramTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/pascals-triangle/.meta/example.php b/exercises/practice/pascals-triangle/.meta/example.php
index 137b8b12..1a5cb38a 100644
--- a/exercises/practice/pascals-triangle/.meta/example.php
+++ b/exercises/practice/pascals-triangle/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function pascalsTriangleRows($rowCount)
{
if ($rowCount < 0 || $rowCount === null) {
diff --git a/exercises/practice/pascals-triangle/PascalsTriangle.php b/exercises/practice/pascals-triangle/PascalsTriangle.php
index 08c87f63..ab3fd49d 100644
--- a/exercises/practice/pascals-triangle/PascalsTriangle.php
+++ b/exercises/practice/pascals-triangle/PascalsTriangle.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function pascalsTriangleRows(int $rowCount)
{
throw new \BadFunctionCallException("Implement the pascalsTriangleRows function");
diff --git a/exercises/practice/pascals-triangle/PascalsTriangleTest.php b/exercises/practice/pascals-triangle/PascalsTriangleTest.php
index e95a7144..e447976b 100644
--- a/exercises/practice/pascals-triangle/PascalsTriangleTest.php
+++ b/exercises/practice/pascals-triangle/PascalsTriangleTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class PascalsTriangleTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/perfect-numbers/.meta/example.php b/exercises/practice/perfect-numbers/.meta/example.php
index 7cb4a6d2..e4fa47e0 100644
--- a/exercises/practice/perfect-numbers/.meta/example.php
+++ b/exercises/practice/perfect-numbers/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function getClassification($number)
{
if ($number <= 0) {
diff --git a/exercises/practice/perfect-numbers/PerfectNumbers.php b/exercises/practice/perfect-numbers/PerfectNumbers.php
index 90d30753..34c6a4f1 100644
--- a/exercises/practice/perfect-numbers/PerfectNumbers.php
+++ b/exercises/practice/perfect-numbers/PerfectNumbers.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function getClassification(int $number): string
{
throw new \BadFunctionCallException("Implement the getClassification function");
diff --git a/exercises/practice/perfect-numbers/PerfectNumbersTest.php b/exercises/practice/perfect-numbers/PerfectNumbersTest.php
index 66f2b8da..03adacd8 100644
--- a/exercises/practice/perfect-numbers/PerfectNumbersTest.php
+++ b/exercises/practice/perfect-numbers/PerfectNumbersTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class PerfectNumbersTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/phone-number/.meta/example.php b/exercises/practice/phone-number/.meta/example.php
index 9d7792e7..04c2e101 100644
--- a/exercises/practice/phone-number/.meta/example.php
+++ b/exercises/practice/phone-number/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class PhoneNumber
{
private $number;
diff --git a/exercises/practice/phone-number/PhoneNumber.php b/exercises/practice/phone-number/PhoneNumber.php
index ec0382bb..dcdd8e50 100644
--- a/exercises/practice/phone-number/PhoneNumber.php
+++ b/exercises/practice/phone-number/PhoneNumber.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class PhoneNumber
{
public function number(): string
diff --git a/exercises/practice/phone-number/PhoneNumberTest.php b/exercises/practice/phone-number/PhoneNumberTest.php
index 49ba870d..49cda21d 100644
--- a/exercises/practice/phone-number/PhoneNumberTest.php
+++ b/exercises/practice/phone-number/PhoneNumberTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class PhoneNumberTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/pig-latin/.meta/example.php b/exercises/practice/pig-latin/.meta/example.php
index a1ca5d3a..d3d29828 100644
--- a/exercises/practice/pig-latin/.meta/example.php
+++ b/exercises/practice/pig-latin/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* Translates a string into Pig Latin
*
diff --git a/exercises/practice/pig-latin/PigLatin.php b/exercises/practice/pig-latin/PigLatin.php
index aa14d132..a5938933 100644
--- a/exercises/practice/pig-latin/PigLatin.php
+++ b/exercises/practice/pig-latin/PigLatin.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function translate(string $text): string
{
throw new \BadFunctionCallException("Implement the translate function");
diff --git a/exercises/practice/pig-latin/PigLatinTest.php b/exercises/practice/pig-latin/PigLatinTest.php
index 4562b4da..948e803f 100644
--- a/exercises/practice/pig-latin/PigLatinTest.php
+++ b/exercises/practice/pig-latin/PigLatinTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class PigLatinTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/prime-factors/.meta/example.php b/exercises/practice/prime-factors/.meta/example.php
index f50ab313..7a817641 100644
--- a/exercises/practice/prime-factors/.meta/example.php
+++ b/exercises/practice/prime-factors/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function factors($n)
{
$factorList = [];
diff --git a/exercises/practice/prime-factors/PrimeFactors.php b/exercises/practice/prime-factors/PrimeFactors.php
index e4f15cd3..033fe0f6 100644
--- a/exercises/practice/prime-factors/PrimeFactors.php
+++ b/exercises/practice/prime-factors/PrimeFactors.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function factors(int $number): array
{
throw new \BadFunctionCallException("Implement the factors function");
diff --git a/exercises/practice/prime-factors/PrimeFactorsTest.php b/exercises/practice/prime-factors/PrimeFactorsTest.php
index 23c0811a..394fa01a 100644
--- a/exercises/practice/prime-factors/PrimeFactorsTest.php
+++ b/exercises/practice/prime-factors/PrimeFactorsTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class PrimeFactorsTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/queen-attack/.meta/example.php b/exercises/practice/queen-attack/.meta/example.php
index 2a471b2f..bff6c287 100644
--- a/exercises/practice/queen-attack/.meta/example.php
+++ b/exercises/practice/queen-attack/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* Check if the queen is placed on a valid square.
*
diff --git a/exercises/practice/queen-attack/QueenAttack.php b/exercises/practice/queen-attack/QueenAttack.php
index cee6e874..e2a5af09 100644
--- a/exercises/practice/queen-attack/QueenAttack.php
+++ b/exercises/practice/queen-attack/QueenAttack.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function placeQueen(int $xCoordinate, int $yCoordinate): bool
{
throw new \BadFunctionCallException("Implement the placeQueen function");
diff --git a/exercises/practice/queen-attack/QueenAttackTest.php b/exercises/practice/queen-attack/QueenAttackTest.php
index 24de5d6b..af3da5cd 100644
--- a/exercises/practice/queen-attack/QueenAttackTest.php
+++ b/exercises/practice/queen-attack/QueenAttackTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class QueenAttackTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/rail-fence-cipher/.meta/example.php b/exercises/practice/rail-fence-cipher/.meta/example.php
index e61c6637..6d15f309 100644
--- a/exercises/practice/rail-fence-cipher/.meta/example.php
+++ b/exercises/practice/rail-fence-cipher/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function encode($plainMessage, $rails)
{
$cipherMessage = [];
@@ -24,7 +48,7 @@ function decode($cipherMessage, $rails)
$position = ($rails * 2) - 2;
$textLength = strlen($cipherMessage);
- $minLength = floor($textLength / $position);
+ $minLength = (int) floor($textLength / $position);
$balance = $textLength % $position;
$lengths = [];
$strings = [];
diff --git a/exercises/practice/rail-fence-cipher/RailFenceCipher.php b/exercises/practice/rail-fence-cipher/RailFenceCipher.php
index 54320faf..522ee397 100644
--- a/exercises/practice/rail-fence-cipher/RailFenceCipher.php
+++ b/exercises/practice/rail-fence-cipher/RailFenceCipher.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function encode(string $plainMessage, int $rails): string
{
throw new \BadFunctionCallException("Implement the encode function");
diff --git a/exercises/practice/rail-fence-cipher/RailFenceCipherTest.php b/exercises/practice/rail-fence-cipher/RailFenceCipherTest.php
index 136515d7..b344f238 100644
--- a/exercises/practice/rail-fence-cipher/RailFenceCipherTest.php
+++ b/exercises/practice/rail-fence-cipher/RailFenceCipherTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class RailFenceCipherTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/raindrops/.meta/example.php b/exercises/practice/raindrops/.meta/example.php
index e875a447..485af00a 100644
--- a/exercises/practice/raindrops/.meta/example.php
+++ b/exercises/practice/raindrops/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function raindrops($num)
{
$sound =
diff --git a/exercises/practice/raindrops/Raindrops.php b/exercises/practice/raindrops/Raindrops.php
index b501a91e..39b0c2d4 100644
--- a/exercises/practice/raindrops/Raindrops.php
+++ b/exercises/practice/raindrops/Raindrops.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function raindrops(int $number): string
{
throw new \BadFunctionCallException("Implement the raindrops function");
diff --git a/exercises/practice/raindrops/RaindropsTest.php b/exercises/practice/raindrops/RaindropsTest.php
index b5dd1333..4958bfa9 100644
--- a/exercises/practice/raindrops/RaindropsTest.php
+++ b/exercises/practice/raindrops/RaindropsTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class RaindropsTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/rna-transcription/.meta/example.php b/exercises/practice/rna-transcription/.meta/example.php
index b9be888c..cc1b1255 100644
--- a/exercises/practice/rna-transcription/.meta/example.php
+++ b/exercises/practice/rna-transcription/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function toRna($strand)
{
return strtr($strand, 'CGTA', 'GCAU');
diff --git a/exercises/practice/rna-transcription/RnaTranscription.php b/exercises/practice/rna-transcription/RnaTranscription.php
index db2f72ac..70328d50 100644
--- a/exercises/practice/rna-transcription/RnaTranscription.php
+++ b/exercises/practice/rna-transcription/RnaTranscription.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function toRna(string $dna): string
{
throw new \BadFunctionCallException("Implement the toRna function");
diff --git a/exercises/practice/rna-transcription/RnaTranscriptionTest.php b/exercises/practice/rna-transcription/RnaTranscriptionTest.php
index c4169807..09b8be15 100644
--- a/exercises/practice/rna-transcription/RnaTranscriptionTest.php
+++ b/exercises/practice/rna-transcription/RnaTranscriptionTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class RnaTranscriptionTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/robot-name/.meta/example.php b/exercises/practice/robot-name/.meta/example.php
index bfa76c77..d9edb40b 100644
--- a/exercises/practice/robot-name/.meta/example.php
+++ b/exercises/practice/robot-name/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Robot
{
private $name;
diff --git a/exercises/practice/robot-name/RobotName.php b/exercises/practice/robot-name/RobotName.php
index 797e8a9f..3f7fd53d 100644
--- a/exercises/practice/robot-name/RobotName.php
+++ b/exercises/practice/robot-name/RobotName.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Robot
{
public function getName(): string
diff --git a/exercises/practice/robot-name/RobotNameTest.php b/exercises/practice/robot-name/RobotNameTest.php
index af4bbea7..ae360996 100644
--- a/exercises/practice/robot-name/RobotNameTest.php
+++ b/exercises/practice/robot-name/RobotNameTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class RobotNameTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/robot-simulator/.meta/example.php b/exercises/practice/robot-simulator/.meta/example.php
index a69a6d98..2629ab10 100644
--- a/exercises/practice/robot-simulator/.meta/example.php
+++ b/exercises/practice/robot-simulator/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Robot
{
public const DIRECTION_NORTH = 'north';
diff --git a/exercises/practice/robot-simulator/RobotSimulator.php b/exercises/practice/robot-simulator/RobotSimulator.php
index f6c4f585..d4305ab9 100644
--- a/exercises/practice/robot-simulator/RobotSimulator.php
+++ b/exercises/practice/robot-simulator/RobotSimulator.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Robot
{
/**
diff --git a/exercises/practice/robot-simulator/RobotSimulatorTest.php b/exercises/practice/robot-simulator/RobotSimulatorTest.php
index 35473628..0761cc42 100644
--- a/exercises/practice/robot-simulator/RobotSimulatorTest.php
+++ b/exercises/practice/robot-simulator/RobotSimulatorTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class RobotSimulatorTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/roman-numerals/.meta/example.php b/exercises/practice/roman-numerals/.meta/example.php
index f90ac6c8..83ebd3d0 100644
--- a/exercises/practice/roman-numerals/.meta/example.php
+++ b/exercises/practice/roman-numerals/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function toRoman($number)
{
$mapping = [
diff --git a/exercises/practice/roman-numerals/RomanNumerals.php b/exercises/practice/roman-numerals/RomanNumerals.php
index 131ffeaf..99da717a 100644
--- a/exercises/practice/roman-numerals/RomanNumerals.php
+++ b/exercises/practice/roman-numerals/RomanNumerals.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function toRoman(int $number): string
{
throw new \BadFunctionCallException("Implement the toRoman function");
diff --git a/exercises/practice/roman-numerals/RomanNumeralsTest.php b/exercises/practice/roman-numerals/RomanNumeralsTest.php
index 96e1a090..b0605d9e 100644
--- a/exercises/practice/roman-numerals/RomanNumeralsTest.php
+++ b/exercises/practice/roman-numerals/RomanNumeralsTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class RomanNumeralsTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/run-length-encoding/.meta/example.php b/exercises/practice/run-length-encoding/.meta/example.php
index a3befcd1..3965acb4 100644
--- a/exercises/practice/run-length-encoding/.meta/example.php
+++ b/exercises/practice/run-length-encoding/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* @param string $input
* @return string
diff --git a/exercises/practice/run-length-encoding/RunLengthEncoding.php b/exercises/practice/run-length-encoding/RunLengthEncoding.php
index e0c82eea..82d354b1 100644
--- a/exercises/practice/run-length-encoding/RunLengthEncoding.php
+++ b/exercises/practice/run-length-encoding/RunLengthEncoding.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function encode(string $input): string
{
throw new \BadFunctionCallException("Implement the encode function");
diff --git a/exercises/practice/run-length-encoding/RunLengthEncodingTest.php b/exercises/practice/run-length-encoding/RunLengthEncodingTest.php
index d1fed69a..c1477360 100644
--- a/exercises/practice/run-length-encoding/RunLengthEncodingTest.php
+++ b/exercises/practice/run-length-encoding/RunLengthEncodingTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class RunLengthEncodingTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/scrabble-score/.meta/example.php b/exercises/practice/scrabble-score/.meta/example.php
index f3e1f41a..072ff3ef 100644
--- a/exercises/practice/scrabble-score/.meta/example.php
+++ b/exercises/practice/scrabble-score/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function score($word)
{
if (strlen($word) === 0 || $word === ' ') {
diff --git a/exercises/practice/scrabble-score/ScrabbleScore.php b/exercises/practice/scrabble-score/ScrabbleScore.php
index 5b50e488..e835b020 100644
--- a/exercises/practice/scrabble-score/ScrabbleScore.php
+++ b/exercises/practice/scrabble-score/ScrabbleScore.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function score(string $word): int
{
throw new \BadFunctionCallException("Implement the score function");
diff --git a/exercises/practice/scrabble-score/ScrabbleScoreTest.php b/exercises/practice/scrabble-score/ScrabbleScoreTest.php
index 6993675f..e4e2f7f6 100644
--- a/exercises/practice/scrabble-score/ScrabbleScoreTest.php
+++ b/exercises/practice/scrabble-score/ScrabbleScoreTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* Calculate the value of scrabble score for a given word.
*/
diff --git a/exercises/practice/series/.meta/example.php b/exercises/practice/series/.meta/example.php
index 6ca364d3..553caa3c 100644
--- a/exercises/practice/series/.meta/example.php
+++ b/exercises/practice/series/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function slices($series, $size)
{
if ($size > strlen($series) || $size < 1) {
diff --git a/exercises/practice/series/Series.php b/exercises/practice/series/Series.php
index 5e027b11..5f708a29 100644
--- a/exercises/practice/series/Series.php
+++ b/exercises/practice/series/Series.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function slices(string $digits, int $series): array
{
throw new \BadFunctionCallException("Implement the slices function");
diff --git a/exercises/practice/series/SeriesTest.php b/exercises/practice/series/SeriesTest.php
index 9081c37c..808c16f0 100644
--- a/exercises/practice/series/SeriesTest.php
+++ b/exercises/practice/series/SeriesTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class SeriesTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/sieve/.meta/example.php b/exercises/practice/sieve/.meta/example.php
index f10536b9..3997abc6 100644
--- a/exercises/practice/sieve/.meta/example.php
+++ b/exercises/practice/sieve/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function sieve($number)
{
if ($number == 1) {
diff --git a/exercises/practice/sieve/Sieve.php b/exercises/practice/sieve/Sieve.php
index e55afb8e..c4d482d3 100644
--- a/exercises/practice/sieve/Sieve.php
+++ b/exercises/practice/sieve/Sieve.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function sieve(int $number): array
{
throw new \BadFunctionCallException("Implement the sieve function");
diff --git a/exercises/practice/sieve/SieveTest.php b/exercises/practice/sieve/SieveTest.php
index 944ce5b6..02a2d986 100644
--- a/exercises/practice/sieve/SieveTest.php
+++ b/exercises/practice/sieve/SieveTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class SieveTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/space-age/.meta/example.php b/exercises/practice/space-age/.meta/example.php
index 3a374e74..363e13ed 100644
--- a/exercises/practice/space-age/.meta/example.php
+++ b/exercises/practice/space-age/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class SpaceAge
{
public $seconds;
diff --git a/exercises/practice/space-age/SpaceAge.php b/exercises/practice/space-age/SpaceAge.php
index 3249fdf1..aa15c2e1 100644
--- a/exercises/practice/space-age/SpaceAge.php
+++ b/exercises/practice/space-age/SpaceAge.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class SpaceAge
{
public function __construct(int $seconds)
diff --git a/exercises/practice/space-age/SpaceAgeTest.php b/exercises/practice/space-age/SpaceAgeTest.php
index d051b542..35dc10a1 100644
--- a/exercises/practice/space-age/SpaceAgeTest.php
+++ b/exercises/practice/space-age/SpaceAgeTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class SpaceAgeTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/sum-of-multiples/.meta/example.php b/exercises/practice/sum-of-multiples/.meta/example.php
index 51a26926..fbf0f0b0 100644
--- a/exercises/practice/sum-of-multiples/.meta/example.php
+++ b/exercises/practice/sum-of-multiples/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function sumOfMultiples($number, $multiples)
{
$numbers = [];
diff --git a/exercises/practice/sum-of-multiples/SumOfMultiples.php b/exercises/practice/sum-of-multiples/SumOfMultiples.php
index 2e77bea5..3bdd29c4 100644
--- a/exercises/practice/sum-of-multiples/SumOfMultiples.php
+++ b/exercises/practice/sum-of-multiples/SumOfMultiples.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function sumOfMultiples(int $number, array $multiples): int
{
throw new \BadFunctionCallException("Implement the sumOfMultiples function");
diff --git a/exercises/practice/sum-of-multiples/SumOfMultiplesTest.php b/exercises/practice/sum-of-multiples/SumOfMultiplesTest.php
index 8dbc149e..f69255ba 100644
--- a/exercises/practice/sum-of-multiples/SumOfMultiplesTest.php
+++ b/exercises/practice/sum-of-multiples/SumOfMultiplesTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class SumOfMultiplesTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/transpose/.meta/example.php b/exercises/practice/transpose/.meta/example.php
index ed3a7968..98f4aa98 100644
--- a/exercises/practice/transpose/.meta/example.php
+++ b/exercises/practice/transpose/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* Transpose multi line text into Rows become columns and columns become rows.
* Eg: http://en.wikipedia.org/wiki/Transpose
diff --git a/exercises/practice/transpose/Transpose.php b/exercises/practice/transpose/Transpose.php
index 5a54db91..058c88cb 100644
--- a/exercises/practice/transpose/Transpose.php
+++ b/exercises/practice/transpose/Transpose.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function transpose(array $input): array
{
throw new \BadFunctionCallException("Implement the transpose function");
diff --git a/exercises/practice/transpose/TransposeTest.php b/exercises/practice/transpose/TransposeTest.php
index db9eeeda..7e46d39f 100644
--- a/exercises/practice/transpose/TransposeTest.php
+++ b/exercises/practice/transpose/TransposeTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class TransposeTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/triangle/.meta/example.php b/exercises/practice/triangle/.meta/example.php
index 477fd9c2..f9d09a54 100644
--- a/exercises/practice/triangle/.meta/example.php
+++ b/exercises/practice/triangle/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Triangle
{
protected $sideA;
diff --git a/exercises/practice/triangle/Triangle.php b/exercises/practice/triangle/Triangle.php
index 446194a0..85fde79f 100644
--- a/exercises/practice/triangle/Triangle.php
+++ b/exercises/practice/triangle/Triangle.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class Triangle
{
public function __construct(int $a, int $b, int $c)
diff --git a/exercises/practice/triangle/TriangleTest.php b/exercises/practice/triangle/TriangleTest.php
index 9b8d2922..b19f727f 100644
--- a/exercises/practice/triangle/TriangleTest.php
+++ b/exercises/practice/triangle/TriangleTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class TriangleTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/trinary/.meta/example.php b/exercises/practice/trinary/.meta/example.php
index 5c0022d9..67c0115b 100644
--- a/exercises/practice/trinary/.meta/example.php
+++ b/exercises/practice/trinary/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function toDecimal($ternaryString, $base = 3)
{
if (!preg_match('/^[0-2]+$/', $ternaryString)) {
diff --git a/exercises/practice/trinary/Trinary.php b/exercises/practice/trinary/Trinary.php
index c75f7156..e37a4874 100644
--- a/exercises/practice/trinary/Trinary.php
+++ b/exercises/practice/trinary/Trinary.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function toDecimal(string $number): int
{
throw new \BadFunctionCallException("Implement the toDecimal function");
diff --git a/exercises/practice/trinary/TrinaryTest.php b/exercises/practice/trinary/TrinaryTest.php
index 20966e3a..85c2b566 100644
--- a/exercises/practice/trinary/TrinaryTest.php
+++ b/exercises/practice/trinary/TrinaryTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class TrinaryTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/two-fer/.meta/example.php b/exercises/practice/two-fer/.meta/example.php
index 2e24a1f7..c5fc79c3 100644
--- a/exercises/practice/two-fer/.meta/example.php
+++ b/exercises/practice/two-fer/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function twoFer(string $name = 'you'): string
{
return "One for $name, one for me.";
diff --git a/exercises/practice/two-fer/TwoFer.php b/exercises/practice/two-fer/TwoFer.php
index 0604d2d7..7205ef1d 100644
--- a/exercises/practice/two-fer/TwoFer.php
+++ b/exercises/practice/two-fer/TwoFer.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function twoFer(string $name): string
{
throw new \BadFunctionCallException("Implement the twoFer function");
diff --git a/exercises/practice/two-fer/TwoFerTest.php b/exercises/practice/two-fer/TwoFerTest.php
index e25c538c..c0807d65 100644
--- a/exercises/practice/two-fer/TwoFerTest.php
+++ b/exercises/practice/two-fer/TwoFerTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class TwoFerTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/variable-length-quantity/.meta/example.php b/exercises/practice/variable-length-quantity/.meta/example.php
index db6e6e91..c11a2487 100644
--- a/exercises/practice/variable-length-quantity/.meta/example.php
+++ b/exercises/practice/variable-length-quantity/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
/**
* @param array $integers
* @return array
diff --git a/exercises/practice/variable-length-quantity/VariableLengthQuantity.php b/exercises/practice/variable-length-quantity/VariableLengthQuantity.php
index 14740e94..c7a05449 100644
--- a/exercises/practice/variable-length-quantity/VariableLengthQuantity.php
+++ b/exercises/practice/variable-length-quantity/VariableLengthQuantity.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function vlq_encode(array $input): array
{
throw new \BadFunctionCallException("Implement the vlq_encode function");
diff --git a/exercises/practice/variable-length-quantity/VariableLengthQuantityTest.php b/exercises/practice/variable-length-quantity/VariableLengthQuantityTest.php
index 608e0c34..279c21d0 100644
--- a/exercises/practice/variable-length-quantity/VariableLengthQuantityTest.php
+++ b/exercises/practice/variable-length-quantity/VariableLengthQuantityTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class VariableLengthQuantityTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/word-count/.meta/example.php b/exercises/practice/word-count/.meta/example.php
index 0197a591..0282ae35 100644
--- a/exercises/practice/word-count/.meta/example.php
+++ b/exercises/practice/word-count/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function wordCount($phrase)
{
$count = [];
diff --git a/exercises/practice/word-count/WordCount.php b/exercises/practice/word-count/WordCount.php
index f84c42fd..b782967b 100644
--- a/exercises/practice/word-count/WordCount.php
+++ b/exercises/practice/word-count/WordCount.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function wordCount(string $words): array
{
throw new \BadFunctionCallException("Implement the wordCount function");
diff --git a/exercises/practice/word-count/WordCountTest.php b/exercises/practice/word-count/WordCountTest.php
index 6bc0b40f..21c6ad84 100644
--- a/exercises/practice/word-count/WordCountTest.php
+++ b/exercises/practice/word-count/WordCountTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class WordCountTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/exercises/practice/wordy/.meta/example.php b/exercises/practice/wordy/.meta/example.php
index 0e2c8493..dc368102 100644
--- a/exercises/practice/wordy/.meta/example.php
+++ b/exercises/practice/wordy/.meta/example.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function calculate($question = "")
{
preg_match(
diff --git a/exercises/practice/wordy/Wordy.php b/exercises/practice/wordy/Wordy.php
index f523eb5e..5f0b8aed 100644
--- a/exercises/practice/wordy/Wordy.php
+++ b/exercises/practice/wordy/Wordy.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
function calculate(string $input): int
{
throw new \BadFunctionCallException("Implement the calculate function");
diff --git a/exercises/practice/wordy/WordyTest.php b/exercises/practice/wordy/WordyTest.php
index 77722fa2..f90b1b70 100644
--- a/exercises/practice/wordy/WordyTest.php
+++ b/exercises/practice/wordy/WordyTest.php
@@ -1,5 +1,29 @@
.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+
+declare(strict_types=1);
+
class WordyTest extends PHPUnit\Framework\TestCase
{
public static function setUpBeforeClass(): void
diff --git a/phpcs-php.xml b/phpcs-php.xml
index 9585f413..5b99119f 100644
--- a/phpcs-php.xml
+++ b/phpcs-php.xml
@@ -8,4 +8,11 @@
+
+
+
+
+
+
+
diff --git a/src/Sniffs/ExplainStrictTypesSniff.php b/src/Sniffs/ExplainStrictTypesSniff.php
new file mode 100644
index 00000000..5b9a4d31
--- /dev/null
+++ b/src/Sniffs/ExplainStrictTypesSniff.php
@@ -0,0 +1,70 @@
+.
+ *
+ * To disable strict typing, comment out the directive below.
+ */
+EOT;
+
+ private ?Fixer $fixer = null;
+ private int $position = 0;
+
+ private array $tokens = [
+ T_COMMENT,
+ ];
+
+ public function register(): array
+ {
+ return [
+ T_DECLARE,
+ ];
+ }
+
+ public function process(File $file, $stackPtr)
+ {
+ $this->fixer = $file->fixer;
+ $this->position = $stackPtr;
+
+ if (!$file->findPrevious($this->tokens, $stackPtr)) {
+ $file->addFixableError(
+ 'Missing explanation of declaration of strict types.',
+ $stackPtr - 1,
+ self::class
+ );
+ $this->fix();
+ }
+ }
+
+ private function fix(): void
+ {
+ $this->fixer->addContent($this->position - 1, self::$explanation);
+ }
+}