From 7ff7b63d2cb5ae71e7a481fa77427c7f5df19e77 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 30 Oct 2018 12:16:19 +0100 Subject: [PATCH 01/75] - Added DDD initial commit. Added unit tests. --- .gitignore | 3 + Makefile | 27 +- bin/.gitkeep | 0 composer.json | 14 +- composer.lock | 491 +++++++++--------- docker-compose.yml | 10 + docker/php-cli/Dockerfile | 16 + phpcs.xml | 1 + phpunit.xml | 5 +- .../Exception/SorryInvalidPlayerToken.php | 9 + .../Exception/SorryPlayerNameIsTooLong.php | 9 + .../Exception/SorryPlayerNameIsTooShort.php | 9 + src/TicTacToe/Domain/Player/Player.php | 13 + src/TicTacToe/Domain/Player/PlayerName.php | 35 ++ src/TicTacToe/Domain/Player/PlayerToken.php | 44 ++ .../UI/Console/ConsoleOutput.php | 35 ++ src/TicTacToe/Infrastructure/UI/Output.php | 16 + tests/unit/Domain/Player/PlayerNameTest.php | 30 ++ tests/unit/Domain/Player/PlayerTokenTest.php | 30 ++ 19 files changed, 536 insertions(+), 261 deletions(-) create mode 100644 bin/.gitkeep create mode 100644 docker-compose.yml create mode 100644 docker/php-cli/Dockerfile create mode 100644 src/TicTacToe/Domain/Player/Exception/SorryInvalidPlayerToken.php create mode 100644 src/TicTacToe/Domain/Player/Exception/SorryPlayerNameIsTooLong.php create mode 100644 src/TicTacToe/Domain/Player/Exception/SorryPlayerNameIsTooShort.php create mode 100644 src/TicTacToe/Domain/Player/Player.php create mode 100644 src/TicTacToe/Domain/Player/PlayerName.php create mode 100644 src/TicTacToe/Domain/Player/PlayerToken.php create mode 100644 src/TicTacToe/Infrastructure/UI/Console/ConsoleOutput.php create mode 100644 src/TicTacToe/Infrastructure/UI/Output.php create mode 100644 tests/unit/Domain/Player/PlayerNameTest.php create mode 100644 tests/unit/Domain/Player/PlayerTokenTest.php diff --git a/.gitignore b/.gitignore index c921004..4247d65 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ vendor/* coverage/* +bin/* + +!bin/.gitkeep diff --git a/Makefile b/Makefile index 97448df..421c47c 100644 --- a/Makefile +++ b/Makefile @@ -1,32 +1,37 @@ +CMD = docker-compose exec php COMPOSER ?= composer -PROJECT = "Tic-Tac-Toe" +PROJECT = "TicTacToe." -all: clear lint-composer lint-php composer phpcs test coverage +all: clear lint-composer lint-php composer phpcs play lint-composer: @echo "\n==> Validating composer.json and composer.lock:" - $(COMPOSER) validate --strict + $(CMD) $(COMPOSER) validate --strict lint-php: @echo "\n==> Validating all php files:" @find src -type f -name \*.php | while read file; do php -l "$$file" || exit 1; done composer: - $(COMPOSER) install + $(CMD) $(COMPOSER) install clear: - rm -rf vendor + $(CMD) rm -rf vendor phpcs: - php vendor/bin/phpcs . -np + $(CMD) bin/phpcs --standard=phpcs.xml -p phpcbf: - vendor/bin/phpcbf src/* + $(CMD) bin/phpcbf -test: - vendor/bin/phpunit +play: + $(CMD) bin/App.php coverage: - vendor/bin/phpunit --coverage-html coverage + $(CMD) bin/phpunit --coverage-html coverage -.PHONY: lint-php lint-composer phpcs phpcbf test coverage composer clear +tests: + $(CMD) bin/phpunit + + +.PHONY: lint-php lint-composer phpcs phpcbf composer clear play tests coverage diff --git a/bin/.gitkeep b/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/composer.json b/composer.json index 203e710..f1045a0 100644 --- a/composer.json +++ b/composer.json @@ -5,19 +5,27 @@ "type": "project", "authors": [ { - "name": "Mina Nabil Sami" + "name": "Mina Nabil Sami", + "email": "mina.nsami@gmail.com" } ], "require": { - "php": ">=7", + "php": ">=7.2", "squizlabs/php_codesniffer": "2.*" }, "require-dev": { - "phpunit/phpunit": "6.1.*" + "phpunit/phpunit": "^7" }, "autoload": { "psr-0": { "TicTacToe": "src/" } + }, + "config": { + "bin-dir": "bin", + "platform": { + "php": "7.2" + }, + "sort-packages": true } } diff --git a/composer.lock b/composer.lock index e3f446e..d0ee4a6 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bb919364e2ff349c52686ba89992197f", + "content-hash": "824cfb8613b2c691c905bf589c7be738", "packages": [ { "name": "squizlabs/php_codesniffer", @@ -88,32 +88,32 @@ "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.0.5", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": "^7.1" }, "require-dev": { "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "phpunit/phpunit": "^6.2.3", + "squizlabs/php_codesniffer": "^3.0.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -138,41 +138,47 @@ "constructor", "instantiate" ], - "time": "2015-06-14T21:17:01+00:00" + "time": "2017-07-22T11:58:36+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.6.1", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102" + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/8e6e04167378abf1ddb4d3522d8755c5fd90d102", - "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", "shasum": "" }, "require": { - "php": ">=5.4.0" + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" }, "require-dev": { - "doctrine/collections": "1.*", - "phpunit/phpunit": "~4.1" + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" }, "type": "library", "autoload": { "psr-4": { "DeepCopy\\": "src/DeepCopy/" - } + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "description": "Create deep copies (clones) of your objects", - "homepage": "https://github.com/myclabs/DeepCopy", "keywords": [ "clone", "copy", @@ -180,26 +186,26 @@ "object", "object graph" ], - "time": "2017-04-12T18:52:22+00:00" + "time": "2018-06-11T23:09:50+00:00" }, { "name": "phar-io/manifest", - "version": "1.0.1", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", - "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", "shasum": "" }, "require": { "ext-dom": "*", "ext-phar": "*", - "phar-io/version": "^1.0.1", + "phar-io/version": "^2.0", "php": "^5.6 || ^7.0" }, "type": "library", @@ -235,20 +241,20 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2017-03-05T18:14:27+00:00" + "time": "2018-07-08T19:23:20+00:00" }, { "name": "phar-io/version", - "version": "1.0.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", - "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", + "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", "shasum": "" }, "require": { @@ -282,20 +288,20 @@ } ], "description": "Library for handling version information and constraints", - "time": "2017-03-05T17:38:23+00:00" + "time": "2018-07-08T19:19:57+00:00" }, { "name": "phpdocumentor/reflection-common", - "version": "1.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", "shasum": "" }, "require": { @@ -336,33 +342,39 @@ "reflection", "static analysis" ], - "time": "2015-12-27T11:43:31+00:00" + "time": "2017-09-11T18:02:19+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.1.1", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", "shasum": "" }, "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.2.0", + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0", + "phpdocumentor/type-resolver": "^0.4.0", "webmozart/assert": "^1.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": [ @@ -381,24 +393,24 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2016-09-30T07:12:33+00:00" + "time": "2017-11-30T07:14:17+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.2.1", + "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", - "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", "shasum": "" }, "require": { - "php": ">=5.5", + "php": "^5.5 || ^7.0", "phpdocumentor/reflection-common": "^1.0" }, "require-dev": { @@ -428,37 +440,37 @@ "email": "me@mikevanriel.com" } ], - "time": "2016-11-25T06:54:22+00:00" + "time": "2017-07-14T14:27:02+00:00" }, { "name": "phpspec/prophecy", - "version": "v1.7.0", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", - "sebastian/comparator": "^1.1|^2.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8 || ^5.6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.8.x-dev" } }, "autoload": { @@ -491,44 +503,44 @@ "spy", "stub" ], - "time": "2017-03-02T20:05:34+00:00" + "time": "2018-08-05T17:53:17+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "5.1.1", + "version": "6.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "bc433b7af27e0ab9b6b4c6d8ec918a493875f6bc" + "reference": "4d3ae9b21a7d7e440bd0cf65565533117976859f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/bc433b7af27e0ab9b6b4c6d8ec918a493875f6bc", - "reference": "bc433b7af27e0ab9b6b4c6d8ec918a493875f6bc", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/4d3ae9b21a7d7e440bd0cf65565533117976859f", + "reference": "4d3ae9b21a7d7e440bd0cf65565533117976859f", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", - "php": "^7.0", - "phpunit/php-file-iterator": "^1.3", - "phpunit/php-text-template": "^1.2", - "phpunit/php-token-stream": "^1.4.11 || ^2.0", - "sebastian/code-unit-reverse-lookup": "^1.0", - "sebastian/environment": "^2.0", - "sebastian/version": "^2.0" + "php": "^7.1", + "phpunit/php-file-iterator": "^2.0", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^3.0", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^3.1 || ^4.0", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1" }, "require-dev": { - "ext-xdebug": "^2.5", - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^7.0" }, "suggest": { - "ext-xdebug": "^2.5.1" + "ext-xdebug": "^2.6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.1.x-dev" + "dev-master": "6.1-dev" } }, "autoload": { @@ -543,7 +555,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -554,29 +566,32 @@ "testing", "xunit" ], - "time": "2017-04-12T07:59:32+00:00" + "time": "2018-10-23T05:59:32+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.2", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" + "reference": "050bedf145a257b1ff02746c31894800e5122946" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", + "reference": "050bedf145a257b1ff02746c31894800e5122946", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -591,7 +606,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -601,7 +616,7 @@ "filesystem", "iterator" ], - "time": "2016-10-03T07:40:28+00:00" + "time": "2018-09-13T20:33:42+00:00" }, { "name": "phpunit/php-text-template", @@ -646,28 +661,28 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.9", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b8454ea6958c3dee38453d3bd571e023108c91f", + "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -682,7 +697,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -691,33 +706,33 @@ "keywords": [ "timer" ], - "time": "2017-02-26T11:10:40+00:00" + "time": "2018-02-01T13:07:23+00:00" }, { "name": "phpunit/php-token-stream", - "version": "1.4.11", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" + "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c99e3be9d3e85f60646f152f9002d46ed7770d18", + "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.3.3" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -740,57 +755,57 @@ "keywords": [ "tokenizer" ], - "time": "2017-02-27T10:12:30+00:00" + "time": "2018-10-30T05:52:18+00:00" }, { "name": "phpunit/phpunit", - "version": "6.1.0", + "version": "7.4.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "2aa57c530381662b01c2cf705b03e8c12e918f1d" + "reference": "c151651fb6ed264038d486ea262e243af72e5e64" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2aa57c530381662b01c2cf705b03e8c12e918f1d", - "reference": "2aa57c530381662b01c2cf705b03e8c12e918f1d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c151651fb6ed264038d486ea262e243af72e5e64", + "reference": "c151651fb6ed264038d486ea262e243af72e5e64", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.1", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "^1.3", - "phar-io/manifest": "^1.0.1", - "phar-io/version": "^1.0", - "php": "^7.0", + "myclabs/deep-copy": "^1.7", + "phar-io/manifest": "^1.0.2", + "phar-io/version": "^2.0", + "php": "^7.1", "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^5.0", - "phpunit/php-file-iterator": "^1.4", - "phpunit/php-text-template": "^1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "^4.0", - "sebastian/comparator": "^2.0", - "sebastian/diff": "^1.2", - "sebastian/environment": "^2.0", + "phpunit/php-code-coverage": "^6.0.7", + "phpunit/php-file-iterator": "^2.0.1", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^2.0", + "sebastian/comparator": "^3.0", + "sebastian/diff": "^3.0", + "sebastian/environment": "^3.1 || ^4.0", "sebastian/exporter": "^3.1", - "sebastian/global-state": "^1.1 || ^2.0", - "sebastian/object-enumerator": "^3.0.2", - "sebastian/resource-operations": "^1.0", - "sebastian/version": "^2.0" + "sebastian/global-state": "^2.0", + "sebastian/object-enumerator": "^3.0.3", + "sebastian/resource-operations": "^2.0", + "sebastian/version": "^2.0.1" }, "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2", - "phpunit/dbunit": "<3.0" + "phpunit/phpunit-mock-objects": "*" }, "require-dev": { "ext-pdo": "*" }, "suggest": { + "ext-soap": "*", "ext-xdebug": "*", - "phpunit/php-invoker": "^1.1" + "phpunit/php-invoker": "^2.0" }, "bin": [ "phpunit" @@ -798,7 +813,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.1.x-dev" + "dev-master": "7.4-dev" } }, "autoload": { @@ -824,66 +839,7 @@ "testing", "xunit" ], - "time": "2017-04-07T04:45:38+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "4.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "eabce450df194817a7d7e27e19013569a903a2bf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/eabce450df194817a7d7e27e19013569a903a2bf", - "reference": "eabce450df194817a7d7e27e19013569a903a2bf", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^7.0", - "phpunit/php-text-template": "^1.2", - "sebastian/exporter": "^3.0" - }, - "conflict": { - "phpunit/phpunit": "<6.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2017-03-03T06:30:20+00:00" + "time": "2018-10-23T05:57:41+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -932,30 +888,30 @@ }, { "name": "sebastian/comparator", - "version": "2.0.0", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "20f84f468cb67efee293246e6a09619b891f55f0" + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/20f84f468cb67efee293246e6a09619b891f55f0", - "reference": "20f84f468cb67efee293246e6a09619b891f55f0", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", "shasum": "" }, "require": { - "php": "^7.0", - "sebastian/diff": "^1.2", - "sebastian/exporter": "^3.0" + "php": "^7.1", + "sebastian/diff": "^3.0", + "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -986,38 +942,39 @@ } ], "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", + "homepage": "https://github.com/sebastianbergmann/comparator", "keywords": [ "comparator", "compare", "equality" ], - "time": "2017-03-03T06:26:08+00:00" + "time": "2018-07-12T15:12:46+00:00" }, { "name": "sebastian/diff", - "version": "1.4.1", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" + "reference": "366541b989927187c4ca70490a35615d3fef2dce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/366541b989927187c4ca70490a35615d3fef2dce", + "reference": "366541b989927187c4ca70490a35615d3fef2dce", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "~4.8" + "phpunit/phpunit": "^7.0", + "symfony/process": "^2 || ^3.3 || ^4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1042,34 +999,37 @@ "description": "Diff implementation", "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ - "diff" + "diff", + "udiff", + "unidiff", + "unified diff" ], - "time": "2015-12-08T07:14:41+00:00" + "time": "2018-06-10T07:54:39+00:00" }, { "name": "sebastian/environment", - "version": "2.0.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "^5.0" + "phpunit/phpunit": "^6.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -1094,7 +1054,7 @@ "environment", "hhvm" ], - "time": "2016-11-26T07:53:53+00:00" + "time": "2017-07-01T08:51:00+00:00" }, { "name": "sebastian/exporter", @@ -1165,23 +1125,23 @@ }, { "name": "sebastian/global-state", - "version": "1.1.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^6.0" }, "suggest": { "ext-uopz": "*" @@ -1189,7 +1149,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1212,25 +1172,25 @@ "keywords": [ "global state" ], - "time": "2015-10-12T03:26:01+00:00" + "time": "2017-04-27T15:39:26+00:00" }, { "name": "sebastian/object-enumerator", - "version": "3.0.2", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "31dd3379d16446c5d86dec32ab1ad1f378581ad8" + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/31dd3379d16446c5d86dec32ab1ad1f378581ad8", - "reference": "31dd3379d16446c5d86dec32ab1ad1f378581ad8", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", "shasum": "" }, "require": { "php": "^7.0", - "sebastian/object-reflector": "^1.0", + "sebastian/object-reflector": "^1.1.1", "sebastian/recursion-context": "^3.0" }, "require-dev": { @@ -1259,7 +1219,7 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-03-12T15:17:29+00:00" + "time": "2017-08-03T12:35:26+00:00" }, { "name": "sebastian/object-reflector", @@ -1361,25 +1321,25 @@ }, { "name": "sebastian/resource-operations", - "version": "1.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", "shasum": "" }, "require": { - "php": ">=5.6.0" + "php": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1399,7 +1359,7 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28T20:34:47+00:00" + "time": "2018-10-04T04:07:39+00:00" }, { "name": "sebastian/version", @@ -1444,18 +1404,58 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, + { + "name": "theseer/tokenizer", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "time": "2017-04-07T12:08:54+00:00" + }, { "name": "webmozart/assert", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", "shasum": "" }, "require": { @@ -1492,7 +1492,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2018-01-29T19:49:41+00:00" } ], "aliases": [], @@ -1501,7 +1501,10 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7" + "php": ">=7.2" }, - "platform-dev": [] + "platform-dev": [], + "platform-overrides": { + "php": "7.2" + } } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1f1f90a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3' + +services: + php: + image: custom-php-cli + container_name: tictactoe + build: docker/php-cli + tty: true + volumes: + - ./:/code diff --git a/docker/php-cli/Dockerfile b/docker/php-cli/Dockerfile new file mode 100644 index 0000000..432295a --- /dev/null +++ b/docker/php-cli/Dockerfile @@ -0,0 +1,16 @@ +FROM php:7-cli + +RUN apt-get update && apt-get -y install \ + curl \ + zip \ + unzip \ + vim +RUN pecl install xdebug +RUN docker-php-ext-enable xdebug +RUN rm -rf /var/lib/apt/lists/* + +# Install Composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +RUN composer --version + +WORKDIR /code diff --git a/phpcs.xml b/phpcs.xml index dbf467b..288bd4c 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -5,6 +5,7 @@ + tests/* */Test/* */vendor/* */coverage/* diff --git a/phpunit.xml b/phpunit.xml index e15153a..844b241 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -3,6 +3,7 @@ ./src/TicTacToe/Test/ + ./tests/ @@ -10,10 +11,8 @@ ./src/TicTacToe/ ./src/TicTacToe/Test/ + ./vendor/ - - ./vendor/ - diff --git a/src/TicTacToe/Domain/Player/Exception/SorryInvalidPlayerToken.php b/src/TicTacToe/Domain/Player/Exception/SorryInvalidPlayerToken.php new file mode 100644 index 0000000..97bd5ed --- /dev/null +++ b/src/TicTacToe/Domain/Player/Exception/SorryInvalidPlayerToken.php @@ -0,0 +1,9 @@ + self::MAX_LENGTH) { + throw new SorryPlayerNameIsTooLong("Player name is too long, maximum " . self::MAX_LENGTH); + } + + $this->name = $name; + } + + public function __toString(): string + { + return $this->name; + } +} diff --git a/src/TicTacToe/Domain/Player/PlayerToken.php b/src/TicTacToe/Domain/Player/PlayerToken.php new file mode 100644 index 0000000..076a038 --- /dev/null +++ b/src/TicTacToe/Domain/Player/PlayerToken.php @@ -0,0 +1,44 @@ +token = $token; + } + + public static function createGameTokenX(): PlayerToken + { + return new self(self::X_TOKEN); + } + + public static function createGameTokenY(): PlayerToken + { + return new self(self::Y_TOKEN); + } + + public function __toString(): string + { + return $this->token; + } +} diff --git a/src/TicTacToe/Infrastructure/UI/Console/ConsoleOutput.php b/src/TicTacToe/Infrastructure/UI/Console/ConsoleOutput.php new file mode 100644 index 0000000..c19c176 --- /dev/null +++ b/src/TicTacToe/Infrastructure/UI/Console/ConsoleOutput.php @@ -0,0 +1,35 @@ + Date: Tue, 30 Oct 2018 12:24:25 +0100 Subject: [PATCH 02/75] - require ramsey/uuid to use UUID as ids. --- composer.json | 1 + composer.lock | 187 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 187 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f1045a0..f5876d0 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ ], "require": { "php": ">=7.2", + "ramsey/uuid": "^3.8", "squizlabs/php_codesniffer": "2.*" }, "require-dev": { diff --git a/composer.lock b/composer.lock index d0ee4a6..4f9e478 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,135 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "824cfb8613b2c691c905bf589c7be738", + "content-hash": "374f5505671a0c5ae34afa80ef0c060d", "packages": [ + { + "name": "paragonie/random_compat", + "version": "v9.99.99", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "shasum": "" + }, + "require": { + "php": "^7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "time": "2018-07-02T15:55:56+00:00" + }, + { + "name": "ramsey/uuid", + "version": "3.8.0", + "source": { + "type": "git", + "url": "https://github.com/ramsey/uuid.git", + "reference": "d09ea80159c1929d75b3f9c60504d613aeb4a1e3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/d09ea80159c1929d75b3f9c60504d613aeb4a1e3", + "reference": "d09ea80159c1929d75b3f9c60504d613aeb4a1e3", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "^1.0|^2.0|9.99.99", + "php": "^5.4 || ^7.0", + "symfony/polyfill-ctype": "^1.8" + }, + "replace": { + "rhumsaa/uuid": "self.version" + }, + "require-dev": { + "codeception/aspect-mock": "^1.0 | ~2.0.0", + "doctrine/annotations": "~1.2.0", + "goaop/framework": "1.0.0-alpha.2 | ^1.0 | ~2.1.0", + "ircmaxell/random-lib": "^1.1", + "jakub-onderka/php-parallel-lint": "^0.9.0", + "mockery/mockery": "^0.9.9", + "moontoast/math": "^1.1", + "php-mock/php-mock-phpunit": "^0.3|^1.1", + "phpunit/phpunit": "^4.7|^5.0|^6.5", + "squizlabs/php_codesniffer": "^2.3" + }, + "suggest": { + "ext-ctype": "Provides support for PHP Ctype functions", + "ext-libsodium": "Provides the PECL libsodium extension for use with the SodiumRandomGenerator", + "ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator", + "ircmaxell/random-lib": "Provides RandomLib for use with the RandomLibAdapter", + "moontoast/math": "Provides support for converting UUID to 128-bit integer (in string form).", + "ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid", + "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Ramsey\\Uuid\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marijn Huizendveld", + "email": "marijn.huizendveld@gmail.com" + }, + { + "name": "Thibaud Fabre", + "email": "thibaud@aztech.io" + }, + { + "name": "Ben Ramsey", + "email": "ben@benramsey.com", + "homepage": "https://benramsey.com" + } + ], + "description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).", + "homepage": "https://github.com/ramsey/uuid", + "keywords": [ + "guid", + "identifier", + "uuid" + ], + "time": "2018-07-19T23:38:55+00:00" + }, { "name": "squizlabs/php_codesniffer", "version": "2.8.1", @@ -83,6 +210,64 @@ "standards" ], "time": "2017-03-01T22:17:45+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.9.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2018-08-06T14:22:27+00:00" } ], "packages-dev": [ From 994af8b1b1f3cc89736e0045f8c8eb14b14103b9 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 30 Oct 2018 13:35:39 +0100 Subject: [PATCH 03/75] - Fix makefile for travis --- .travis.yml | 2 ++ Makefile | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1a9ef04..d29904d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +env: + - RUNNER=travis language: php php: - '7.0' diff --git a/Makefile b/Makefile index 421c47c..488990e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ CMD = docker-compose exec php COMPOSER ?= composer PROJECT = "TicTacToe." +ENV = ${RUNNER} + +ifeq ($(ENV),"travis") + CMD = "" +endif all: clear lint-composer lint-php composer phpcs play @@ -13,6 +18,7 @@ lint-php: @find src -type f -name \*.php | while read file; do php -l "$$file" || exit 1; done composer: + @echo "\n==> Running composer install, runner $(RUNNER)" $(CMD) $(COMPOSER) install clear: From 226a0abc8fd2917c0426e4199c3080d9966e2b0f Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 30 Oct 2018 13:40:03 +0100 Subject: [PATCH 04/75] try to make travis happy --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 488990e..1559ede 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CMD = docker-compose exec php COMPOSER ?= composer PROJECT = "TicTacToe." -ENV = ${RUNNER} +ENV = $(RUNNER) ifeq ($(ENV),"travis") CMD = "" From ac583bfd2a30145a0603b9c8746b38ee5569c268 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 30 Oct 2018 13:54:31 +0100 Subject: [PATCH 05/75] make travis happy --- Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 1559ede..846206a 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ -CMD = docker-compose exec php COMPOSER ?= composer PROJECT = "TicTacToe." -ENV = $(RUNNER) -ifeq ($(ENV),"travis") - CMD = "" +ifeq ($(RUNNER), travis) + CMD := +else + CMD := docker-compose exec php endif all: clear lint-composer lint-php composer phpcs play @@ -37,6 +37,7 @@ coverage: $(CMD) bin/phpunit --coverage-html coverage tests: + @echo "\n==> Running tests .. $(RUNNER)" $(CMD) bin/phpunit From ada1a6f255948ecc80f8548b321498d9ca358084 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 30 Oct 2018 14:00:04 +0100 Subject: [PATCH 06/75] use php 7.2 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d29904d..37fb286 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,5 @@ env: - RUNNER=travis language: php php: - - '7.0' + - '7.2' install: make all From 4e98ac0e5bc9d5eaeeb65cd342ef0281d3cd6020 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 30 Oct 2018 14:03:55 +0100 Subject: [PATCH 07/75] make phpcs happy --- src/TicTacToe/Application.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/TicTacToe/Application.php b/src/TicTacToe/Application.php index c79859e..d6fc1ba 100644 --- a/src/TicTacToe/Application.php +++ b/src/TicTacToe/Application.php @@ -182,11 +182,18 @@ protected function gameHasWinner($marker) $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#"), IOHandler::SUCCESS); $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " "), IOHandler::SUCCESS); $this->ioHandler->writeLine($this->getBorderedStringWithPadding("Hoorrraaayyy !"), IOHandler::SUCCESS); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding($winner->getName() . " won!"), IOHandler::SUCCESS); + $this->ioHandler->writeLine( + $this->getBorderedStringWithPadding($winner->getName() . " won!"), + IOHandler::SUCCESS + ); + foreach ($this->board->getBoard() as $boardRow) { $this->ioHandler->writeLine($this->getBorderedStringWithPadding($boardRow), IOHandler::SUCCESS); } - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("Thank you for playing Tic-Tac-Toe"), IOHandler::SUCCESS); + $this->ioHandler->writeLine( + $this->getBorderedStringWithPadding("Thank you for playing Tic-Tac-Toe"), + IOHandler::SUCCESS + ); $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " "), IOHandler::SUCCESS); $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#"), IOHandler::SUCCESS); } From 62ee466ca7c5ff153d57a9e21772e5b42f61eef7 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 30 Oct 2018 14:05:12 +0100 Subject: [PATCH 08/75] better Makefile --- Makefile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 846206a..e539b23 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ else CMD := docker-compose exec php endif -all: clear lint-composer lint-php composer phpcs play +all: clear lint-composer lint-php composer phpcs lint-composer: @echo "\n==> Validating composer.json and composer.lock:" @@ -23,6 +23,7 @@ composer: clear: $(CMD) rm -rf vendor + $(CMD) rm -rf bin/php* phpcs: $(CMD) bin/phpcs --standard=phpcs.xml -p @@ -30,9 +31,6 @@ phpcs: phpcbf: $(CMD) bin/phpcbf -play: - $(CMD) bin/App.php - coverage: $(CMD) bin/phpunit --coverage-html coverage @@ -41,4 +39,4 @@ tests: $(CMD) bin/phpunit -.PHONY: lint-php lint-composer phpcs phpcbf composer clear play tests coverage +.PHONY: lint-php lint-composer phpcs phpcbf composer clear tests coverage From 90139a5e1f6743a3da0f04ddbd5b4c01bb4216cb Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 30 Oct 2018 14:16:28 +0100 Subject: [PATCH 09/75] - red tests for creating valid player --- src/TicTacToe/Domain/Player/Player.php | 34 +++++++++++++++++++++++++ tests/unit/Domain/Player/PlayerTest.php | 26 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 tests/unit/Domain/Player/PlayerTest.php diff --git a/src/TicTacToe/Domain/Player/Player.php b/src/TicTacToe/Domain/Player/Player.php index 43116e0..5f058fa 100644 --- a/src/TicTacToe/Domain/Player/Player.php +++ b/src/TicTacToe/Domain/Player/Player.php @@ -6,8 +6,42 @@ final class Player { + /** @var PlayerId */ + private $id; + /** @var PlayerName */ private $name; + /** @var PlayerToken */ private $gameToken; + + public function __construct(PlayerId $id, PlayerName $name, PlayerToken $token) + { + $this->id = $id; + $this->name = $name; + $this->gameToken = $token; + } + + public static function createPlayerWithTokenX(string $name): Player + { + return new self( + new PlayerId(), + new PlayerName($name), + PlayerToken::createGameTokenX() + ); + } + + public static function createPlayerWithTokenY(string $name): Player + { + return new self( + new PlayerId(), + new PlayerName($name), + PlayerToken::createGameTokenY() + ); + } + + public function name(): string + { + return (string) $this->name; + } } diff --git a/tests/unit/Domain/Player/PlayerTest.php b/tests/unit/Domain/Player/PlayerTest.php new file mode 100644 index 0000000..396fe8d --- /dev/null +++ b/tests/unit/Domain/Player/PlayerTest.php @@ -0,0 +1,26 @@ +name()); + self::assertEquals('x', $player->token()); + } + + +} From 4c144f5707a541a72103c8abc827eb346c33364a Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 30 Oct 2018 14:17:28 +0100 Subject: [PATCH 10/75] - green tests for getting player token after creation. --- src/TicTacToe/Domain/Player/Player.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/TicTacToe/Domain/Player/Player.php b/src/TicTacToe/Domain/Player/Player.php index 5f058fa..6009c6b 100644 --- a/src/TicTacToe/Domain/Player/Player.php +++ b/src/TicTacToe/Domain/Player/Player.php @@ -44,4 +44,9 @@ public function name(): string { return (string) $this->name; } + + public function token(): string + { + return (string) $this->gameToken; + } } From 4d8ee46037c84bb34d1d4856e9d969f513857252 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 30 Oct 2018 14:20:36 +0100 Subject: [PATCH 11/75] - green tests after refactor function. --- src/TicTacToe/Domain/Player/Player.php | 8 ++++---- tests/unit/Domain/Player/PlayerTest.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/TicTacToe/Domain/Player/Player.php b/src/TicTacToe/Domain/Player/Player.php index 6009c6b..60cc29e 100644 --- a/src/TicTacToe/Domain/Player/Player.php +++ b/src/TicTacToe/Domain/Player/Player.php @@ -13,13 +13,13 @@ final class Player private $name; /** @var PlayerToken */ - private $gameToken; + private $playingToken; public function __construct(PlayerId $id, PlayerName $name, PlayerToken $token) { $this->id = $id; $this->name = $name; - $this->gameToken = $token; + $this->playingToken = $token; } public static function createPlayerWithTokenX(string $name): Player @@ -45,8 +45,8 @@ public function name(): string return (string) $this->name; } - public function token(): string + public function playingToken(): string { - return (string) $this->gameToken; + return (string) $this->playingToken; } } diff --git a/tests/unit/Domain/Player/PlayerTest.php b/tests/unit/Domain/Player/PlayerTest.php index 396fe8d..e80ecea 100644 --- a/tests/unit/Domain/Player/PlayerTest.php +++ b/tests/unit/Domain/Player/PlayerTest.php @@ -19,7 +19,7 @@ public function testPlayerCreatedSuccessfully() ); self::assertEquals("mina", $player->name()); - self::assertEquals('x', $player->token()); + self::assertEquals('x', $player->playingToken()); } From bf9c95fac46fc65e533b45c5cf6cead076ca5ed8 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 30 Oct 2018 14:36:43 +0100 Subject: [PATCH 12/75] - green tests for Player. --- src/TicTacToe/Domain/Player/Player.php | 5 +++++ src/TicTacToe/Domain/Player/PlayerId.php | 28 ++++++++++++++++++++++++ tests/unit/Domain/Player/PlayerTest.php | 23 ++++++++++++++++++- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/TicTacToe/Domain/Player/PlayerId.php diff --git a/src/TicTacToe/Domain/Player/Player.php b/src/TicTacToe/Domain/Player/Player.php index 60cc29e..9d94955 100644 --- a/src/TicTacToe/Domain/Player/Player.php +++ b/src/TicTacToe/Domain/Player/Player.php @@ -49,4 +49,9 @@ public function playingToken(): string { return (string) $this->playingToken; } + + public function id(): PlayerId + { + return $this->id; + } } diff --git a/src/TicTacToe/Domain/Player/PlayerId.php b/src/TicTacToe/Domain/Player/PlayerId.php new file mode 100644 index 0000000..3c6555d --- /dev/null +++ b/src/TicTacToe/Domain/Player/PlayerId.php @@ -0,0 +1,28 @@ +id = null === $id ? Uuid::uuid4()->toString() : $id; + } + + public function equals(PlayerId $playerId) + { + return $this->id === (string) $playerId; + } + + public function __toString(): string + { + return $this->id; + } +} diff --git a/tests/unit/Domain/Player/PlayerTest.php b/tests/unit/Domain/Player/PlayerTest.php index e80ecea..548a004 100644 --- a/tests/unit/Domain/Player/PlayerTest.php +++ b/tests/unit/Domain/Player/PlayerTest.php @@ -12,15 +12,36 @@ class PlayerTest extends TestCase { public function testPlayerCreatedSuccessfully() { + $playerId = new PlayerId(); $player = new Player( - new PlayerId(), + $playerId, new PlayerName("mina"), PlayerToken::createGameTokenX() ); self::assertEquals("mina", $player->name()); self::assertEquals('x', $player->playingToken()); + self::assertInstanceOf(PlayerId::class, $player->id()); + self::assertTrue($playerId->equals($player->id())); } + public function testPlayerCreatedWithPlayingTokenXSuccessfully() + { + $player = Player::createPlayerWithTokenX("mina"); + + self::assertEquals("mina", $player->name()); + self::assertEquals('x', $player->playingToken()); + self::assertInstanceOf(PlayerId::class, $player->id()); + self::assertNotNull($player->id()); + } + public function testPlayerCreatedWithPlayingTokenYSuccessfully() + { + $player = Player::createPlayerWithTokenY("mina"); + + self::assertEquals("mina", $player->name()); + self::assertEquals('y', $player->playingToken()); + self::assertInstanceOf(PlayerId::class, $player->id()); + self::assertNotNull($player->id()); + } } From db84cede0850b84d36b5ee15911a15b2966c74e6 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 30 Oct 2018 15:00:09 +0100 Subject: [PATCH 13/75] More player tests. --- tests/unit/Domain/Player/PlayerTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/unit/Domain/Player/PlayerTest.php b/tests/unit/Domain/Player/PlayerTest.php index 548a004..9424c28 100644 --- a/tests/unit/Domain/Player/PlayerTest.php +++ b/tests/unit/Domain/Player/PlayerTest.php @@ -3,6 +3,8 @@ declare(strict_types = 1); use PHPUnit\Framework\TestCase; +use TicTacToe\Domain\Player\Exception\SorryPlayerNameIsTooLong; +use TicTacToe\Domain\Player\Exception\SorryPlayerNameIsTooShort; use TicTacToe\Domain\Player\Player; use TicTacToe\Domain\Player\PlayerId; use TicTacToe\Domain\Player\PlayerName; @@ -44,4 +46,16 @@ public function testPlayerCreatedWithPlayingTokenYSuccessfully() self::assertInstanceOf(PlayerId::class, $player->id()); self::assertNotNull($player->id()); } + + public function testItThrowsExceptionIfPlayerNameIsShort() + { + self::expectException(SorryPlayerNameIsTooShort::class); + Player::createPlayerWithTokenX("m"); + } + + public function testItThrowsExceptionIfPlayerNameIsLong() + { + self::expectException(SorryPlayerNameIsTooLong::class); + Player::createPlayerWithTokenX("FGLAHETLDGHAELTRHG53Y693576935sfkhglkshfgshfgkfkgherg53yt3589gh358gh359hg395gh395"); + } } From eb340797132c1bd8272a94fa1c39d4f533e986f0 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 1 Nov 2018 13:32:37 +0100 Subject: [PATCH 14/75] Green Board / Cell tests. --- Makefile | 6 ++- src/TicTacToe/Domain/Board/Board.php | 49 +++++++++++++++++++ src/TicTacToe/Domain/Board/Cell.php | 28 +++++++++++ .../Exception/SorryBoardSizeIsNotValid.php | 9 ++++ tests/unit/Domain/Board/BoardTest.php | 23 +++++++++ tests/unit/Domain/Board/CellTest.php | 15 ++++++ 6 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 src/TicTacToe/Domain/Board/Board.php create mode 100644 src/TicTacToe/Domain/Board/Cell.php create mode 100644 src/TicTacToe/Domain/Board/Exception/SorryBoardSizeIsNotValid.php create mode 100644 tests/unit/Domain/Board/BoardTest.php create mode 100644 tests/unit/Domain/Board/CellTest.php diff --git a/Makefile b/Makefile index e539b23..cd8e2d2 100644 --- a/Makefile +++ b/Makefile @@ -38,5 +38,9 @@ tests: @echo "\n==> Running tests .. $(RUNNER)" $(CMD) bin/phpunit +build-docker: + @echo "\n==> Docker container building and starting ..." + docker-compose up --build -d -.PHONY: lint-php lint-composer phpcs phpcbf composer clear tests coverage + +.PHONY: lint-php lint-composer phpcs phpcbf composer clear tests coverage build-docker diff --git a/src/TicTacToe/Domain/Board/Board.php b/src/TicTacToe/Domain/Board/Board.php new file mode 100644 index 0000000..c76c503 --- /dev/null +++ b/src/TicTacToe/Domain/Board/Board.php @@ -0,0 +1,49 @@ +size = $size; + $this->initBoard(); + } + + public function size(): int + { + return $this->size; + } + + private function initBoard() + { + foreach (range(0, $this->size - 1) as $row) { + foreach (range(0, $this->size - 1) as $col) { + $this->cellSet[$row][$col] = Cell::empty(); + } + } + } + + public static function create3By3Board(): Board + { + return new Board( + self::BOARD_SIZE_3 + ); + } +} diff --git a/src/TicTacToe/Domain/Board/Cell.php b/src/TicTacToe/Domain/Board/Cell.php new file mode 100644 index 0000000..d259695 --- /dev/null +++ b/src/TicTacToe/Domain/Board/Cell.php @@ -0,0 +1,28 @@ +value = $value; + } + + public function __toString(): string + { + return (string) $this->value; + } + + public static function empty(): Cell + { + return new Cell(''); + } +} diff --git a/src/TicTacToe/Domain/Board/Exception/SorryBoardSizeIsNotValid.php b/src/TicTacToe/Domain/Board/Exception/SorryBoardSizeIsNotValid.php new file mode 100644 index 0000000..965b971 --- /dev/null +++ b/src/TicTacToe/Domain/Board/Exception/SorryBoardSizeIsNotValid.php @@ -0,0 +1,9 @@ +size()); + } + + public function testItThrowsSorryBoardSizeIsNotValid() + { + self::expectException(SorryBoardSizeIsNotValid::class); + new Board(4); + } +} diff --git a/tests/unit/Domain/Board/CellTest.php b/tests/unit/Domain/Board/CellTest.php new file mode 100644 index 0000000..951aa16 --- /dev/null +++ b/tests/unit/Domain/Board/CellTest.php @@ -0,0 +1,15 @@ + Date: Thu, 1 Nov 2018 13:33:54 +0100 Subject: [PATCH 15/75] Green Board tests --- src/TicTacToe/Domain/Board/Cell.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TicTacToe/Domain/Board/Cell.php b/src/TicTacToe/Domain/Board/Cell.php index d259695..a2bf982 100644 --- a/src/TicTacToe/Domain/Board/Cell.php +++ b/src/TicTacToe/Domain/Board/Cell.php @@ -23,6 +23,6 @@ public function __toString(): string public static function empty(): Cell { - return new Cell(''); + return new Cell(); } } From 91d82b2fdcd6932d769eec82b30bd10818937762 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 21 Nov 2018 10:19:07 +0100 Subject: [PATCH 16/75] push modified files --- Makefile | 2 +- README.md | 7 ++-- .../Game/Exception/SorryTooManyPlayers.php | 9 ++++ src/TicTacToe/Domain/Game/Game.php | 31 ++++++++++++++ .../Domain/Player/PlayerRepository.php | 31 ++++++++++++++ src/TicTacToe/Domain/Player/PlayerSet.php | 40 ++++++++++++++++++ .../Repository/InMemoryPlayerRepository.php | 42 +++++++++++++++++++ .../UI/Console/ConsoleOutput.php | 4 +- 8 files changed, 160 insertions(+), 6 deletions(-) create mode 100644 src/TicTacToe/Domain/Game/Exception/SorryTooManyPlayers.php create mode 100644 src/TicTacToe/Domain/Game/Game.php create mode 100644 src/TicTacToe/Domain/Player/PlayerRepository.php create mode 100644 src/TicTacToe/Domain/Player/PlayerSet.php create mode 100644 src/TicTacToe/Infrastructure/Repository/InMemoryPlayerRepository.php diff --git a/Makefile b/Makefile index cd8e2d2..29e9c21 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ else CMD := docker-compose exec php endif -all: clear lint-composer lint-php composer phpcs +all: clear build-docker lint-composer lint-php composer phpcs tests lint-composer: @echo "\n==> Validating composer.json and composer.lock:" diff --git a/README.md b/README.md index 0a82a35..f50f750 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ A php-cli Tic-Tac-Toe simple two players game. ### Requirements -1. `php >= 7.0` (required for `phpunit v6.1`) +1. `php >= 7.2` +2. `Docker` ### Installation @@ -18,11 +19,11 @@ Run `make all` will do all the magic for you. ### Start playing -To start playing the game, you need to run `php main.php` +To start playing the game, you need to run `make play` ### Unit tests -To generate tests report, run `make test`. +To generate tests report, run `make tests`. ### Coverage diff --git a/src/TicTacToe/Domain/Game/Exception/SorryTooManyPlayers.php b/src/TicTacToe/Domain/Game/Exception/SorryTooManyPlayers.php new file mode 100644 index 0000000..a4d1bb6 --- /dev/null +++ b/src/TicTacToe/Domain/Game/Exception/SorryTooManyPlayers.php @@ -0,0 +1,9 @@ + self::MAX_PLAYERS) { + throw new SorryTooManyPlayers("Only " . self::MAX_PLAYERS . " players allowed."); + } + + $this->board = $board; + $this->players = new PlayerSet($players); + } +} diff --git a/src/TicTacToe/Domain/Player/PlayerRepository.php b/src/TicTacToe/Domain/Player/PlayerRepository.php new file mode 100644 index 0000000..2a6b217 --- /dev/null +++ b/src/TicTacToe/Domain/Player/PlayerRepository.php @@ -0,0 +1,31 @@ +players = $players; + } + + /** + * @return array|Player[] + */ + public function toArray(): array + { + return $this->players; + } + + public function getIterator(): \Traversable + { + return new \ArrayIterator($this->toArray()); + } + + public function count() + { + return count($this->players); + } +} diff --git a/src/TicTacToe/Infrastructure/Repository/InMemoryPlayerRepository.php b/src/TicTacToe/Infrastructure/Repository/InMemoryPlayerRepository.php new file mode 100644 index 0000000..d9020de --- /dev/null +++ b/src/TicTacToe/Infrastructure/Repository/InMemoryPlayerRepository.php @@ -0,0 +1,42 @@ +players[(string)$player->id()] = $player; + } + + public function ofId(PlayerId $playerId): ?Player + { + if (!isset($this->players[(string)$playerId->id()])) { + return null; + } + + return $this->players[$playerId->id()]; + } + + public function nextIdentity(): PlayerId + { + return new PlayerId(); + } + + /** + * @return Player[] + */ + public function players(): array + { + return $this->players; + } +} diff --git a/src/TicTacToe/Infrastructure/UI/Console/ConsoleOutput.php b/src/TicTacToe/Infrastructure/UI/Console/ConsoleOutput.php index c19c176..847d481 100644 --- a/src/TicTacToe/Infrastructure/UI/Console/ConsoleOutput.php +++ b/src/TicTacToe/Infrastructure/UI/Console/ConsoleOutput.php @@ -20,12 +20,12 @@ public function error(string $error) public function success(string $message) { - echo sprintf(self::success, $message); + echo sprintf(self::SUCCESS, $message); } public function warning(string $message) { - echo sprintf(self::warning, $message); + echo sprintf(self::WARNING, $message); } public function info(string $message) From 1160d3a48f911a31fa267053f469f4f22a45cae2 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 21 Nov 2018 10:21:18 +0100 Subject: [PATCH 17/75] add phpstan for static analysis --- composer.json | 1 + composer.lock | 1086 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 1049 insertions(+), 38 deletions(-) diff --git a/composer.json b/composer.json index f5876d0..bd1d4ab 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ "squizlabs/php_codesniffer": "2.*" }, "require-dev": { + "phpstan/phpstan": "^0.10.5", "phpunit/phpunit": "^7" }, "autoload": { diff --git a/composer.lock b/composer.lock index 4f9e478..fa58960 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "374f5505671a0c5ae34afa80ef0c060d", + "content-hash": "06a15e3eb8ff60d4b0ca4520c46baac7", "packages": [ { "name": "paragonie/random_compat", @@ -271,6 +271,50 @@ } ], "packages-dev": [ + { + "name": "composer/xdebug-handler", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/b8e9745fb9b06ea6664d8872c4505fb16df4611c", + "reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "time": "2018-08-31T19:07:57+00:00" + }, { "name": "doctrine/instantiator", "version": "1.1.0", @@ -303,75 +347,703 @@ }, "autoload": { "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2017-07-22T11:58:36+00:00" + }, + { + "name": "jean85/pretty-package-versions", + "version": "1.2", + "source": { + "type": "git", + "url": "https://github.com/Jean85/pretty-package-versions.git", + "reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/75c7effcf3f77501d0e0caa75111aff4daa0dd48", + "reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48", + "shasum": "" + }, + "require": { + "ocramius/package-versions": "^1.2.0", + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Jean85\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alessandro Lai", + "email": "alessandro.lai85@gmail.com" + } + ], + "description": "A wrapper for ocramius/package-versions to get pretty versions strings", + "keywords": [ + "composer", + "package", + "release", + "versions" + ], + "time": "2018-06-13T13:22:40+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.8.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2018-06-11T23:09:50+00:00" + }, + { + "name": "nette/bootstrap", + "version": "v2.4.6", + "source": { + "type": "git", + "url": "https://github.com/nette/bootstrap.git", + "reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/bootstrap/zipball/268816e3f1bb7426c3a4ceec2bd38a036b532543", + "reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543", + "shasum": "" + }, + "require": { + "nette/di": "~2.4.7", + "nette/utils": "~2.4", + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "latte/latte": "~2.2", + "nette/application": "~2.3", + "nette/caching": "~2.3", + "nette/database": "~2.3", + "nette/forms": "~2.3", + "nette/http": "~2.4.0", + "nette/mail": "~2.3", + "nette/robot-loader": "^2.4.2 || ^3.0", + "nette/safe-stream": "~2.2", + "nette/security": "~2.3", + "nette/tester": "~2.0", + "tracy/tracy": "^2.4.1" + }, + "suggest": { + "nette/robot-loader": "to use Configurator::createRobotLoader()", + "tracy/tracy": "to use Configurator::enableTracy()" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🅱 Nette Bootstrap: the simple way to configure and bootstrap your Nette application.", + "homepage": "https://nette.org", + "keywords": [ + "bootstrapping", + "configurator", + "nette" + ], + "time": "2018-05-17T12:52:20+00:00" + }, + { + "name": "nette/di", + "version": "v2.4.14", + "source": { + "type": "git", + "url": "https://github.com/nette/di.git", + "reference": "923da3e2c0aa53162ef455472c0ac7787b096c5a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/di/zipball/923da3e2c0aa53162ef455472c0ac7787b096c5a", + "reference": "923da3e2c0aa53162ef455472c0ac7787b096c5a", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "nette/neon": "^2.3.3 || ~3.0.0", + "nette/php-generator": "^2.6.1 || ~3.0.0", + "nette/utils": "^2.4.3 || ~3.0.0", + "php": ">=5.6.0" + }, + "conflict": { + "nette/bootstrap": "<2.4", + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "💎 Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfectly usable autowiring and support for all new PHP 7.1 features.", + "homepage": "https://nette.org", + "keywords": [ + "compiled", + "di", + "dic", + "factory", + "ioc", + "nette", + "static" + ], + "time": "2018-09-17T15:47:40+00:00" + }, + { + "name": "nette/finder", + "version": "v2.4.2", + "source": { + "type": "git", + "url": "https://github.com/nette/finder.git", + "reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/finder/zipball/ee951a656cb8ac622e5dd33474a01fd2470505a0", + "reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0", + "shasum": "" + }, + "require": { + "nette/utils": "~2.4", + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "~2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🔍 Nette Finder: find files and directories with an intuitive API.", + "homepage": "https://nette.org", + "keywords": [ + "filesystem", + "glob", + "iterator", + "nette" + ], + "time": "2018-06-28T11:49:23+00:00" + }, + { + "name": "nette/neon", + "version": "v2.4.3", + "source": { + "type": "git", + "url": "https://github.com/nette/neon.git", + "reference": "5e72b1dd3e2d34f0863c5561139a19df6a1ef398" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/neon/zipball/5e72b1dd3e2d34f0863c5561139a19df6a1ef398", + "reference": "5e72b1dd3e2d34f0863c5561139a19df6a1ef398", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "ext-json": "*", + "php": ">=5.6.0" + }, + "require-dev": { + "nette/tester": "~2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🍸 Nette NEON: encodes and decodes NEON file format.", + "homepage": "http://ne-on.org", + "keywords": [ + "export", + "import", + "neon", + "nette", + "yaml" + ], + "time": "2018-03-21T12:12:21+00:00" + }, + { + "name": "nette/php-generator", + "version": "v3.0.5", + "source": { + "type": "git", + "url": "https://github.com/nette/php-generator.git", + "reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/php-generator/zipball/ea90209c2e8a7cd087b2742ca553c047a8df5eff", + "reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff", + "shasum": "" + }, + "require": { + "nette/utils": "^2.4.2 || ~3.0.0", + "php": ">=7.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.2 features.", + "homepage": "https://nette.org", + "keywords": [ + "code", + "nette", + "php", + "scaffolding" + ], + "time": "2018-08-09T14:32:27+00:00" + }, + { + "name": "nette/robot-loader", + "version": "v3.1.0", + "source": { + "type": "git", + "url": "https://github.com/nette/robot-loader.git", + "reference": "fc76c70e740b10f091e502b2e393d0be912f38d4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/robot-loader/zipball/fc76c70e740b10f091e502b2e393d0be912f38d4", + "reference": "fc76c70e740b10f091e502b2e393d0be912f38d4", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "nette/finder": "^2.3 || ^3.0", + "nette/utils": "^2.4 || ^3.0", + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.", + "homepage": "https://nette.org", + "keywords": [ + "autoload", + "class", + "interface", + "nette", + "trait" + ], + "time": "2018-08-13T14:19:06+00:00" + }, + { + "name": "nette/utils", + "version": "v2.5.3", + "source": { + "type": "git", + "url": "https://github.com/nette/utils.git", + "reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/utils/zipball/17b9f76f2abd0c943adfb556e56f2165460b15ce", + "reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "~2.0", + "tracy/tracy": "^2.3" + }, + "suggest": { + "ext-gd": "to use Image", + "ext-iconv": "to use Strings::webalize() and toAscii()", + "ext-intl": "for script transliteration in Strings::webalize() and toAscii()", + "ext-json": "to use Nette\\Utils\\Json", + "ext-mbstring": "to use Strings::lower() etc...", + "ext-xml": "to use Strings::length() etc. when mbstring is not available" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ], + "files": [ + "src/loader.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", + "homepage": "https://nette.org", + "keywords": [ + "array", + "core", + "datetime", + "images", + "json", + "nette", + "paginator", + "password", + "slugify", + "string", + "unicode", + "utf-8", + "utility", + "validation" + ], + "time": "2018-09-18T10:22:16+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v4.1.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "d0230c5c77a7e3cfa69446febf340978540958c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/d0230c5c77a7e3cfa69446febf340978540958c0", + "reference": "d0230c5c77a7e3cfa69446febf340978540958c0", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.5 || ^7.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" + "name": "Nikita Popov" } ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "description": "A PHP parser written in PHP", "keywords": [ - "constructor", - "instantiate" + "parser", + "php" ], - "time": "2017-07-22T11:58:36+00:00" + "time": "2018-10-10T09:24:14+00:00" }, { - "name": "myclabs/deep-copy", - "version": "1.8.1", + "name": "ocramius/package-versions", + "version": "1.3.0", "source": { "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" + "url": "https://github.com/Ocramius/PackageVersions.git", + "reference": "4489d5002c49d55576fa0ba786f42dbb009be46f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/4489d5002c49d55576fa0ba786f42dbb009be46f", + "reference": "4489d5002c49d55576fa0ba786f42dbb009be46f", "shasum": "" }, "require": { - "php": "^7.1" - }, - "replace": { - "myclabs/deep-copy": "self.version" + "composer-plugin-api": "^1.0.0", + "php": "^7.1.0" }, "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" + "composer/composer": "^1.6.3", + "ext-zip": "*", + "infection/infection": "^0.7.1", + "phpunit/phpunit": "^7.0.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PackageVersions\\Installer", + "branch-alias": { + "dev-master": "2.0.x-dev" + } }, - "type": "library", "autoload": { "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, - "files": [ - "src/DeepCopy/deep_copy.php" - ] + "PackageVersions\\": "src/PackageVersions" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } ], - "time": "2018-06-11T23:09:50+00:00" + "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", + "time": "2018-02-05T13:05:30+00:00" }, { "name": "phar-io/manifest", @@ -690,6 +1362,121 @@ ], "time": "2018-08-05T17:53:17+00:00" }, + { + "name": "phpstan/phpdoc-parser", + "version": "0.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "ed3223362174b8067729930439e139794e9e514a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/ed3223362174b8067729930439e139794e9e514a", + "reference": "ed3223362174b8067729930439e139794e9e514a", + "shasum": "" + }, + "require": { + "php": "~7.1" + }, + "require-dev": { + "consistence/coding-standard": "^2.0.0", + "jakub-onderka/php-parallel-lint": "^0.9.2", + "phing/phing": "^2.16.0", + "phpstan/phpstan": "^0.10@dev", + "phpunit/phpunit": "^6.3", + "slevomat/coding-standard": "^3.3.0", + "symfony/process": "^3.4 || ^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + }, + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "time": "2018-06-20T17:48:01+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "0.10.5", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "c6a8cd1fe08a23b9d101a55ffa9ff6b91d71ef5d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c6a8cd1fe08a23b9d101a55ffa9ff6b91d71ef5d", + "reference": "c6a8cd1fe08a23b9d101a55ffa9ff6b91d71ef5d", + "shasum": "" + }, + "require": { + "composer/xdebug-handler": "^1.3.0", + "jean85/pretty-package-versions": "^1.0.3", + "nette/bootstrap": "^2.4 || ^3.0", + "nette/di": "^2.4.7 || ^3.0", + "nette/robot-loader": "^3.0.1", + "nette/utils": "^2.4.5 || ^3.0", + "nikic/php-parser": "^4.0.2", + "php": "~7.1", + "phpstan/phpdoc-parser": "^0.3", + "symfony/console": "~3.2 || ~4.0", + "symfony/finder": "~3.2 || ~4.0" + }, + "require-dev": { + "brianium/paratest": "^2.0", + "consistence/coding-standard": "^3.5", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "ext-gd": "*", + "ext-intl": "*", + "ext-mysqli": "*", + "ext-zip": "*", + "jakub-onderka/php-parallel-lint": "^1.0", + "localheinz/composer-normalize": "~0.9.0", + "phing/phing": "^2.16.0", + "phpstan/phpstan-deprecation-rules": "^0.10.2", + "phpstan/phpstan-php-parser": "^0.10", + "phpstan/phpstan-phpunit": "^0.10", + "phpstan/phpstan-strict-rules": "^0.10", + "phpunit/phpunit": "^7.0", + "slevomat/coding-standard": "^4.7.2" + }, + "bin": [ + "bin/phpstan" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.10-dev" + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": [ + "src/", + "build/PHPStan" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "time": "2018-10-20T17:24:55+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "6.1.3", @@ -1026,6 +1813,53 @@ ], "time": "2018-10-23T05:57:41+00:00" }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.1", @@ -1589,6 +2423,182 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, + { + "name": "symfony/console", + "version": "v4.1.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "432122af37d8cd52fba1b294b11976e0d20df595" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/432122af37d8cd52fba1b294b11976e0d20df595", + "reference": "432122af37d8cd52fba1b294b11976e0d20df595", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~3.4|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.4|~4.0" + }, + "suggest": { + "psr/log-implementation": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2018-10-31T09:30:44+00:00" + }, + { + "name": "symfony/finder", + "version": "v4.1.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "1f17195b44543017a9c9b2d437c670627e96ad06" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/1f17195b44543017a9c9b2d437c670627e96ad06", + "reference": "1f17195b44543017a9c9b2d437c670627e96ad06", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2018-10-03T08:47:56+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2018-09-21T13:07:52+00:00" + }, { "name": "theseer/tokenizer", "version": "1.1.0", From 2f730bc9940e88b0243a790f9dfa69643bf84672 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 21 Nov 2018 10:23:42 +0100 Subject: [PATCH 18/75] add phpstan for doctrine --- composer.json | 1 + composer.lock | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bd1d4ab..cd0ba09 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ }, "require-dev": { "phpstan/phpstan": "^0.10.5", + "phpstan/phpstan-doctrine": "^0.10.0", "phpunit/phpunit": "^7" }, "autoload": { diff --git a/composer.lock b/composer.lock index fa58960..dc07572 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "06a15e3eb8ff60d4b0ca4520c46baac7", + "content-hash": "2433582596775155d720482ec27b1075", "packages": [ { "name": "paragonie/random_compat", @@ -1477,6 +1477,61 @@ "description": "PHPStan - PHP Static Analysis Tool", "time": "2018-10-20T17:24:55+00:00" }, + { + "name": "phpstan/phpstan-doctrine", + "version": "0.10", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-doctrine.git", + "reference": "a0314b1fa5b4d76880e4e9542ee01f3df8471630" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/a0314b1fa5b4d76880e4e9542ee01f3df8471630", + "reference": "a0314b1fa5b4d76880e4e9542ee01f3df8471630", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.0", + "php": "~7.1", + "phpstan/phpstan": "^0.10" + }, + "conflict": { + "doctrine/collections": "<1.0", + "doctrine/common": "<2.7", + "doctrine/orm": "<2.5" + }, + "require-dev": { + "consistence/coding-standard": "^3.0.1", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "doctrine/collections": "^1.0", + "doctrine/common": "^2.7", + "doctrine/orm": "^2.5", + "jakub-onderka/php-parallel-lint": "^1.0", + "phing/phing": "^2.16.0", + "phpstan/phpstan-phpunit": "^0.10", + "phpstan/phpstan-strict-rules": "^0.10", + "phpunit/phpunit": "^7.0", + "slevomat/coding-standard": "^4.5.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.10-dev" + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Doctrine extensions for PHPStan", + "time": "2018-05-28T20:08:30+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "6.1.3", From bb1c8f66596b9a8b1c1a82df00e3f78333b2a13c Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 21 Nov 2018 10:36:25 +0100 Subject: [PATCH 19/75] add support for phpstan --- Makefile | 10 +++++++--- phpstan.neon | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 phpstan.neon diff --git a/Makefile b/Makefile index 29e9c21..7f0d2ee 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ else CMD := docker-compose exec php endif -all: clear build-docker lint-composer lint-php composer phpcs tests +all: clear build-docker lint-composer lint-php composer phpcs tests static-analysis lint-composer: @echo "\n==> Validating composer.json and composer.lock:" @@ -35,12 +35,16 @@ coverage: $(CMD) bin/phpunit --coverage-html coverage tests: - @echo "\n==> Running tests .. $(RUNNER)" + @echo "\n==> Running tests" $(CMD) bin/phpunit +static-analysis: + @echo "\n==> Running static analysis" + $(CMD) bin/phpstan -l 7 -c phpstan.neon src tests + build-docker: @echo "\n==> Docker container building and starting ..." docker-compose up --build -d -.PHONY: lint-php lint-composer phpcs phpcbf composer clear tests coverage build-docker +.PHONY: lint-php lint-composer phpcs phpcbf composer clear tests coverage build-docker static-analysis diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..e2cec94 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,2 @@ +includes: + - config.level7.neon From 70cd3bcf87e0d12232d26619fe98f46e9524b6c9 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 21 Nov 2018 11:01:31 +0100 Subject: [PATCH 20/75] better travis job --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 37fb286..b1e92c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,4 @@ env: language: php php: - '7.2' -install: make all +install: make clear lint-composer lint-php composer phpcs tests From 44be3502d3287eacae32c13413344fae1f2d043b Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 22 Nov 2018 17:18:10 +0100 Subject: [PATCH 21/75] fix readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f50f750..69efa50 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# tic-tac-toe-sami +# tic-tac-toe [![Build Status](https://travis-ci.org/mnsami/tic-tac-toe.svg?branch=master)](https://travis-ci.org/mnsami/tic-tac-toe) From 17297a2e30239ea5f1ef5eb60114d1b645f089e4 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 11 Jun 2019 22:14:19 +0200 Subject: [PATCH 22/75] adding first Domain event and AggregateRoot --- .../Domain/Player/Event/PlayerCreated.php | 51 ++++ src/TicTacToe/Domain/Player/Player.php | 15 +- src/TicTacToe/Domain/Shared/AggregateRoot.php | 28 ++ src/TicTacToe/Domain/Shared/Event.php | 29 ++ src/TicTacToe/Player/HumanPlayer.php | 9 - src/TicTacToe/Player/Player.php | 54 ---- src/TicTacToe/Player/PlayerInterface.php | 20 -- src/TicTacToe/Test/ApplicationTest.php | 272 ------------------ src/TicTacToe/Test/BaseTest.php | 26 -- src/TicTacToe/Test/BoardTest.php | 170 ----------- src/TicTacToe/Test/IO/IOHandlerTest.php | 108 ------- src/TicTacToe/Test/Player/HumanPlayerTest.php | 35 --- 12 files changed, 120 insertions(+), 697 deletions(-) create mode 100644 src/TicTacToe/Domain/Player/Event/PlayerCreated.php create mode 100644 src/TicTacToe/Domain/Shared/AggregateRoot.php create mode 100644 src/TicTacToe/Domain/Shared/Event.php delete mode 100644 src/TicTacToe/Player/HumanPlayer.php delete mode 100644 src/TicTacToe/Player/Player.php delete mode 100644 src/TicTacToe/Player/PlayerInterface.php delete mode 100644 src/TicTacToe/Test/ApplicationTest.php delete mode 100644 src/TicTacToe/Test/BaseTest.php delete mode 100644 src/TicTacToe/Test/BoardTest.php delete mode 100644 src/TicTacToe/Test/IO/IOHandlerTest.php delete mode 100644 src/TicTacToe/Test/Player/HumanPlayerTest.php diff --git a/src/TicTacToe/Domain/Player/Event/PlayerCreated.php b/src/TicTacToe/Domain/Player/Event/PlayerCreated.php new file mode 100644 index 0000000..2766dc0 --- /dev/null +++ b/src/TicTacToe/Domain/Player/Event/PlayerCreated.php @@ -0,0 +1,51 @@ +player = $player; + } + + /** + * @inheritDoc + */ + public function occurredAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + /** + * @inheritDoc + */ + public function toArray(): array + { + return [ + 'playerId' => (string) $this->player->id(), + 'name' => $this->player->name(), + 'token' => $this->player->playingToken(), + 'createdAt' => $this->createdAt->format(\DateTimeImmutable::ATOM) + ]; + } + + /** + * @inheritDoc + */ + public function name(): string + { + return PlayerCreated::class; + } +} diff --git a/src/TicTacToe/Domain/Player/Player.php b/src/TicTacToe/Domain/Player/Player.php index 9d94955..525c50f 100644 --- a/src/TicTacToe/Domain/Player/Player.php +++ b/src/TicTacToe/Domain/Player/Player.php @@ -4,7 +4,10 @@ namespace TicTacToe\Domain\Player; -final class Player +use TicTacToe\Domain\Player\Event\PlayerCreated; +use TicTacToe\Domain\Shared\AggregateRoot; + +final class Player extends AggregateRoot { /** @var PlayerId */ private $id; @@ -15,7 +18,7 @@ final class Player /** @var PlayerToken */ private $playingToken; - public function __construct(PlayerId $id, PlayerName $name, PlayerToken $token) + private function __construct(PlayerId $id, PlayerName $name, PlayerToken $token) { $this->id = $id; $this->name = $name; @@ -24,11 +27,17 @@ public function __construct(PlayerId $id, PlayerName $name, PlayerToken $token) public static function createPlayerWithTokenX(string $name): Player { - return new self( + $player = new self( new PlayerId(), new PlayerName($name), PlayerToken::createGameTokenX() ); + + $player->record( + new PlayerCreated($player) + ); + + return $player; } public static function createPlayerWithTokenY(string $name): Player diff --git a/src/TicTacToe/Domain/Shared/AggregateRoot.php b/src/TicTacToe/Domain/Shared/AggregateRoot.php new file mode 100644 index 0000000..c9f4683 --- /dev/null +++ b/src/TicTacToe/Domain/Shared/AggregateRoot.php @@ -0,0 +1,28 @@ +events; + } + + public function resetRecordedEvents() + { + $this->events = []; + } + + protected function record(Event $event) + { + $this->events[] = $event; + } +} diff --git a/src/TicTacToe/Domain/Shared/Event.php b/src/TicTacToe/Domain/Shared/Event.php new file mode 100644 index 0000000..716e9a8 --- /dev/null +++ b/src/TicTacToe/Domain/Shared/Event.php @@ -0,0 +1,29 @@ +isAllowedMarker($marker)) { - $this->marker = $marker; - } - - if (empty($name)) { - $this->name = "Player_" . $marker; - } else { - $this->name = $name; - } - - $this->marker = $marker; - } - - /** - * Checks if the player choose 'x' or 'o' as - * his/her marker. - * - * @param char $marker Makrer player chose - * - * @return true if yes false otherwise - */ - protected function isAllowedMarker($marker) - { - if (in_array(strtolower($marker), $this->allowedMarkers)) { - return true; - } - - throw new \InvalidArgumentException("Only 'x' or 'y' are allowed as markers."); - } - - public function getName() - { - return $this->name; - } - - public function getMarker() - { - return $this->marker; - } -} diff --git a/src/TicTacToe/Player/PlayerInterface.php b/src/TicTacToe/Player/PlayerInterface.php deleted file mode 100644 index b1c3c63..0000000 --- a/src/TicTacToe/Player/PlayerInterface.php +++ /dev/null @@ -1,20 +0,0 @@ -createMock(IOHandler::class); - - $ioHandlerStub->expects($this->exactly(4)) - ->method('readstring') - ->will($this->onConsecutiveCalls('foo','x','baar','o')); - - - $application = new Application($ioHandlerStub); - $application->checkInPlayers(); - - $players = $application->getPlayers(); - - $this->assertEquals(2, count($players)); - - $this->assertEquals('foo', $players[0]->getName()); - $this->assertEquals('x', $players[0]->getMarker()); - $this->assertEquals('baar', $players[1]->getName()); - $this->assertEquals('o', $players[1]->getMarker()); - } - - public function testNextStepSuccess() - { - $ioHandlerStub = $this->createMock(IOHandler::class); - - $ioHandlerStub->expects($this->exactly(5)) - ->method('readstring') - ->will($this->onConsecutiveCalls('foo','x','baar','o', '1')); - - - $application = new Application($ioHandlerStub); - $application->checkInPlayers(); - - $players = $application->getPlayers(); - - $this->assertEquals(0, $application->getMovesCount()); - $this->assertEquals(2, count($players)); - - $this->assertEquals('foo', $players[0]->getName()); - $this->assertEquals('x', $players[0]->getMarker()); - $this->assertEquals('baar', $players[1]->getName()); - $this->assertEquals('o', $players[1]->getMarker()); - - $this->invokeMethod($application, 'nextStep'); - $this->assertEquals(1, $application->getMovesCount()); - $this->assertNotNull($application->getCellValue(1)); - } - - public function testCheckInPlayersFailureAndRetrial() - { - $ioHandlerStub = $this->createMock(IOHandler::class); - - $ioHandlerStub->expects($this->any()) - ->method('readString') - ->will($this->onConsecutiveCalls('foo','x','baar','x', 'o')); - - $application = new Application($ioHandlerStub); - - $application->checkInPlayers(); - $players = $application->getPlayers(); - - $this->assertEquals(2, count($players)); - - $this->assertEquals('foo', $players[0]->getName()); - $this->assertEquals('x', $players[0]->getMarker()); - $this->assertEquals('baar', $players[1]->getName()); - $this->assertEquals('o', $players[1]->getMarker()); - } - - public function testGetPlayerByMarkerSuccess() - { - $ioHandlerStub = $this->createMock(IOHandler::class); - - $ioHandlerStub->expects($this->any()) - ->method('readString') - ->will($this->onConsecutiveCalls('foo','x','baar','x', 'o')); - - $application = new Application($ioHandlerStub); - - $application->checkInPlayers(); - $player = $this->invokeMethod($application, 'getPlayerByMarker', array('x')); - - $this->assertEquals('foo', $player->getName()); - $this->assertEquals('x', $player->getMarker()); - } - - public function testGetPlayerByMarkerReturnNull() - { - $ioHandlerStub = $this->createMock(IOHandler::class); - - $ioHandlerStub->expects($this->any()) - ->method('readString') - ->will($this->onConsecutiveCalls('foo','x','baar','o')); - - $application = new Application($ioHandlerStub); - - $application->checkInPlayers(); - $player = $this->invokeMethod($application, 'getPlayerByMarker', array('i')); - - $this->assertNull($player); - } - - public function testGetBorderedStringWithPadding() - { - $expected = "|############################foobaar#############################|"; - - $ioHandler = new IOHandler(); - $application = new Application($ioHandler); - $result = $this->invokeMethod($application, 'getBorderedStringWithPadding', array('foobaar', '#')); - - $this->assertEquals($expected, $result); - $this->assertEquals(66, strlen($result)); - } - - public function testGetPaddedStringForOutput() - { - $expected = "############################foobaar#############################"; - - $ioHandler = new IOHandler(); - $application = new Application($ioHandler); - $result = $this->invokeMethod($application, 'getPaddedStringForOutput', array('foobaar', '#')); - - $this->assertEquals($expected, $result); - $this->assertEquals(64, strlen($result)); - } - - public function testShowWelcome() - { - $expected = sprintf(IOHandler::INFO, "|################################################################|" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| Tic-Tac-Toe Game |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "|################################################################|" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| Welcome to Tic-Tac-Toe |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| This is a two players tic-tac-toe game. |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| 1 | 2 | 3 |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| ---|---|--- |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| 4 | 5 | 6 |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| ---|---|--- |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| 7 | 8 | 9 |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| To start playing you need to press 's/S', then enter players |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| details (name and marker). If at anytime you want to draw the |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| board press 'd/D'. |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "| Enjoy! |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "|________________________________________________________________|" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, PHP_EOL); - $expected .= sprintf(IOHandler::LIGHT_CYAN, "Press 's/S' to start the game... "); - - $ioHandler = new IOHandler(); - $application = new Application($ioHandler); - - $this->expectOutputString($expected); - $this->invokeMethod($application, 'showWelcome'); - } - - public function testIsGameDrawFalse() - { - $ioHandler = new IOHandler(); - $application = new Application($ioHandler); - - $result = $this->invokeMethod($application, 'isGameDraw'); - - $this->assertFalse($result); - } - - public function testProcessKeyPressShowBoard() - { - $ioHandlerStub = $this->getMockBuilder(IOHandler::class) - ->setMethods(['readString']) - ->getMock(); - - $ioHandlerStub->expects($this->any()) - ->method('readString') - ->willReturn('d'); - - $application = new Application($ioHandlerStub); - - $expected = ""; - $expected .= sprintf(IOHandler::INFO, " | | " . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "---|---|---" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, " | | " . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, "---|---|---" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO, " | | " . PHP_EOL); - - $this->expectOutputString($expected); - $this->invokeMethod($application, 'processInput'); - } - - public function testProcessKeyPressUnidentified() - { - $ioHandlerStub = $this->getMockBuilder(IOHandler::class) - ->setMethods(['readString']) - ->getMock(); - - $ioHandlerStub->expects($this->any()) - ->method('readString') - ->willReturn('q'); - - $application = new Application($ioHandlerStub); - - $expected = ""; - $expected .= sprintf(IOHandler::WARNING, "Unidentified input." . PHP_EOL); - - $this->expectOutputString($expected); - $this->invokeMethod($application, 'processInput'); - } - - public function testProcessInputEnterLocation() - { - $ioHandlerStub = $this->getMockBuilder(IOHandler::class) - ->setMethods(['readString']) - ->getMock(); - - $ioHandlerStub->expects($this->any()) - ->method('readString') - ->willReturn('1'); - - $application = new Application($ioHandlerStub); - - $result = $this->invokeMethod($application, 'processInput'); - $this->assertEquals('1', $result); - } - - public function testProcessKeyPressGameStart() - { - $ioHandlerStub = $this->getMockBuilder(IOHandler::class) - ->setMethods(['readString']) - ->getMock(); - - $ioHandlerStub->expects($this->exactly(5)) - ->method('readString') - ->will($this->onConsecutiveCalls('s','foo','x','baar','o')); - - $application = new Application($ioHandlerStub); - - $this->invokeMethod($application, 'processInput'); - $this->assertTrue($application->isGameStarted()); - } - - public function testGameIsDraw() - { - $expected = ""; - $expected .= sprintf(IOHandler::INFO,"|################################################################|" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO,"| |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO,"| It is a DRAW! |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO,"| Thank you for playing Tic-Tac-Toe. |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO,"| |" . PHP_EOL); - $expected .= sprintf(IOHandler::INFO,"|################################################################|" . PHP_EOL); - - $ioHandler = new IOHandler(); - $application = new Application($ioHandler); - $this->expectOutputString($expected); - $this->invokeMethod($application, 'gameIsDraw'); - } -} diff --git a/src/TicTacToe/Test/BaseTest.php b/src/TicTacToe/Test/BaseTest.php deleted file mode 100644 index 06c79da..0000000 --- a/src/TicTacToe/Test/BaseTest.php +++ /dev/null @@ -1,26 +0,0 @@ -getMethod($methodName); - $method->setAccessible(true); - - return $method->invokeArgs($object, $parameters); - } -} diff --git a/src/TicTacToe/Test/BoardTest.php b/src/TicTacToe/Test/BoardTest.php deleted file mode 100644 index 3b300bf..0000000 --- a/src/TicTacToe/Test/BoardTest.php +++ /dev/null @@ -1,170 +0,0 @@ -assertTrue($board->isValidMove(1)); - } - - public function testSetBoardInvalidMove() - { - $board = new Board(); - - try { - $board->setBoardCell(1, 'x'); - $board->setBoardCell(1, 'o'); - } catch (\Exception $e) { - $this->assertInstanceOf(\LogicException::class, $e); - } - } - - public function testSetBoardThrowsOutOfRangeException() - { - $board = new Board(); - - try { - $board->setBoardCell(10, 'x'); - } catch (\Exception $e) { - $this->assertInstanceOf(\OutOfRangeException::class, $e); - } - } - - public function testCellHasValueTrue() - { - $board = new Board(); - $board->setBoardCell(1, 'x'); - $this->assertTrue($board->cellHasValue(1)); - } - - public function testCheckForWinnerTrue() - { - $board = new Board(); - - $board->setBoardCell(1, 'x'); - $board->setBoardCell(2, 'x'); - $board->setBoardCell(3, 'x'); - - $this->assertEquals('x', $board->checkForWinner()); - } - - public function testCheckForWinnerNoWinner() - { - $board = new Board(); - - $board->setBoardCell(1, 'x'); - $board->setBoardCell(2, 'x'); - $board->setBoardCell(9, 'x'); - - $this->assertEquals(null, $board->checkForWinner()); - } - - public function testGetBoardSize() - { - $board = new Board(); - - $this->assertEquals(3, $board->getBoardSize()); - } - - public function testGetBoardWithEmptyCells() - { - $board = new Board(); - $boardPlan = $board->getBoard(); - - $expected = array( - " | | ", - "---|---|---", - " | | ", - "---|---|---", - " | | ", - ); - $this->assertEquals($expected, $boardPlan); - } - - public function testGetDemoBoard() - { - $board = new Board(); - $boardPlan = $board->demoBoard(); - - $expected = array( - " 1 | 2 | 3 ", - "---|---|---", - " 4 | 5 | 6 ", - "---|---|---", - " 7 | 8 | 9 ", - ); - - $this->assertEquals($expected, $boardPlan); - } - - public function testAreAllCellsFilledTrue() - { - $board = new Board(); - foreach ($this->fillBoardNoWin() as $input) { - $board->setBoardCell($input[0], $input[1]); - } - - $this->assertTrue($board->areAllCellsFilled()); - } - - public function testAreAllCellsFilledFalse() - { - $board = new Board(); - foreach ($this->fillBoard() as $input) { - $board->setBoardCell($input[0], $input[1]); - } - - $this->assertFalse($board->areAllCellsFilled()); - } - - public function testGetCellValueNotEmpty() - { - $board = new Board(); - $board->setBoardCell(1, 'x'); - - $this->assertEquals('x', $board->getCellValue(1)); - } - - public function testGetCellValueEmpty() - { - $board = new Board(); - - $this->assertNull($board->getCellValue(1)); - } - - public function fillBoardNoWin() - { - return array( - array(1, 'x'), - array(2, 'o'), - array(3, 'x'), - array(4, 'o'), - array(5, 'x'), - array(6, 'o'), - array(7, 'o'), - array(8, 'x'), - array(9, 'o') - ); - } - - public function fillBoard() - { - return array( - array(1, 'x'), - array(2, 'o'), - array(3, 'x'), - array(4, 'o'), - array(5, 'x'), - array(6, 'o'), - array(7, 'o'), - array(8, 'x'), - ); - } -} diff --git a/src/TicTacToe/Test/IO/IOHandlerTest.php b/src/TicTacToe/Test/IO/IOHandlerTest.php deleted file mode 100644 index a817efa..0000000 --- a/src/TicTacToe/Test/IO/IOHandlerTest.php +++ /dev/null @@ -1,108 +0,0 @@ -ioHandler = $this->getMockBuilder(IOHandler::class) - ->setMethods(['readStringFromStream', 'readIntegerFromStream']) - ->getMock(); - } - - public function testReadStringEmptyInput() - { - $this->ioHandler->expects($this->once()) - ->method('readStringFromStream') - ->willReturn(''); - - try { - $string = $this->ioHandler->readString(); - } catch (\Exception $e) { - $this->assertInstanceOf(\InvalidArgumentException::class, $e); - } - } - - public function testReadStringSuccess() - { - $this->ioHandler->expects($this->once()) - ->method('readStringFromStream') - ->willReturn('foo'); - - $string = $this->ioHandler->readString(); - $this->assertEquals('foo', $string); - } - - public function testReadStringNotString() - { - $this->ioHandler->expects($this->once()) - ->method('readStringFromStream') - ->willReturn(123); - - try { - $string = $this->ioHandler->readString(); - } catch (\Exception $e) { - $this->assertInstanceOf(\InvalidArgumentException::class, $e); - } - } - - public function testReadIntegerSuccess() - { - $this->ioHandler->expects($this->once()) - ->method('readIntegerFromStream') - ->willReturn(123); - - $integer = $this->ioHandler->readInteger(); - $this->assertEquals(123, $integer); - } - - public function testReadIntegerFailure() - { - $this->ioHandler->expects($this->once()) - ->method('readIntegerFromStream') - ->willReturn("ABC"); - - try { - $integer = $this->ioHandler->readInteger(); - } catch (\Exception $e) { - $this->assertInstanceOf(\InvalidArgumentException::class, $e); - } - } - - public function testWrite() - { - $this->expectOutputString(sprintf(IOHandler::INFO, "foo")); - $this->ioHandler->write("foo"); - } - - public function testWriteWithArrayAsInput() - { - $expected = sprintf(IOHandler::INFO, "foo") . sprintf(IOHandler::INFO, "bar"); - $this->expectOutputString($expected); - $lines[] = "foo"; - $lines[] = "bar"; - $this->ioHandler->write($lines); - // var_dump($this->getActualOutput()); - } - - public function testWriteLine() - { - $this->expectOutputString(sprintf(IOHandler::INFO, "foo" . PHP_EOL)); - $this->ioHandler->writeLine("foo"); - } - - public function testWriteLineWithArrayAsInput() - { - $expected = sprintf(IOHandler::INFO, "foo" . PHP_EOL) . sprintf(IOHandler::INFO, "bar" . PHP_EOL); - $this->expectOutputString($expected); - $lines[] = "foo"; - $lines[] = "bar"; - $this->ioHandler->writeLine($lines); - } -} diff --git a/src/TicTacToe/Test/Player/HumanPlayerTest.php b/src/TicTacToe/Test/Player/HumanPlayerTest.php deleted file mode 100644 index 612d7a8..0000000 --- a/src/TicTacToe/Test/Player/HumanPlayerTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertEquals('mina', $player->getName()); - $this->assertEquals('x', $player->getMarker()); - } - - public function testGetNameWhenNameIsNotProvided() - { - $player = new HumanPlayer('x'); - - $this->assertEquals('Player_x', $player->getName()); - $this->assertEquals('x', $player->getMarker()); - } - - public function testIsAllowedMarkerWithInvalidMarker() - { - try { - $player = new HumanPlayer('1'); - } catch (\Exception $e) { - $this->assertInstanceOf(\InvalidArgumentException::class, $e); - } - } -} - From e82a7f6ff2f5d3da762bf57dc7ba1b6f086bf3e5 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 11 Jun 2019 22:15:34 +0200 Subject: [PATCH 23/75] Record PlayerCreated event. --- src/TicTacToe/Domain/Player/Player.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/TicTacToe/Domain/Player/Player.php b/src/TicTacToe/Domain/Player/Player.php index 525c50f..c336794 100644 --- a/src/TicTacToe/Domain/Player/Player.php +++ b/src/TicTacToe/Domain/Player/Player.php @@ -27,7 +27,7 @@ private function __construct(PlayerId $id, PlayerName $name, PlayerToken $token) public static function createPlayerWithTokenX(string $name): Player { - $player = new self( + $player = new self( new PlayerId(), new PlayerName($name), PlayerToken::createGameTokenX() @@ -42,11 +42,17 @@ public static function createPlayerWithTokenX(string $name): Player public static function createPlayerWithTokenY(string $name): Player { - return new self( + $player = new self( new PlayerId(), new PlayerName($name), PlayerToken::createGameTokenY() ); + + $player->record( + new PlayerCreated($player) + ); + + return $player; } public function name(): string From a945305bef4849013e4b8c0c88824a4ad3a8d3d8 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 11 Jun 2019 22:36:13 +0200 Subject: [PATCH 24/75] green tests for PlayerId. --- tests/unit/Domain/Player/PlayerIdTest.php | 25 +++++++++++++++++++++++ tests/unit/Domain/Player/PlayerTest.php | 8 ++------ 2 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 tests/unit/Domain/Player/PlayerIdTest.php diff --git a/tests/unit/Domain/Player/PlayerIdTest.php b/tests/unit/Domain/Player/PlayerIdTest.php new file mode 100644 index 0000000..e15314a --- /dev/null +++ b/tests/unit/Domain/Player/PlayerIdTest.php @@ -0,0 +1,25 @@ +name()); self::assertEquals('x', $player->playingToken()); self::assertInstanceOf(PlayerId::class, $player->id()); - self::assertTrue($playerId->equals($player->id())); } public function testPlayerCreatedWithPlayingTokenXSuccessfully() From 27b2279a93eb9138686764d415ac40bb998d3781 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 11 Jun 2019 23:06:39 +0200 Subject: [PATCH 25/75] green tests for PlayerCreated. --- .../Domain/Player/Event/PlayerCreated.php | 11 +++---- src/TicTacToe/Domain/Player/Player.php | 9 ++++++ .../Domain/Player/Event/PlayerCreatedTest.php | 29 +++++++++++++++++++ tests/unit/Domain/Player/PlayerIdTest.php | 2 +- 4 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 tests/unit/Domain/Player/Event/PlayerCreatedTest.php diff --git a/src/TicTacToe/Domain/Player/Event/PlayerCreated.php b/src/TicTacToe/Domain/Player/Event/PlayerCreated.php index 2766dc0..b291021 100644 --- a/src/TicTacToe/Domain/Player/Event/PlayerCreated.php +++ b/src/TicTacToe/Domain/Player/Event/PlayerCreated.php @@ -12,9 +12,6 @@ final class PlayerCreated implements Event /** @var Player */ private $player; - /** @var \DateTimeImmutable */ - private $createdAt; - public function __construct(Player $player) { $this->player = $player; @@ -25,7 +22,7 @@ public function __construct(Player $player) */ public function occurredAt(): \DateTimeImmutable { - return $this->createdAt; + return $this->player->createdAt(); } /** @@ -35,9 +32,9 @@ public function toArray(): array { return [ 'playerId' => (string) $this->player->id(), - 'name' => $this->player->name(), - 'token' => $this->player->playingToken(), - 'createdAt' => $this->createdAt->format(\DateTimeImmutable::ATOM) + 'playerName' => $this->player->name(), + 'playerToken' => $this->player->playingToken(), + 'createdAt' => $this->player->createdAt()->format(\DateTimeImmutable::ATOM) ]; } diff --git a/src/TicTacToe/Domain/Player/Player.php b/src/TicTacToe/Domain/Player/Player.php index c336794..88f157e 100644 --- a/src/TicTacToe/Domain/Player/Player.php +++ b/src/TicTacToe/Domain/Player/Player.php @@ -18,11 +18,15 @@ final class Player extends AggregateRoot /** @var PlayerToken */ private $playingToken; + /** @var \DateTimeImmutable */ + private $createdAt; + private function __construct(PlayerId $id, PlayerName $name, PlayerToken $token) { $this->id = $id; $this->name = $name; $this->playingToken = $token; + $this->createdAt = new \DateTimeImmutable(); } public static function createPlayerWithTokenX(string $name): Player @@ -69,4 +73,9 @@ public function id(): PlayerId { return $this->id; } + + public function createdAt(): \DateTimeImmutable + { + return $this->createdAt; + } } diff --git a/tests/unit/Domain/Player/Event/PlayerCreatedTest.php b/tests/unit/Domain/Player/Event/PlayerCreatedTest.php new file mode 100644 index 0000000..d22f92c --- /dev/null +++ b/tests/unit/Domain/Player/Event/PlayerCreatedTest.php @@ -0,0 +1,29 @@ +createPlayer(); + $event = new PlayerCreated($player); + + self::assertEquals($player->createdAt()->getTimestamp(), $event->occurredAt()->getTimestamp()); + + $payload = $event->toArray(); + self::assertArrayHasKey('playerId', $payload); + self::assertArrayHasKey('playerName', $payload); + self::assertArrayHasKey('playerToken', $payload); + } + + public function createPlayer($name = 'foobar') + { + $player = Player::createPlayerWithTokenX($name); + + return $player; + } +} diff --git a/tests/unit/Domain/Player/PlayerIdTest.php b/tests/unit/Domain/Player/PlayerIdTest.php index e15314a..cc32ccc 100644 --- a/tests/unit/Domain/Player/PlayerIdTest.php +++ b/tests/unit/Domain/Player/PlayerIdTest.php @@ -7,7 +7,7 @@ class PlayerIdTest extends \PHPUnit\Framework\TestCase { - public function testItCreateSuccessWithUUID4() + public function testItCreateSuccessWithUUID4IfNothingPassed() { $playerId = new PlayerId(); From 9506df55283d7a9ad6fbf1e2d4da406635cc2a7c Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 11 Jun 2019 23:11:45 +0200 Subject: [PATCH 26/75] green tests for PlayerCreated. --- tests/unit/Domain/Player/Event/PlayerCreatedTest.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/unit/Domain/Player/Event/PlayerCreatedTest.php b/tests/unit/Domain/Player/Event/PlayerCreatedTest.php index d22f92c..f45e005 100644 --- a/tests/unit/Domain/Player/Event/PlayerCreatedTest.php +++ b/tests/unit/Domain/Player/Event/PlayerCreatedTest.php @@ -9,18 +9,25 @@ class PlayerCreatedTest extends \PHPUnit\Framework\TestCase { public function testItExposesCorrectData() { - $player = $this->createPlayer(); + $player = $this->createPlayerX(); $event = new PlayerCreated($player); self::assertEquals($player->createdAt()->getTimestamp(), $event->occurredAt()->getTimestamp()); $payload = $event->toArray(); + self::assertEquals(PlayerCreated::class, $event->name()); + self::assertArrayHasKey('playerId', $payload); + self::assertEquals((string) $player->id(), $payload['playerId']); + self::assertArrayHasKey('playerName', $payload); + self::assertEquals($player->name(), $payload['playerName']); + self::assertArrayHasKey('playerToken', $payload); + self::assertEquals($player->playingToken(), $payload['playerToken']); } - public function createPlayer($name = 'foobar') + public function createPlayerX($name = 'foobar') { $player = Player::createPlayerWithTokenX($name); From 9204058793d3fab03ad4d36ec39218d7f0b07ef6 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 11 Jun 2019 23:25:09 +0200 Subject: [PATCH 27/75] docker make commands. --- Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7f0d2ee..e4c880d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ COMPOSER ?= composer +DOCKER_COMPOSE = docker-compose PROJECT = "TicTacToe." ifeq ($(RUNNER), travis) @@ -42,9 +43,17 @@ static-analysis: @echo "\n==> Running static analysis" $(CMD) bin/phpstan -l 7 -c phpstan.neon src tests +container-stop: + @echo "\n==> Stopping docker container" + $(DOCKER_COMPOSE) stop + +container-down: + @echo "\n==> Removing docker container" + $(DOCKER_COMPOSE) down + build-docker: @echo "\n==> Docker container building and starting ..." docker-compose up --build -d -.PHONY: lint-php lint-composer phpcs phpcbf composer clear tests coverage build-docker static-analysis +.PHONY: lint-php lint-composer phpcs phpcbf composer clear tests coverage build-docker static-analysis container-stop container-down From a98bb81221892fca7e30784f34ebce6505a84ee3 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 12 Jun 2019 10:00:28 +0200 Subject: [PATCH 28/75] better makefile. --- Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e4c880d..576e516 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ else CMD := docker-compose exec php endif -all: clear build-docker lint-composer lint-php composer phpcs tests static-analysis +all: clear container-up lint-composer lint-php composer phpcs tests static-analysis lint-composer: @echo "\n==> Validating composer.json and composer.lock:" @@ -51,9 +51,11 @@ container-down: @echo "\n==> Removing docker container" $(DOCKER_COMPOSE) down -build-docker: +container-up: @echo "\n==> Docker container building and starting ..." - docker-compose up --build -d + $(DOCKER_COMPOSE) up --build -d +tear-down: container-stop container-down -.PHONY: lint-php lint-composer phpcs phpcbf composer clear tests coverage build-docker static-analysis container-stop container-down + +.PHONY: lint-php lint-composer phpcs phpcbf composer clear tests coverage container-up static-analysis container-stop container-down From 7e91ceacd8571951dd9eca1287b8899829f3e775 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 12 Jun 2019 10:05:25 +0200 Subject: [PATCH 29/75] green tests GameId. --- src/TicTacToe/Domain/Game/GameId.php | 28 +++++++++++++++++++++++ tests/unit/Domain/Game/GameIdTest.php | 26 +++++++++++++++++++++ tests/unit/Domain/Player/PlayerIdTest.php | 3 ++- 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/TicTacToe/Domain/Game/GameId.php create mode 100644 tests/unit/Domain/Game/GameIdTest.php diff --git a/src/TicTacToe/Domain/Game/GameId.php b/src/TicTacToe/Domain/Game/GameId.php new file mode 100644 index 0000000..02fd5e0 --- /dev/null +++ b/src/TicTacToe/Domain/Game/GameId.php @@ -0,0 +1,28 @@ +id = null === $id ? Uuid::uuid4()->toString() : $id; + } + + public function equals(GameId $gameId) + { + return $this->id === (string) $gameId; + } + + public function __toString(): string + { + return $this->id; + } +} diff --git a/tests/unit/Domain/Game/GameIdTest.php b/tests/unit/Domain/Game/GameIdTest.php new file mode 100644 index 0000000..91bbe9d --- /dev/null +++ b/tests/unit/Domain/Game/GameIdTest.php @@ -0,0 +1,26 @@ + Date: Wed, 12 Jun 2019 10:21:53 +0200 Subject: [PATCH 30/75] green tests Game. --- src/TicTacToe/Domain/Game/Game.php | 23 ++++++++++-- tests/unit/Domain/Game/GameTest.php | 56 +++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 tests/unit/Domain/Game/GameTest.php diff --git a/src/TicTacToe/Domain/Game/Game.php b/src/TicTacToe/Domain/Game/Game.php index d5d51d8..d8a6b04 100644 --- a/src/TicTacToe/Domain/Game/Game.php +++ b/src/TicTacToe/Domain/Game/Game.php @@ -11,6 +11,9 @@ final class Game { + /** @var GameId */ + private $id; + /** @var PlayerSet */ private $players; @@ -19,13 +22,29 @@ final class Game public const MAX_PLAYERS = 2; - public function __construct(Board $board, Player ...$players) + public function __construct(GameId $gameId, Board $board, Player ...$players) { if (count($players) > self::MAX_PLAYERS) { throw new SorryTooManyPlayers("Only " . self::MAX_PLAYERS . " players allowed."); } + $this->id = $gameId; $this->board = $board; - $this->players = new PlayerSet($players); + $this->players = new PlayerSet(...$players); + } + + public function id(): GameId + { + return $this->id; + } + + public function players(): PlayerSet + { + return $this->players; + } + + public function board(): Board + { + return $this->board; } } diff --git a/tests/unit/Domain/Game/GameTest.php b/tests/unit/Domain/Game/GameTest.php new file mode 100644 index 0000000..5f1e73a --- /dev/null +++ b/tests/unit/Domain/Game/GameTest.php @@ -0,0 +1,56 @@ +createPlayers(2); + $game = new Game($gameId, Board::create3By3Board(), ...$players); + + self::assertEquals(2, $game->players()->count()); + self::assertInstanceOf(GameId::class, $game->id()); + } + + public function testItThrowsTooManyPlayersWhenMorePlayersCreated() + { + $gameId = new GameId(); + $players = $this->createPlayers(3); + self::expectException(SorryTooManyPlayers::class); + $game = new Game($gameId, Board::create3By3Board(), ...$players); + } + + public function randomizeString(int $length) + { + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + return $randomString; + } + + public function createPlayers(int $count) + { + $players = []; + for($i = 0; $i < $count; $i++) { + if ($i % 2 == 0) { + $players[] = Player::createPlayerWithTokenX($this->randomizeString(5)); + } else { + $players[] = Player::createPlayerWithTokenY($this->randomizeString(5)); + } + } + + return $players; + } +} From 18892db1233312102a8342a6686d113c1f29bd69 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 12 Jun 2019 10:42:24 +0200 Subject: [PATCH 31/75] fixes --- src/TicTacToe/Domain/Board/Board.php | 2 +- tests/unit/Domain/Game/GameTest.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/TicTacToe/Domain/Board/Board.php b/src/TicTacToe/Domain/Board/Board.php index c76c503..882718f 100644 --- a/src/TicTacToe/Domain/Board/Board.php +++ b/src/TicTacToe/Domain/Board/Board.php @@ -42,7 +42,7 @@ private function initBoard() public static function create3By3Board(): Board { - return new Board( + return new self( self::BOARD_SIZE_3 ); } diff --git a/tests/unit/Domain/Game/GameTest.php b/tests/unit/Domain/Game/GameTest.php index 5f1e73a..5133c8b 100644 --- a/tests/unit/Domain/Game/GameTest.php +++ b/tests/unit/Domain/Game/GameTest.php @@ -19,6 +19,7 @@ public function testItCreatesGameSuccessfully() self::assertEquals(2, $game->players()->count()); self::assertInstanceOf(GameId::class, $game->id()); + self::assertInstanceOf(Board::class, $game->board()); } public function testItThrowsTooManyPlayersWhenMorePlayersCreated() @@ -26,7 +27,7 @@ public function testItThrowsTooManyPlayersWhenMorePlayersCreated() $gameId = new GameId(); $players = $this->createPlayers(3); self::expectException(SorryTooManyPlayers::class); - $game = new Game($gameId, Board::create3By3Board(), ...$players); + new Game($gameId, Board::create3By3Board(), ...$players); } public function randomizeString(int $length) From fd52704df301ef0b175553b53f11d9b45d1619e7 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 12 Jun 2019 11:24:23 +0200 Subject: [PATCH 32/75] red game tests --- .../Domain/Game/Event/GameCreated.php | 52 +++++++++++++++++++ src/TicTacToe/Domain/Game/Game.php | 26 +++++++++- .../Console/ConsoleOutput.php | 4 +- .../UI => Presentation}/Output.php | 2 +- 4 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 src/TicTacToe/Domain/Game/Event/GameCreated.php rename src/TicTacToe/{Infrastructure/UI => Presentation}/Console/ConsoleOutput.php (88%) rename src/TicTacToe/{Infrastructure/UI => Presentation}/Output.php (85%) diff --git a/src/TicTacToe/Domain/Game/Event/GameCreated.php b/src/TicTacToe/Domain/Game/Event/GameCreated.php new file mode 100644 index 0000000..51e6f27 --- /dev/null +++ b/src/TicTacToe/Domain/Game/Event/GameCreated.php @@ -0,0 +1,52 @@ +game = $game; + } + + /** + * Return event timestamp + * + * @return \DateTimeImmutable + */ + public function occurredAt(): \DateTimeImmutable + { + return $this->game->createdAt(); + } + + /** + * Return event data as array + * + * @return array + */ + public function toArray(): array + { + return [ + 'gameId' => (string) $this->game->id(), + 'createdAt' => $this->game->createdAt()->format(\DateTimeImmutable::ATOM) + ]; + } + + /** + * Get event name + * + * @return string + */ + public function name(): string + { + return GameCreated::class; + } +} diff --git a/src/TicTacToe/Domain/Game/Game.php b/src/TicTacToe/Domain/Game/Game.php index d8a6b04..f7f632d 100644 --- a/src/TicTacToe/Domain/Game/Game.php +++ b/src/TicTacToe/Domain/Game/Game.php @@ -5,11 +5,13 @@ namespace TicTacToe\Domain\Game; use TicTacToe\Domain\Board\Board; +use TicTacToe\Domain\Game\Event\GameCreated; use TicTacToe\Domain\Game\Exception\SorryTooManyPlayers; use TicTacToe\Domain\Player\Player; use TicTacToe\Domain\Player\PlayerSet; +use TicTacToe\Domain\Shared\AggregateRoot; -final class Game +final class Game extends AggregateRoot { /** @var GameId */ private $id; @@ -20,9 +22,12 @@ final class Game /** @var Board */ private $board; + /** @var \DateTimeImmutable */ + private $createdAt; + public const MAX_PLAYERS = 2; - public function __construct(GameId $gameId, Board $board, Player ...$players) + private function __construct(GameId $gameId, Board $board, Player ...$players) { if (count($players) > self::MAX_PLAYERS) { throw new SorryTooManyPlayers("Only " . self::MAX_PLAYERS . " players allowed."); @@ -31,6 +36,18 @@ public function __construct(GameId $gameId, Board $board, Player ...$players) $this->id = $gameId; $this->board = $board; $this->players = new PlayerSet(...$players); + $this->createdAt = new \DateTimeImmutable(); + } + + public static function start(GameId $gameId, Board $board, Player ...$players) + { + $game = new self($gameId, $board, ...$players); + + $game->record( + new GameCreated($game) + ); + + return $game; } public function id(): GameId @@ -47,4 +64,9 @@ public function board(): Board { return $this->board; } + + public function createdAt(): \DateTimeImmutable + { + return $this->createdAt; + } } diff --git a/src/TicTacToe/Infrastructure/UI/Console/ConsoleOutput.php b/src/TicTacToe/Presentation/Console/ConsoleOutput.php similarity index 88% rename from src/TicTacToe/Infrastructure/UI/Console/ConsoleOutput.php rename to src/TicTacToe/Presentation/Console/ConsoleOutput.php index 847d481..85f66cd 100644 --- a/src/TicTacToe/Infrastructure/UI/Console/ConsoleOutput.php +++ b/src/TicTacToe/Presentation/Console/ConsoleOutput.php @@ -2,9 +2,9 @@ declare(strict_types = 1); -namespace TicTacToe\Infrastructure\UI\Console; +namespace TicTacToe\Presentation\Console; -use TicTacToe\Infrastructure\UI\Output; +use TicTacToe\Presentation\Output; final class ConsoleOutput implements Output { diff --git a/src/TicTacToe/Infrastructure/UI/Output.php b/src/TicTacToe/Presentation/Output.php similarity index 85% rename from src/TicTacToe/Infrastructure/UI/Output.php rename to src/TicTacToe/Presentation/Output.php index 7f12a02..3e82f21 100644 --- a/src/TicTacToe/Infrastructure/UI/Output.php +++ b/src/TicTacToe/Presentation/Output.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Infrastructure\UI; +namespace TicTacToe\Presentation; interface Output { From bd7f0d4765e4ef3cfde7bfeca9af3c0fee0c2f37 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 12 Jun 2019 11:24:50 +0200 Subject: [PATCH 33/75] green game tests --- tests/unit/Domain/Game/GameTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/Domain/Game/GameTest.php b/tests/unit/Domain/Game/GameTest.php index 5133c8b..966d6ff 100644 --- a/tests/unit/Domain/Game/GameTest.php +++ b/tests/unit/Domain/Game/GameTest.php @@ -15,7 +15,7 @@ public function testItCreatesGameSuccessfully() { $gameId = new GameId(); $players = $this->createPlayers(2); - $game = new Game($gameId, Board::create3By3Board(), ...$players); + $game = Game::start($gameId, Board::create3By3Board(), ...$players); self::assertEquals(2, $game->players()->count()); self::assertInstanceOf(GameId::class, $game->id()); @@ -27,7 +27,7 @@ public function testItThrowsTooManyPlayersWhenMorePlayersCreated() $gameId = new GameId(); $players = $this->createPlayers(3); self::expectException(SorryTooManyPlayers::class); - new Game($gameId, Board::create3By3Board(), ...$players); + Game::start($gameId, Board::create3By3Board(), ...$players); } public function randomizeString(int $length) From dd35b1880a75dcca13f173389d94c01f660c4179 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 12 Jun 2019 15:02:16 +0200 Subject: [PATCH 34/75] adding CreatePlayerCommand and Handler. --- .../Player/CreatePlayerCommand.php | 30 +++++++++++++++++++ .../Player/CreatePlayerHandler.php | 28 +++++++++++++++++ src/TicTacToe/Domain/Player/Player.php | 15 ++++++++++ 3 files changed, 73 insertions(+) create mode 100644 src/TicTacToe/Application/Player/CreatePlayerCommand.php create mode 100644 src/TicTacToe/Application/Player/CreatePlayerHandler.php diff --git a/src/TicTacToe/Application/Player/CreatePlayerCommand.php b/src/TicTacToe/Application/Player/CreatePlayerCommand.php new file mode 100644 index 0000000..d6a6c24 --- /dev/null +++ b/src/TicTacToe/Application/Player/CreatePlayerCommand.php @@ -0,0 +1,30 @@ +name = $name; + $this->token = $token; + } + + public function name(): string + { + return $this->name; + } + + public function token(): string + { + return $this->token; + } +} diff --git a/src/TicTacToe/Application/Player/CreatePlayerHandler.php b/src/TicTacToe/Application/Player/CreatePlayerHandler.php new file mode 100644 index 0000000..5ea6903 --- /dev/null +++ b/src/TicTacToe/Application/Player/CreatePlayerHandler.php @@ -0,0 +1,28 @@ +playerRepository = $playerRepository; + } + + public function __invoke(CreatePlayerCommand $command) + { + $player = Player::createPlayerWithToken($command->name(), $command->token()); + + $this->playerRepository->add($player); + + return $player; + } +} diff --git a/src/TicTacToe/Domain/Player/Player.php b/src/TicTacToe/Domain/Player/Player.php index 88f157e..c831564 100644 --- a/src/TicTacToe/Domain/Player/Player.php +++ b/src/TicTacToe/Domain/Player/Player.php @@ -59,6 +59,21 @@ public static function createPlayerWithTokenY(string $name): Player return $player; } + public static function createPlayerWithToken(string $name, string $token): Player + { + $player = new self( + new PlayerId(), + new PlayerName($name), + new PlayerToken($token) + ); + + $player->record( + new PlayerCreated($player) + ); + + return $player; + } + public function name(): string { return (string) $this->name; From a291898414d99c154259c7a21b613dfcbc268aab Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 12 Jun 2019 22:28:33 +0200 Subject: [PATCH 35/75] adding EventStore. --- src/TicTacToe/Domain/Shared/EventStore.php | 10 ++++++++++ .../InMemory/InMemoryEventStore.php | 18 ++++++++++++++++++ .../InMemoryPlayerRepository.php | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/TicTacToe/Domain/Shared/EventStore.php create mode 100644 src/TicTacToe/Infrastructure/InMemory/InMemoryEventStore.php rename src/TicTacToe/Infrastructure/{Repository => InMemory}/InMemoryPlayerRepository.php (94%) diff --git a/src/TicTacToe/Domain/Shared/EventStore.php b/src/TicTacToe/Domain/Shared/EventStore.php new file mode 100644 index 0000000..1ba786f --- /dev/null +++ b/src/TicTacToe/Domain/Shared/EventStore.php @@ -0,0 +1,10 @@ +events[] = unserialize(serialize($event)); + } +} diff --git a/src/TicTacToe/Infrastructure/Repository/InMemoryPlayerRepository.php b/src/TicTacToe/Infrastructure/InMemory/InMemoryPlayerRepository.php similarity index 94% rename from src/TicTacToe/Infrastructure/Repository/InMemoryPlayerRepository.php rename to src/TicTacToe/Infrastructure/InMemory/InMemoryPlayerRepository.php index d9020de..fb62df7 100644 --- a/src/TicTacToe/Infrastructure/Repository/InMemoryPlayerRepository.php +++ b/src/TicTacToe/Infrastructure/InMemory/InMemoryPlayerRepository.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Infrastructure\Repository; +namespace TicTacToe\Infrastructure\InMemory; use TicTacToe\Domain\Player\Player; use TicTacToe\Domain\Player\PlayerId; From 280912218886b523c92f676a46532826ac16d59e Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 12 Jun 2019 23:13:25 +0200 Subject: [PATCH 36/75] Add CommandBus. --- .../Player/CreatePlayerCommand.php | 4 +++- .../Player/CreatePlayerHandler.php | 11 +++++++++- src/TicTacToe/Domain/Shared/Command.php | 9 +++++++++ src/TicTacToe/Domain/Shared/CommandBus.php | 20 +++++++++++++++++++ .../Domain/Shared/CommandHandler.php | 15 ++++++++++++++ .../Domain/Shared/DataTransformer.php | 13 ++++++++++++ 6 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 src/TicTacToe/Domain/Shared/Command.php create mode 100644 src/TicTacToe/Domain/Shared/CommandBus.php create mode 100644 src/TicTacToe/Domain/Shared/CommandHandler.php create mode 100644 src/TicTacToe/Domain/Shared/DataTransformer.php diff --git a/src/TicTacToe/Application/Player/CreatePlayerCommand.php b/src/TicTacToe/Application/Player/CreatePlayerCommand.php index d6a6c24..2294c27 100644 --- a/src/TicTacToe/Application/Player/CreatePlayerCommand.php +++ b/src/TicTacToe/Application/Player/CreatePlayerCommand.php @@ -4,7 +4,9 @@ namespace TicTacToe\Application\Player; -final class CreatePlayerCommand +use TicTacToe\Domain\Shared\Command; + +final class CreatePlayerCommand implements Command { /** @var string */ private $name; diff --git a/src/TicTacToe/Application/Player/CreatePlayerHandler.php b/src/TicTacToe/Application/Player/CreatePlayerHandler.php index 5ea6903..b367062 100644 --- a/src/TicTacToe/Application/Player/CreatePlayerHandler.php +++ b/src/TicTacToe/Application/Player/CreatePlayerHandler.php @@ -6,8 +6,9 @@ use TicTacToe\Domain\Player\Player; use TicTacToe\Domain\Player\PlayerRepository; +use TicTacToe\Domain\Shared\CommandHandler; -final class CreatePlayerHandler +final class CreatePlayerHandler implements CommandHandler { /** @var PlayerRepository */ private $playerRepository; @@ -25,4 +26,12 @@ public function __invoke(CreatePlayerCommand $command) return $player; } + + /** + * @inheritDoc + */ + public function handles(): string + { + return CreatePlayerCommand::class; + } } diff --git a/src/TicTacToe/Domain/Shared/Command.php b/src/TicTacToe/Domain/Shared/Command.php new file mode 100644 index 0000000..891b6ce --- /dev/null +++ b/src/TicTacToe/Domain/Shared/Command.php @@ -0,0 +1,9 @@ + Date: Wed, 12 Jun 2019 23:43:58 +0200 Subject: [PATCH 37/75] red tests after folder restructure. --- .../Application/Player/CreatePlayerCommand.php | 2 +- .../Application/Player/CreatePlayerHandler.php | 0 .../Domain/Model}/Board/Board.php | 4 ++-- .../Domain/Model}/Board/Cell.php | 4 ++-- .../Board/Exception/SorryBoardSizeIsNotValid.php | 2 +- .../Domain/Model}/Game/Event/GameCreated.php | 2 +- .../Game/Exception/SorryTooManyPlayers.php | 2 +- .../Domain/Model}/Game/Game.php | 16 ++++++++-------- .../Domain/Model}/Game/GameId.php | 2 +- .../Domain/Model}/Player/Event/PlayerCreated.php | 6 +++--- .../Player/Exception/SorryInvalidPlayerToken.php | 2 +- .../Exception/SorryPlayerNameIsTooLong.php | 2 +- .../Exception/SorryPlayerNameIsTooShort.php | 2 +- .../Domain/Model}/Player/Player.php | 6 +++--- .../Domain/Model}/Player/PlayerId.php | 2 +- .../Domain/Model}/Player/PlayerName.php | 6 +++--- .../Domain/Model}/Player/PlayerRepository.php | 2 +- .../Domain/Model}/Player/PlayerSet.php | 2 +- .../Domain/Model}/Player/PlayerToken.php | 4 ++-- .../Persistence}/InMemory/InMemoryEventStore.php | 6 +++--- .../InMemory/InMemoryPlayerRepository.php | 8 ++++---- .../Presentation/Console/ConsoleOutput.php | 0 .../{ => Engine}/Presentation/Output.php | 0 .../Shared => Shared/Application}/Command.php | 2 +- .../Application}/CommandHandler.php | 2 +- .../Application}/DataTransformer.php | 2 +- .../Domain/Model}/AggregateRoot.php | 2 +- .../Shared => Shared/Domain/Model}/Event.php | 2 +- .../Infrastructure/CommandBus}/CommandBus.php | 2 +- .../Infrastructure}/EventStore.php | 4 +++- 30 files changed, 50 insertions(+), 48 deletions(-) rename src/TicTacToe/{ => Engine}/Application/Player/CreatePlayerCommand.php (91%) rename src/TicTacToe/{ => Engine}/Application/Player/CreatePlayerHandler.php (100%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Board/Board.php (89%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Board/Cell.php (81%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Board/Exception/SorryBoardSizeIsNotValid.php (64%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Game/Event/GameCreated.php (95%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Game/Exception/SorryTooManyPlayers.php (63%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Game/Game.php (79%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Game/GameId.php (91%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Player/Event/PlayerCreated.php (86%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Player/Exception/SorryInvalidPlayerToken.php (63%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Player/Exception/SorryPlayerNameIsTooLong.php (63%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Player/Exception/SorryPlayerNameIsTooShort.php (64%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Player/Player.php (92%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Player/PlayerId.php (91%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Player/PlayerName.php (78%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Player/PlayerRepository.php (92%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Player/PlayerSet.php (94%) rename src/TicTacToe/{Domain => Engine/Domain/Model}/Player/PlayerToken.php (88%) rename src/TicTacToe/{Infrastructure => Engine/Infrastructure/Persistence}/InMemory/InMemoryEventStore.php (61%) rename src/TicTacToe/{Infrastructure => Engine/Infrastructure/Persistence}/InMemory/InMemoryPlayerRepository.php (77%) rename src/TicTacToe/{ => Engine}/Presentation/Console/ConsoleOutput.php (100%) rename src/TicTacToe/{ => Engine}/Presentation/Output.php (100%) rename src/TicTacToe/{Domain/Shared => Shared/Application}/Command.php (59%) rename src/TicTacToe/{Domain/Shared => Shared/Application}/CommandHandler.php (81%) rename src/TicTacToe/{Domain/Shared => Shared/Application}/DataTransformer.php (77%) rename src/TicTacToe/{Domain/Shared => Shared/Domain/Model}/AggregateRoot.php (90%) rename src/TicTacToe/{Domain/Shared => Shared/Domain/Model}/Event.php (91%) rename src/TicTacToe/{Domain/Shared => Shared/Infrastructure/CommandBus}/CommandBus.php (87%) rename src/TicTacToe/{Domain/Shared => Shared/Infrastructure}/EventStore.php (54%) diff --git a/src/TicTacToe/Application/Player/CreatePlayerCommand.php b/src/TicTacToe/Engine/Application/Player/CreatePlayerCommand.php similarity index 91% rename from src/TicTacToe/Application/Player/CreatePlayerCommand.php rename to src/TicTacToe/Engine/Application/Player/CreatePlayerCommand.php index 2294c27..b519291 100644 --- a/src/TicTacToe/Application/Player/CreatePlayerCommand.php +++ b/src/TicTacToe/Engine/Application/Player/CreatePlayerCommand.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Application\Player; +namespace TicTacToe\Engine\Application\Player; use TicTacToe\Domain\Shared\Command; diff --git a/src/TicTacToe/Application/Player/CreatePlayerHandler.php b/src/TicTacToe/Engine/Application/Player/CreatePlayerHandler.php similarity index 100% rename from src/TicTacToe/Application/Player/CreatePlayerHandler.php rename to src/TicTacToe/Engine/Application/Player/CreatePlayerHandler.php diff --git a/src/TicTacToe/Domain/Board/Board.php b/src/TicTacToe/Engine/Domain/Model/Board/Board.php similarity index 89% rename from src/TicTacToe/Domain/Board/Board.php rename to src/TicTacToe/Engine/Domain/Model/Board/Board.php index 882718f..850dd62 100644 --- a/src/TicTacToe/Domain/Board/Board.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Board.php @@ -2,9 +2,9 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Board; +namespace TicTacToe\Domain\Model\Board; -use TicTacToe\Domain\Board\Exception\SorryBoardSizeIsNotValid; +use TicTacToe\Domain\Model\Board\Exception\SorryBoardSizeIsNotValid; final class Board { diff --git a/src/TicTacToe/Domain/Board/Cell.php b/src/TicTacToe/Engine/Domain/Model/Board/Cell.php similarity index 81% rename from src/TicTacToe/Domain/Board/Cell.php rename to src/TicTacToe/Engine/Domain/Model/Board/Cell.php index a2bf982..6542e84 100644 --- a/src/TicTacToe/Domain/Board/Cell.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Cell.php @@ -2,9 +2,9 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Board; +namespace TicTacToe\Domain\Model\Board; -use TicTacToe\Domain\Player\PlayerToken; +use TicTacToe\Domain\Model\Player\PlayerToken; final class Cell { diff --git a/src/TicTacToe/Domain/Board/Exception/SorryBoardSizeIsNotValid.php b/src/TicTacToe/Engine/Domain/Model/Board/Exception/SorryBoardSizeIsNotValid.php similarity index 64% rename from src/TicTacToe/Domain/Board/Exception/SorryBoardSizeIsNotValid.php rename to src/TicTacToe/Engine/Domain/Model/Board/Exception/SorryBoardSizeIsNotValid.php index 965b971..654aa38 100644 --- a/src/TicTacToe/Domain/Board/Exception/SorryBoardSizeIsNotValid.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Exception/SorryBoardSizeIsNotValid.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Board\Exception; +namespace TicTacToe\Domain\Model\Board\Exception; class SorryBoardSizeIsNotValid extends \Exception { diff --git a/src/TicTacToe/Domain/Game/Event/GameCreated.php b/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php similarity index 95% rename from src/TicTacToe/Domain/Game/Event/GameCreated.php rename to src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php index 51e6f27..e96648c 100644 --- a/src/TicTacToe/Domain/Game/Event/GameCreated.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Game\Event; +namespace TicTacToe\Domain\Model\Game\Event; use TicTacToe\Domain\Game\Game; use TicTacToe\Domain\Shared\Event; diff --git a/src/TicTacToe/Domain/Game/Exception/SorryTooManyPlayers.php b/src/TicTacToe/Engine/Domain/Model/Game/Exception/SorryTooManyPlayers.php similarity index 63% rename from src/TicTacToe/Domain/Game/Exception/SorryTooManyPlayers.php rename to src/TicTacToe/Engine/Domain/Model/Game/Exception/SorryTooManyPlayers.php index a4d1bb6..c1d3ea8 100644 --- a/src/TicTacToe/Domain/Game/Exception/SorryTooManyPlayers.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Exception/SorryTooManyPlayers.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Game\Exception; +namespace TicTacToe\Domain\Model\Game\Exception; class SorryTooManyPlayers extends \Exception { diff --git a/src/TicTacToe/Domain/Game/Game.php b/src/TicTacToe/Engine/Domain/Model/Game/Game.php similarity index 79% rename from src/TicTacToe/Domain/Game/Game.php rename to src/TicTacToe/Engine/Domain/Model/Game/Game.php index f7f632d..9e77106 100644 --- a/src/TicTacToe/Domain/Game/Game.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Game.php @@ -2,14 +2,14 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Game; - -use TicTacToe\Domain\Board\Board; -use TicTacToe\Domain\Game\Event\GameCreated; -use TicTacToe\Domain\Game\Exception\SorryTooManyPlayers; -use TicTacToe\Domain\Player\Player; -use TicTacToe\Domain\Player\PlayerSet; -use TicTacToe\Domain\Shared\AggregateRoot; +namespace TicTacToe\Domain\Model\Game; + +use TicTacToe\Domain\Model\Board\Board; +use TicTacToe\Domain\Model\Game\Event\GameCreated; +use TicTacToe\Domain\Model\Game\Exception\SorryTooManyPlayers; +use TicTacToe\Domain\Model\Player\Player; +use TicTacToe\Domain\Model\Player\PlayerSet; +use TicTacToe\Shared\Domain\Model\AggregateRoot; final class Game extends AggregateRoot { diff --git a/src/TicTacToe/Domain/Game/GameId.php b/src/TicTacToe/Engine/Domain/Model/Game/GameId.php similarity index 91% rename from src/TicTacToe/Domain/Game/GameId.php rename to src/TicTacToe/Engine/Domain/Model/Game/GameId.php index 02fd5e0..300dc92 100644 --- a/src/TicTacToe/Domain/Game/GameId.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/GameId.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Game; +namespace TicTacToe\Domain\Model\Game; use Ramsey\Uuid\Uuid; diff --git a/src/TicTacToe/Domain/Player/Event/PlayerCreated.php b/src/TicTacToe/Engine/Domain/Model/Player/Event/PlayerCreated.php similarity index 86% rename from src/TicTacToe/Domain/Player/Event/PlayerCreated.php rename to src/TicTacToe/Engine/Domain/Model/Player/Event/PlayerCreated.php index b291021..c384b41 100644 --- a/src/TicTacToe/Domain/Player/Event/PlayerCreated.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/Event/PlayerCreated.php @@ -2,10 +2,10 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Player\Event; +namespace TicTacToe\Domain\Model\Player\Event; -use TicTacToe\Domain\Player\Player; -use TicTacToe\Domain\Shared\Event; +use TicTacToe\Domain\Model\Player\Player; +use TicTacToe\Shared\Infrastructure\Event; final class PlayerCreated implements Event { diff --git a/src/TicTacToe/Domain/Player/Exception/SorryInvalidPlayerToken.php b/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryInvalidPlayerToken.php similarity index 63% rename from src/TicTacToe/Domain/Player/Exception/SorryInvalidPlayerToken.php rename to src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryInvalidPlayerToken.php index 97bd5ed..9b4a439 100644 --- a/src/TicTacToe/Domain/Player/Exception/SorryInvalidPlayerToken.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryInvalidPlayerToken.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Player\Exception; +namespace TicTacToe\Domain\Model\Player\Exception; class SorryInvalidPlayerToken extends \Exception { diff --git a/src/TicTacToe/Domain/Player/Exception/SorryPlayerNameIsTooLong.php b/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooLong.php similarity index 63% rename from src/TicTacToe/Domain/Player/Exception/SorryPlayerNameIsTooLong.php rename to src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooLong.php index 08b685d..9a0e0b8 100644 --- a/src/TicTacToe/Domain/Player/Exception/SorryPlayerNameIsTooLong.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooLong.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Player\Exception; +namespace TicTacToe\Domain\Model\Player\Exception; class SorryPlayerNameIsTooLong extends \Exception { diff --git a/src/TicTacToe/Domain/Player/Exception/SorryPlayerNameIsTooShort.php b/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooShort.php similarity index 64% rename from src/TicTacToe/Domain/Player/Exception/SorryPlayerNameIsTooShort.php rename to src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooShort.php index 46e993f..09e9a62 100644 --- a/src/TicTacToe/Domain/Player/Exception/SorryPlayerNameIsTooShort.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooShort.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Player\Exception; +namespace TicTacToe\Domain\Model\Player\Exception; class SorryPlayerNameIsTooShort extends \Exception { diff --git a/src/TicTacToe/Domain/Player/Player.php b/src/TicTacToe/Engine/Domain/Model/Player/Player.php similarity index 92% rename from src/TicTacToe/Domain/Player/Player.php rename to src/TicTacToe/Engine/Domain/Model/Player/Player.php index c831564..d2e8f19 100644 --- a/src/TicTacToe/Domain/Player/Player.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/Player.php @@ -2,10 +2,10 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Player; +namespace TicTacToe\Domain\Model\Player; -use TicTacToe\Domain\Player\Event\PlayerCreated; -use TicTacToe\Domain\Shared\AggregateRoot; +use TicTacToe\Domain\Model\Player\Event\PlayerCreated; +use TicTacToe\Shared\Domain\Model\AggregateRoot; final class Player extends AggregateRoot { diff --git a/src/TicTacToe/Domain/Player/PlayerId.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerId.php similarity index 91% rename from src/TicTacToe/Domain/Player/PlayerId.php rename to src/TicTacToe/Engine/Domain/Model/Player/PlayerId.php index 3c6555d..fb0da51 100644 --- a/src/TicTacToe/Domain/Player/PlayerId.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerId.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Player; +namespace TicTacToe\Domain\Model\Player; use Ramsey\Uuid\Uuid; diff --git a/src/TicTacToe/Domain/Player/PlayerName.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerName.php similarity index 78% rename from src/TicTacToe/Domain/Player/PlayerName.php rename to src/TicTacToe/Engine/Domain/Model/Player/PlayerName.php index 961d3f1..08a848e 100644 --- a/src/TicTacToe/Domain/Player/PlayerName.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerName.php @@ -2,10 +2,10 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Player; +namespace TicTacToe\Domain\Model\Player; -use TicTacToe\Domain\Player\Exception\SorryPlayerNameIsTooLong; -use TicTacToe\Domain\Player\Exception\SorryPlayerNameIsTooShort; +use TicTacToe\Domain\Model\Player\Exception\SorryPlayerNameIsTooLong; +use TicTacToe\Domain\Model\Player\Exception\SorryPlayerNameIsTooShort; final class PlayerName { diff --git a/src/TicTacToe/Domain/Player/PlayerRepository.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerRepository.php similarity index 92% rename from src/TicTacToe/Domain/Player/PlayerRepository.php rename to src/TicTacToe/Engine/Domain/Model/Player/PlayerRepository.php index 2a6b217..1a63ebe 100644 --- a/src/TicTacToe/Domain/Player/PlayerRepository.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerRepository.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Player; +namespace TicTacToe\Domain\Model\Player; interface PlayerRepository { diff --git a/src/TicTacToe/Domain/Player/PlayerSet.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerSet.php similarity index 94% rename from src/TicTacToe/Domain/Player/PlayerSet.php rename to src/TicTacToe/Engine/Domain/Model/Player/PlayerSet.php index 633b963..d98fe8a 100644 --- a/src/TicTacToe/Domain/Player/PlayerSet.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerSet.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Player; +namespace TicTacToe\Domain\Model\Player; use Traversable; diff --git a/src/TicTacToe/Domain/Player/PlayerToken.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerToken.php similarity index 88% rename from src/TicTacToe/Domain/Player/PlayerToken.php rename to src/TicTacToe/Engine/Domain/Model/Player/PlayerToken.php index 076a038..7a44cc8 100644 --- a/src/TicTacToe/Domain/Player/PlayerToken.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerToken.php @@ -2,9 +2,9 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Player; +namespace TicTacToe\Domain\Model\Player; -use TicTacToe\Domain\Player\Exception\SorryInvalidPlayerToken; +use TicTacToe\Domain\Model\Player\Exception\SorryInvalidPlayerToken; final class PlayerToken { diff --git a/src/TicTacToe/Infrastructure/InMemory/InMemoryEventStore.php b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryEventStore.php similarity index 61% rename from src/TicTacToe/Infrastructure/InMemory/InMemoryEventStore.php rename to src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryEventStore.php index 1ac408c..522a06f 100644 --- a/src/TicTacToe/Infrastructure/InMemory/InMemoryEventStore.php +++ b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryEventStore.php @@ -2,10 +2,10 @@ declare(strict_types = 1); -namespace TicTacToe\Infrastructure\InMemory; +namespace TicTacToe\Infrastructure\Persistence\InMemory; -use TicTacToe\Domain\Shared\Event; -use TicTacToe\Domain\Shared\EventStore; +use TicTacToe\Shared\Domain\Model\Event; +use TicTacToe\Shared\Infrastructure\EventStore; final class InMemoryEventStore implements EventStore { diff --git a/src/TicTacToe/Infrastructure/InMemory/InMemoryPlayerRepository.php b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php similarity index 77% rename from src/TicTacToe/Infrastructure/InMemory/InMemoryPlayerRepository.php rename to src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php index fb62df7..4426399 100644 --- a/src/TicTacToe/Infrastructure/InMemory/InMemoryPlayerRepository.php +++ b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php @@ -2,11 +2,11 @@ declare(strict_types = 1); -namespace TicTacToe\Infrastructure\InMemory; +namespace TicTacToe\Infrastructure\Persistence\InMemory; -use TicTacToe\Domain\Player\Player; -use TicTacToe\Domain\Player\PlayerId; -use TicTacToe\Domain\Player\PlayerRepository; +use TicTacToe\Domain\Model\Player\Player; +use TicTacToe\Domain\Model\Player\PlayerId; +use TicTacToe\Domain\Model\Player\PlayerRepository; class InMemoryPlayerRepository implements PlayerRepository { diff --git a/src/TicTacToe/Presentation/Console/ConsoleOutput.php b/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php similarity index 100% rename from src/TicTacToe/Presentation/Console/ConsoleOutput.php rename to src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php diff --git a/src/TicTacToe/Presentation/Output.php b/src/TicTacToe/Engine/Presentation/Output.php similarity index 100% rename from src/TicTacToe/Presentation/Output.php rename to src/TicTacToe/Engine/Presentation/Output.php diff --git a/src/TicTacToe/Domain/Shared/Command.php b/src/TicTacToe/Shared/Application/Command.php similarity index 59% rename from src/TicTacToe/Domain/Shared/Command.php rename to src/TicTacToe/Shared/Application/Command.php index 891b6ce..cb0d3ed 100644 --- a/src/TicTacToe/Domain/Shared/Command.php +++ b/src/TicTacToe/Shared/Application/Command.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Shared; +namespace TicTacToe\Shared\Application; interface Command { diff --git a/src/TicTacToe/Domain/Shared/CommandHandler.php b/src/TicTacToe/Shared/Application/CommandHandler.php similarity index 81% rename from src/TicTacToe/Domain/Shared/CommandHandler.php rename to src/TicTacToe/Shared/Application/CommandHandler.php index f7432b0..e16cceb 100644 --- a/src/TicTacToe/Domain/Shared/CommandHandler.php +++ b/src/TicTacToe/Shared/Application/CommandHandler.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Shared; +namespace TicTacToe\Shared\Application; interface CommandHandler { diff --git a/src/TicTacToe/Domain/Shared/DataTransformer.php b/src/TicTacToe/Shared/Application/DataTransformer.php similarity index 77% rename from src/TicTacToe/Domain/Shared/DataTransformer.php rename to src/TicTacToe/Shared/Application/DataTransformer.php index 8fd8d54..1278ce8 100644 --- a/src/TicTacToe/Domain/Shared/DataTransformer.php +++ b/src/TicTacToe/Shared/Application/DataTransformer.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Shared; +namespace TicTacToe\Shared\Application; interface DataTransformer { diff --git a/src/TicTacToe/Domain/Shared/AggregateRoot.php b/src/TicTacToe/Shared/Domain/Model/AggregateRoot.php similarity index 90% rename from src/TicTacToe/Domain/Shared/AggregateRoot.php rename to src/TicTacToe/Shared/Domain/Model/AggregateRoot.php index c9f4683..5932aa5 100644 --- a/src/TicTacToe/Domain/Shared/AggregateRoot.php +++ b/src/TicTacToe/Shared/Domain/Model/AggregateRoot.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Shared; +namespace TicTacToe\Shared\Domain\Model; abstract class AggregateRoot { diff --git a/src/TicTacToe/Domain/Shared/Event.php b/src/TicTacToe/Shared/Domain/Model/Event.php similarity index 91% rename from src/TicTacToe/Domain/Shared/Event.php rename to src/TicTacToe/Shared/Domain/Model/Event.php index 716e9a8..a80f9da 100644 --- a/src/TicTacToe/Domain/Shared/Event.php +++ b/src/TicTacToe/Shared/Domain/Model/Event.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Shared; +namespace TicTacToe\Shared\Domain\Model; interface Event { diff --git a/src/TicTacToe/Domain/Shared/CommandBus.php b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBus.php similarity index 87% rename from src/TicTacToe/Domain/Shared/CommandBus.php rename to src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBus.php index c28ee6e..ad194fe 100644 --- a/src/TicTacToe/Domain/Shared/CommandBus.php +++ b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBus.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Shared; +namespace TicTacToe\Shared\Infrastructure\CommandBus; interface CommandBus { diff --git a/src/TicTacToe/Domain/Shared/EventStore.php b/src/TicTacToe/Shared/Infrastructure/EventStore.php similarity index 54% rename from src/TicTacToe/Domain/Shared/EventStore.php rename to src/TicTacToe/Shared/Infrastructure/EventStore.php index 1ba786f..857d330 100644 --- a/src/TicTacToe/Domain/Shared/EventStore.php +++ b/src/TicTacToe/Shared/Infrastructure/EventStore.php @@ -2,7 +2,9 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Shared; +namespace TicTacToe\Shared\Infrastructure; + +use TicTacToe\Shared\Domain\Model\Event; interface EventStore { From 3b4095580e149379d48d6b0ba1b8efd84d201f26 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 12 Jun 2019 23:52:48 +0200 Subject: [PATCH 38/75] green board tests --- phpunit.xml | 1 - src/TicTacToe/Engine/Domain/Model/Board/Board.php | 4 ++-- src/TicTacToe/Engine/Domain/Model/Board/Cell.php | 2 +- .../Domain/Model/Board/Exception/SorryBoardSizeIsNotValid.php | 2 +- .../unit/{Domain => Engine/Domain/Model}/Board/BoardTest.php | 4 ++-- tests/unit/{Domain => Engine/Domain/Model}/Board/CellTest.php | 0 .../unit/{Domain => Engine/Domain/Model}/Game/GameIdTest.php | 0 tests/unit/{Domain => Engine/Domain/Model}/Game/GameTest.php | 0 .../Domain/Model}/Player/Event/PlayerCreatedTest.php | 0 .../{Domain => Engine/Domain/Model}/Player/PlayerIdTest.php | 0 .../{Domain => Engine/Domain/Model}/Player/PlayerNameTest.php | 0 .../{Domain => Engine/Domain/Model}/Player/PlayerTest.php | 0 .../Domain/Model}/Player/PlayerTokenTest.php | 0 13 files changed, 6 insertions(+), 7 deletions(-) rename tests/unit/{Domain => Engine/Domain/Model}/Board/BoardTest.php (77%) rename tests/unit/{Domain => Engine/Domain/Model}/Board/CellTest.php (100%) rename tests/unit/{Domain => Engine/Domain/Model}/Game/GameIdTest.php (100%) rename tests/unit/{Domain => Engine/Domain/Model}/Game/GameTest.php (100%) rename tests/unit/{Domain => Engine/Domain/Model}/Player/Event/PlayerCreatedTest.php (100%) rename tests/unit/{Domain => Engine/Domain/Model}/Player/PlayerIdTest.php (100%) rename tests/unit/{Domain => Engine/Domain/Model}/Player/PlayerNameTest.php (100%) rename tests/unit/{Domain => Engine/Domain/Model}/Player/PlayerTest.php (100%) rename tests/unit/{Domain => Engine/Domain/Model}/Player/PlayerTokenTest.php (100%) diff --git a/phpunit.xml b/phpunit.xml index 844b241..a871f37 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -2,7 +2,6 @@ - ./src/TicTacToe/Test/ ./tests/ diff --git a/src/TicTacToe/Engine/Domain/Model/Board/Board.php b/src/TicTacToe/Engine/Domain/Model/Board/Board.php index 850dd62..1020e2d 100644 --- a/src/TicTacToe/Engine/Domain/Model/Board/Board.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Board.php @@ -2,9 +2,9 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Board; +namespace TicTacToe\Engine\Domain\Model\Board; -use TicTacToe\Domain\Model\Board\Exception\SorryBoardSizeIsNotValid; +use TicTacToe\Engine\Domain\Model\Board\Exception\SorryBoardSizeIsNotValid; final class Board { diff --git a/src/TicTacToe/Engine/Domain/Model/Board/Cell.php b/src/TicTacToe/Engine/Domain/Model/Board/Cell.php index 6542e84..0c5cd79 100644 --- a/src/TicTacToe/Engine/Domain/Model/Board/Cell.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Cell.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Board; +namespace TicTacToe\Engine\Domain\Model\Board; use TicTacToe\Domain\Model\Player\PlayerToken; diff --git a/src/TicTacToe/Engine/Domain/Model/Board/Exception/SorryBoardSizeIsNotValid.php b/src/TicTacToe/Engine/Domain/Model/Board/Exception/SorryBoardSizeIsNotValid.php index 654aa38..7effd9f 100644 --- a/src/TicTacToe/Engine/Domain/Model/Board/Exception/SorryBoardSizeIsNotValid.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Exception/SorryBoardSizeIsNotValid.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Board\Exception; +namespace TicTacToe\Engine\Domain\Model\Board\Exception; class SorryBoardSizeIsNotValid extends \Exception { diff --git a/tests/unit/Domain/Board/BoardTest.php b/tests/unit/Engine/Domain/Model/Board/BoardTest.php similarity index 77% rename from tests/unit/Domain/Board/BoardTest.php rename to tests/unit/Engine/Domain/Model/Board/BoardTest.php index bf49fbc..cbbf169 100644 --- a/tests/unit/Domain/Board/BoardTest.php +++ b/tests/unit/Engine/Domain/Model/Board/BoardTest.php @@ -3,8 +3,8 @@ declare(strict_types = 1); use PHPUnit\Framework\TestCase; -use TicTacToe\Domain\Board\Board; -use TicTacToe\Domain\Board\Exception\SorryBoardSizeIsNotValid; +use TicTacToe\Engine\Domain\Model\Board\Board; +use TicTacToe\Engine\Domain\Model\Board\Exception\SorryBoardSizeIsNotValid; class BoardTest extends TestCase { diff --git a/tests/unit/Domain/Board/CellTest.php b/tests/unit/Engine/Domain/Model/Board/CellTest.php similarity index 100% rename from tests/unit/Domain/Board/CellTest.php rename to tests/unit/Engine/Domain/Model/Board/CellTest.php diff --git a/tests/unit/Domain/Game/GameIdTest.php b/tests/unit/Engine/Domain/Model/Game/GameIdTest.php similarity index 100% rename from tests/unit/Domain/Game/GameIdTest.php rename to tests/unit/Engine/Domain/Model/Game/GameIdTest.php diff --git a/tests/unit/Domain/Game/GameTest.php b/tests/unit/Engine/Domain/Model/Game/GameTest.php similarity index 100% rename from tests/unit/Domain/Game/GameTest.php rename to tests/unit/Engine/Domain/Model/Game/GameTest.php diff --git a/tests/unit/Domain/Player/Event/PlayerCreatedTest.php b/tests/unit/Engine/Domain/Model/Player/Event/PlayerCreatedTest.php similarity index 100% rename from tests/unit/Domain/Player/Event/PlayerCreatedTest.php rename to tests/unit/Engine/Domain/Model/Player/Event/PlayerCreatedTest.php diff --git a/tests/unit/Domain/Player/PlayerIdTest.php b/tests/unit/Engine/Domain/Model/Player/PlayerIdTest.php similarity index 100% rename from tests/unit/Domain/Player/PlayerIdTest.php rename to tests/unit/Engine/Domain/Model/Player/PlayerIdTest.php diff --git a/tests/unit/Domain/Player/PlayerNameTest.php b/tests/unit/Engine/Domain/Model/Player/PlayerNameTest.php similarity index 100% rename from tests/unit/Domain/Player/PlayerNameTest.php rename to tests/unit/Engine/Domain/Model/Player/PlayerNameTest.php diff --git a/tests/unit/Domain/Player/PlayerTest.php b/tests/unit/Engine/Domain/Model/Player/PlayerTest.php similarity index 100% rename from tests/unit/Domain/Player/PlayerTest.php rename to tests/unit/Engine/Domain/Model/Player/PlayerTest.php diff --git a/tests/unit/Domain/Player/PlayerTokenTest.php b/tests/unit/Engine/Domain/Model/Player/PlayerTokenTest.php similarity index 100% rename from tests/unit/Domain/Player/PlayerTokenTest.php rename to tests/unit/Engine/Domain/Model/Player/PlayerTokenTest.php From 2dbf3b80dfebdbb0945957eb63cffc6edca1e8b2 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 00:00:30 +0200 Subject: [PATCH 39/75] green Game tests --- .../Engine/Domain/Model/Game/Event/GameCreated.php | 6 +++--- .../Model/Game/Exception/SorryTooManyPlayers.php | 2 +- src/TicTacToe/Engine/Domain/Model/Game/Game.php | 12 ++++++------ src/TicTacToe/Engine/Domain/Model/Game/GameId.php | 2 +- .../Domain/Model/Player/Event/PlayerCreated.php | 6 +++--- .../Player/Exception/SorryInvalidPlayerToken.php | 2 +- .../Player/Exception/SorryPlayerNameIsTooLong.php | 2 +- .../Player/Exception/SorryPlayerNameIsTooShort.php | 2 +- src/TicTacToe/Engine/Domain/Model/Player/Player.php | 4 ++-- .../Engine/Domain/Model/Player/PlayerId.php | 2 +- .../Engine/Domain/Model/Player/PlayerName.php | 6 +++--- .../Engine/Domain/Model/Player/PlayerRepository.php | 2 +- .../Engine/Domain/Model/Player/PlayerSet.php | 2 +- .../Engine/Domain/Model/Player/PlayerToken.php | 4 ++-- tests/unit/Engine/Domain/Model/Game/GameTest.php | 10 +++++----- 15 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php b/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php index e96648c..6cfa1e4 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php @@ -2,10 +2,10 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Game\Event; +namespace TicTacToe\Engine\Domain\Model\Game\Event; -use TicTacToe\Domain\Game\Game; -use TicTacToe\Domain\Shared\Event; +use TicTacToe\Engine\Domain\Model\Game\Game; +use TicTacToe\Shared\Domain\Model\Event; final class GameCreated implements Event { diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Exception/SorryTooManyPlayers.php b/src/TicTacToe/Engine/Domain/Model/Game/Exception/SorryTooManyPlayers.php index c1d3ea8..c99a866 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/Exception/SorryTooManyPlayers.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Exception/SorryTooManyPlayers.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Game\Exception; +namespace TicTacToe\Engine\Domain\Model\Game\Exception; class SorryTooManyPlayers extends \Exception { diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Game.php b/src/TicTacToe/Engine/Domain/Model/Game/Game.php index 9e77106..9a22053 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/Game.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Game.php @@ -2,13 +2,13 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Game; +namespace TicTacToe\Engine\Domain\Model\Game; -use TicTacToe\Domain\Model\Board\Board; -use TicTacToe\Domain\Model\Game\Event\GameCreated; -use TicTacToe\Domain\Model\Game\Exception\SorryTooManyPlayers; -use TicTacToe\Domain\Model\Player\Player; -use TicTacToe\Domain\Model\Player\PlayerSet; +use TicTacToe\Engine\Domain\Model\Board\Board; +use TicTacToe\Engine\Domain\Model\Game\Event\GameCreated; +use TicTacToe\Engine\Domain\Model\Game\Exception\SorryTooManyPlayers; +use TicTacToe\Engine\Domain\Model\Player\Player; +use TicTacToe\Engine\Domain\Model\Player\PlayerSet; use TicTacToe\Shared\Domain\Model\AggregateRoot; final class Game extends AggregateRoot diff --git a/src/TicTacToe/Engine/Domain/Model/Game/GameId.php b/src/TicTacToe/Engine/Domain/Model/Game/GameId.php index 300dc92..9dc3aee 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/GameId.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/GameId.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Game; +namespace TicTacToe\Engine\Domain\Model\Game; use Ramsey\Uuid\Uuid; diff --git a/src/TicTacToe/Engine/Domain/Model/Player/Event/PlayerCreated.php b/src/TicTacToe/Engine/Domain/Model/Player/Event/PlayerCreated.php index c384b41..b2b806a 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/Event/PlayerCreated.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/Event/PlayerCreated.php @@ -2,10 +2,10 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Player\Event; +namespace TicTacToe\Engine\Domain\Model\Player\Event; -use TicTacToe\Domain\Model\Player\Player; -use TicTacToe\Shared\Infrastructure\Event; +use TicTacToe\Engine\Domain\Model\Player\Player; +use TicTacToe\Shared\Domain\Model\Event; final class PlayerCreated implements Event { diff --git a/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryInvalidPlayerToken.php b/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryInvalidPlayerToken.php index 9b4a439..a4cc849 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryInvalidPlayerToken.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryInvalidPlayerToken.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Player\Exception; +namespace TicTacToe\Engine\Domain\Model\Player\Exception; class SorryInvalidPlayerToken extends \Exception { diff --git a/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooLong.php b/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooLong.php index 9a0e0b8..ff9333d 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooLong.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooLong.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Player\Exception; +namespace TicTacToe\Engine\Domain\Model\Player\Exception; class SorryPlayerNameIsTooLong extends \Exception { diff --git a/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooShort.php b/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooShort.php index 09e9a62..8c9337e 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooShort.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNameIsTooShort.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Player\Exception; +namespace TicTacToe\Engine\Domain\Model\Player\Exception; class SorryPlayerNameIsTooShort extends \Exception { diff --git a/src/TicTacToe/Engine/Domain/Model/Player/Player.php b/src/TicTacToe/Engine/Domain/Model/Player/Player.php index d2e8f19..144cc0a 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/Player.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/Player.php @@ -2,9 +2,9 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Player; +namespace TicTacToe\Engine\Domain\Model\Player; -use TicTacToe\Domain\Model\Player\Event\PlayerCreated; +use TicTacToe\Engine\Domain\Model\Player\Event\PlayerCreated; use TicTacToe\Shared\Domain\Model\AggregateRoot; final class Player extends AggregateRoot diff --git a/src/TicTacToe/Engine/Domain/Model/Player/PlayerId.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerId.php index fb0da51..1fb3e12 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/PlayerId.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerId.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Player; +namespace TicTacToe\Engine\Domain\Model\Player; use Ramsey\Uuid\Uuid; diff --git a/src/TicTacToe/Engine/Domain/Model/Player/PlayerName.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerName.php index 08a848e..98ab505 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/PlayerName.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerName.php @@ -2,10 +2,10 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Player; +namespace TicTacToe\Engine\Domain\Model\Player; -use TicTacToe\Domain\Model\Player\Exception\SorryPlayerNameIsTooLong; -use TicTacToe\Domain\Model\Player\Exception\SorryPlayerNameIsTooShort; +use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNameIsTooLong; +use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNameIsTooShort; final class PlayerName { diff --git a/src/TicTacToe/Engine/Domain/Model/Player/PlayerRepository.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerRepository.php index 1a63ebe..654c64f 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/PlayerRepository.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerRepository.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Player; +namespace TicTacToe\Engine\Domain\Model\Player; interface PlayerRepository { diff --git a/src/TicTacToe/Engine/Domain/Model/Player/PlayerSet.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerSet.php index d98fe8a..6e53635 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/PlayerSet.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerSet.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Player; +namespace TicTacToe\Engine\Domain\Model\Player; use Traversable; diff --git a/src/TicTacToe/Engine/Domain/Model/Player/PlayerToken.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerToken.php index 7a44cc8..c7cd151 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/PlayerToken.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerToken.php @@ -2,9 +2,9 @@ declare(strict_types = 1); -namespace TicTacToe\Domain\Model\Player; +namespace TicTacToe\Engine\Domain\Model\Player; -use TicTacToe\Domain\Model\Player\Exception\SorryInvalidPlayerToken; +use TicTacToe\Engine\Domain\Model\Player\Exception\SorryInvalidPlayerToken; final class PlayerToken { diff --git a/tests/unit/Engine/Domain/Model/Game/GameTest.php b/tests/unit/Engine/Domain/Model/Game/GameTest.php index 966d6ff..641e630 100644 --- a/tests/unit/Engine/Domain/Model/Game/GameTest.php +++ b/tests/unit/Engine/Domain/Model/Game/GameTest.php @@ -3,11 +3,11 @@ declare(strict_types = 1); use PHPUnit\Framework\TestCase; -use TicTacToe\Domain\Board\Board; -use TicTacToe\Domain\Game\Exception\SorryTooManyPlayers; -use TicTacToe\Domain\Game\Game; -use TicTacToe\Domain\Game\GameId; -use TicTacToe\Domain\Player\Player; +use TicTacToe\Engine\Domain\Model\Board\Board; +use TicTacToe\Engine\Domain\Model\Game\Exception\SorryTooManyPlayers; +use TicTacToe\Engine\Domain\Model\Game\Game; +use TicTacToe\Engine\Domain\Model\Game\GameId; +use TicTacToe\Engine\Domain\Model\Player\Player; class GameTest extends TestCase { From 3d4c6ff038c7136313e9bc2fdef63aaf38318e04 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 00:00:58 +0200 Subject: [PATCH 40/75] green GameId tests --- tests/unit/Engine/Domain/Model/Game/GameIdTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Engine/Domain/Model/Game/GameIdTest.php b/tests/unit/Engine/Domain/Model/Game/GameIdTest.php index 91bbe9d..2a31508 100644 --- a/tests/unit/Engine/Domain/Model/Game/GameIdTest.php +++ b/tests/unit/Engine/Domain/Model/Game/GameIdTest.php @@ -4,7 +4,7 @@ use PHPUnit\Framework\TestCase; use Ramsey\Uuid\Uuid; -use TicTacToe\Domain\Game\GameId; +use TicTacToe\Engine\Domain\Model\Game\GameId; class GameIdTest extends TestCase { From 7466f5f6c9ee6c3109a5b56b8fe316f78daedf2b Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 00:01:48 +0200 Subject: [PATCH 41/75] green PlayerCreated tests --- .../Engine/Domain/Model/Player/Event/PlayerCreatedTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unit/Engine/Domain/Model/Player/Event/PlayerCreatedTest.php b/tests/unit/Engine/Domain/Model/Player/Event/PlayerCreatedTest.php index f45e005..2b61fb3 100644 --- a/tests/unit/Engine/Domain/Model/Player/Event/PlayerCreatedTest.php +++ b/tests/unit/Engine/Domain/Model/Player/Event/PlayerCreatedTest.php @@ -2,10 +2,11 @@ declare(strict_types = 1); -use TicTacToe\Domain\Player\Event\PlayerCreated; -use TicTacToe\Domain\Player\Player; +use PHPUnit\Framework\TestCase; +use TicTacToe\Engine\Domain\Model\Player\Event\PlayerCreated; +use TicTacToe\Engine\Domain\Model\Player\Player; -class PlayerCreatedTest extends \PHPUnit\Framework\TestCase +class PlayerCreatedTest extends TestCase { public function testItExposesCorrectData() { From f247b4340f023f4ebc024f74538017e7ff8f6056 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 00:02:15 +0200 Subject: [PATCH 42/75] green PlayerIdTest tests --- tests/unit/Engine/Domain/Model/Player/PlayerIdTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Engine/Domain/Model/Player/PlayerIdTest.php b/tests/unit/Engine/Domain/Model/Player/PlayerIdTest.php index 0ed4966..c271c74 100644 --- a/tests/unit/Engine/Domain/Model/Player/PlayerIdTest.php +++ b/tests/unit/Engine/Domain/Model/Player/PlayerIdTest.php @@ -4,7 +4,7 @@ use PHPUnit\Framework\TestCase; use Ramsey\Uuid\Uuid; -use TicTacToe\Domain\Player\PlayerId; +use TicTacToe\Engine\Domain\Model\Player\PlayerId; class PlayerIdTest extends TestCase { From 53974c5c5f4ccf6867e4d980ed4c8411c77de39e Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 00:02:54 +0200 Subject: [PATCH 43/75] green PlayerNameTest tests --- tests/unit/Engine/Domain/Model/Player/PlayerNameTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/Engine/Domain/Model/Player/PlayerNameTest.php b/tests/unit/Engine/Domain/Model/Player/PlayerNameTest.php index 8e47ed2..21edee1 100644 --- a/tests/unit/Engine/Domain/Model/Player/PlayerNameTest.php +++ b/tests/unit/Engine/Domain/Model/Player/PlayerNameTest.php @@ -3,9 +3,9 @@ declare(strict_types = 1); use PHPUnit\Framework\TestCase; -use TicTacToe\Domain\Player\Exception\SorryPlayerNameIsTooShort; -use TicTacToe\Domain\Player\PlayerName; -use TicTacToe\Domain\Player\Exception\SorryPlayerNameIsTooLong; +use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNameIsTooShort; +use TicTacToe\Engine\Domain\Model\Player\PlayerName; +use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNameIsTooLong; class PlayerNameTest extends TestCase { From c7f675b3045ed6891584db232d8f4c39a2011519 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 00:03:32 +0200 Subject: [PATCH 44/75] green PlayerTest tests --- tests/unit/Engine/Domain/Model/Player/PlayerTest.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/unit/Engine/Domain/Model/Player/PlayerTest.php b/tests/unit/Engine/Domain/Model/Player/PlayerTest.php index 6589aa4..ef3bcfa 100644 --- a/tests/unit/Engine/Domain/Model/Player/PlayerTest.php +++ b/tests/unit/Engine/Domain/Model/Player/PlayerTest.php @@ -3,12 +3,10 @@ declare(strict_types = 1); use PHPUnit\Framework\TestCase; -use TicTacToe\Domain\Player\Exception\SorryPlayerNameIsTooLong; -use TicTacToe\Domain\Player\Exception\SorryPlayerNameIsTooShort; -use TicTacToe\Domain\Player\Player; -use TicTacToe\Domain\Player\PlayerId; -use TicTacToe\Domain\Player\PlayerName; -use TicTacToe\Domain\Player\PlayerToken; +use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNameIsTooLong; +use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNameIsTooShort; +use TicTacToe\Engine\Domain\Model\Player\Player; +use TicTacToe\Engine\Domain\Model\Player\PlayerId; class PlayerTest extends TestCase { From 977d093c2197ffe6dd660089f300fc2315e4d1d4 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 00:05:33 +0200 Subject: [PATCH 45/75] green PlayerTokenTest tests --- src/TicTacToe/Engine/Domain/Model/Board/Cell.php | 2 +- tests/unit/Engine/Domain/Model/Board/CellTest.php | 7 ++++--- tests/unit/Engine/Domain/Model/Player/PlayerTokenTest.php | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/TicTacToe/Engine/Domain/Model/Board/Cell.php b/src/TicTacToe/Engine/Domain/Model/Board/Cell.php index 0c5cd79..5d19423 100644 --- a/src/TicTacToe/Engine/Domain/Model/Board/Cell.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Cell.php @@ -4,7 +4,7 @@ namespace TicTacToe\Engine\Domain\Model\Board; -use TicTacToe\Domain\Model\Player\PlayerToken; +use TicTacToe\Engine\Domain\Model\Player\PlayerToken; final class Cell { diff --git a/tests/unit/Engine/Domain/Model/Board/CellTest.php b/tests/unit/Engine/Domain/Model/Board/CellTest.php index 951aa16..424afef 100644 --- a/tests/unit/Engine/Domain/Model/Board/CellTest.php +++ b/tests/unit/Engine/Domain/Model/Board/CellTest.php @@ -2,10 +2,11 @@ declare(strict_types = 1); -use TicTacToe\Domain\Board\Cell; -use TicTacToe\Domain\Player\PlayerToken; +use PHPUnit\Framework\TestCase; +use TicTacToe\Engine\Domain\Model\Board\Cell; +use TicTacToe\Engine\Domain\Model\Player\PlayerToken; -class CellTest extends \PHPUnit\Framework\TestCase +class CellTest extends TestCase { public function testCellCreatedSuccessfully() { diff --git a/tests/unit/Engine/Domain/Model/Player/PlayerTokenTest.php b/tests/unit/Engine/Domain/Model/Player/PlayerTokenTest.php index 38a6e0f..1e405fb 100644 --- a/tests/unit/Engine/Domain/Model/Player/PlayerTokenTest.php +++ b/tests/unit/Engine/Domain/Model/Player/PlayerTokenTest.php @@ -3,8 +3,8 @@ declare(strict_types = 1); use PHPUnit\Framework\TestCase; -use TicTacToe\Domain\Player\Exception\SorryInvalidPlayerToken; -use TicTacToe\Domain\Player\PlayerToken; +use TicTacToe\Engine\Domain\Model\Player\Exception\SorryInvalidPlayerToken; +use TicTacToe\Engine\Domain\Model\Player\PlayerToken; class PlayerTokenTest extends TestCase { From da4259334457fd02fda5eaec0202e1a7483518bf Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 01:01:46 +0200 Subject: [PATCH 46/75] fixes --- .../Engine/Application/Player/CreatePlayerCommand.php | 2 +- .../Engine/Application/Player/CreatePlayerHandler.php | 8 ++++---- .../Persistence/InMemory/InMemoryEventStore.php | 2 +- .../Persistence/InMemory/InMemoryPlayerRepository.php | 8 ++++---- .../Engine/Presentation/Console/ConsoleOutput.php | 4 ++-- src/TicTacToe/Engine/Presentation/Output.php | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/TicTacToe/Engine/Application/Player/CreatePlayerCommand.php b/src/TicTacToe/Engine/Application/Player/CreatePlayerCommand.php index b519291..76f06c3 100644 --- a/src/TicTacToe/Engine/Application/Player/CreatePlayerCommand.php +++ b/src/TicTacToe/Engine/Application/Player/CreatePlayerCommand.php @@ -4,7 +4,7 @@ namespace TicTacToe\Engine\Application\Player; -use TicTacToe\Domain\Shared\Command; +use TicTacToe\Shared\Application\Command; final class CreatePlayerCommand implements Command { diff --git a/src/TicTacToe/Engine/Application/Player/CreatePlayerHandler.php b/src/TicTacToe/Engine/Application/Player/CreatePlayerHandler.php index b367062..c1a7fea 100644 --- a/src/TicTacToe/Engine/Application/Player/CreatePlayerHandler.php +++ b/src/TicTacToe/Engine/Application/Player/CreatePlayerHandler.php @@ -2,11 +2,11 @@ declare(strict_types = 1); -namespace TicTacToe\Application\Player; +namespace TicTacToe\Engine\Application\Player; -use TicTacToe\Domain\Player\Player; -use TicTacToe\Domain\Player\PlayerRepository; -use TicTacToe\Domain\Shared\CommandHandler; +use TicTacToe\Engine\Domain\Model\Player\Player; +use TicTacToe\Engine\Domain\Model\Player\PlayerRepository; +use TicTacToe\Shared\Application\CommandHandler; final class CreatePlayerHandler implements CommandHandler { diff --git a/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryEventStore.php b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryEventStore.php index 522a06f..e667bf5 100644 --- a/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryEventStore.php +++ b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryEventStore.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Infrastructure\Persistence\InMemory; +namespace TicTacToe\Engine\Infrastructure\Persistence\InMemory; use TicTacToe\Shared\Domain\Model\Event; use TicTacToe\Shared\Infrastructure\EventStore; diff --git a/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php index 4426399..8f4c0e1 100644 --- a/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php +++ b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php @@ -2,11 +2,11 @@ declare(strict_types = 1); -namespace TicTacToe\Infrastructure\Persistence\InMemory; +namespace TicTacToe\Engine\Infrastructure\Persistence\InMemory; -use TicTacToe\Domain\Model\Player\Player; -use TicTacToe\Domain\Model\Player\PlayerId; -use TicTacToe\Domain\Model\Player\PlayerRepository; +use TicTacToe\Engine\Domain\Model\Player\Player; +use TicTacToe\Engine\Domain\Model\Player\PlayerId; +use TicTacToe\Engine\Domain\Model\Player\PlayerRepository; class InMemoryPlayerRepository implements PlayerRepository { diff --git a/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php b/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php index 85f66cd..82d7e3e 100644 --- a/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php +++ b/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php @@ -2,9 +2,9 @@ declare(strict_types = 1); -namespace TicTacToe\Presentation\Console; +namespace TicTacToe\Engine\Presentation\Console; -use TicTacToe\Presentation\Output; +use TicTacToe\Engine\Presentation\Output; final class ConsoleOutput implements Output { diff --git a/src/TicTacToe/Engine/Presentation/Output.php b/src/TicTacToe/Engine/Presentation/Output.php index 3e82f21..15a4d97 100644 --- a/src/TicTacToe/Engine/Presentation/Output.php +++ b/src/TicTacToe/Engine/Presentation/Output.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Presentation; +namespace TicTacToe\Engine\Presentation; interface Output { From 2991941aa63a96f5d2c3dde203a88211cfd380c7 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 01:34:39 +0200 Subject: [PATCH 47/75] CreatePlayer Dto, command and handler. --- .../CreatePlayerCommand.php | 2 +- .../CreatePlayer/CreatePlayerDto.php | 54 +++++++++++++++++++ .../CreatePlayerHandler.php | 23 ++++---- .../Shared/Application/CommandHandler.php | 6 +++ .../{CommandBus => }/CommandBus.php | 6 ++- .../CommandBus/CommandBusFactory.php | 47 ++++++++++++++++ .../Exception/SorryCommandHandlerNotFound.php | 17 ++++++ 7 files changed, 144 insertions(+), 11 deletions(-) rename src/TicTacToe/Engine/Application/{Player => CreatePlayer}/CreatePlayerCommand.php (90%) create mode 100644 src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerDto.php rename src/TicTacToe/Engine/Application/{Player => CreatePlayer}/CreatePlayerHandler.php (71%) rename src/TicTacToe/Shared/Infrastructure/{CommandBus => }/CommandBus.php (67%) create mode 100644 src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php create mode 100644 src/TicTacToe/Shared/Infrastructure/CommandBus/Exception/SorryCommandHandlerNotFound.php diff --git a/src/TicTacToe/Engine/Application/Player/CreatePlayerCommand.php b/src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerCommand.php similarity index 90% rename from src/TicTacToe/Engine/Application/Player/CreatePlayerCommand.php rename to src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerCommand.php index 76f06c3..e473196 100644 --- a/src/TicTacToe/Engine/Application/Player/CreatePlayerCommand.php +++ b/src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerCommand.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Engine\Application\Player; +namespace TicTacToe\Engine\Application\CreatePlayer; use TicTacToe\Shared\Application\Command; diff --git a/src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerDto.php b/src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerDto.php new file mode 100644 index 0000000..1ca81f1 --- /dev/null +++ b/src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerDto.php @@ -0,0 +1,54 @@ +playerId = (string) $player->id(); + $this->playerToken = $player->playingToken(); + $this->playerName = $player->name(); + } + + public function playerId(): string + { + return $this->playerId; + } + + public function playerName(): string + { + return $this->playerName; + } + + public function playerToken(): string + { + return $this->playerToken; + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'playerId' => $this->playerId, + 'playerName' => $this->playerName, + 'playerToken' => $this->playerToken + ]; + } +} diff --git a/src/TicTacToe/Engine/Application/Player/CreatePlayerHandler.php b/src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerHandler.php similarity index 71% rename from src/TicTacToe/Engine/Application/Player/CreatePlayerHandler.php rename to src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerHandler.php index c1a7fea..e208310 100644 --- a/src/TicTacToe/Engine/Application/Player/CreatePlayerHandler.php +++ b/src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerHandler.php @@ -2,11 +2,13 @@ declare(strict_types = 1); -namespace TicTacToe\Engine\Application\Player; +namespace TicTacToe\Engine\Application\CreatePlayer; use TicTacToe\Engine\Domain\Model\Player\Player; use TicTacToe\Engine\Domain\Model\Player\PlayerRepository; +use TicTacToe\Shared\Application\Command; use TicTacToe\Shared\Application\CommandHandler; +use TicTacToe\Shared\Application\DataTransformer; final class CreatePlayerHandler implements CommandHandler { @@ -18,20 +20,23 @@ public function __construct(PlayerRepository $playerRepository) $this->playerRepository = $playerRepository; } - public function __invoke(CreatePlayerCommand $command) + /** + * @inheritDoc + */ + public function handles(): string { - $player = Player::createPlayerWithToken($command->name(), $command->token()); - - $this->playerRepository->add($player); - - return $player; + return CreatePlayerCommand::class; } /** * @inheritDoc */ - public function handles(): string + public function handle(Command $command): DataTransformer { - return CreatePlayerCommand::class; + $player = Player::createPlayerWithToken($command->name(), $command->token()); + + $this->playerRepository->add($player); + + return new CreatePlayerDto($player); } } diff --git a/src/TicTacToe/Shared/Application/CommandHandler.php b/src/TicTacToe/Shared/Application/CommandHandler.php index e16cceb..62e92be 100644 --- a/src/TicTacToe/Shared/Application/CommandHandler.php +++ b/src/TicTacToe/Shared/Application/CommandHandler.php @@ -12,4 +12,10 @@ interface CommandHandler * @return string */ public function handles(): string; + + /** + * @param Command $command + * @return DataTransformer + */ + public function handle(Command $command): DataTransformer; } diff --git a/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBus.php b/src/TicTacToe/Shared/Infrastructure/CommandBus.php similarity index 67% rename from src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBus.php rename to src/TicTacToe/Shared/Infrastructure/CommandBus.php index ad194fe..ed3f70f 100644 --- a/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBus.php +++ b/src/TicTacToe/Shared/Infrastructure/CommandBus.php @@ -2,7 +2,11 @@ declare(strict_types = 1); -namespace TicTacToe\Shared\Infrastructure\CommandBus; +namespace TicTacToe\Shared\Infrastructure; + +use TicTacToe\Shared\Application\Command; +use TicTacToe\Shared\Application\CommandHandler; +use TicTacToe\Shared\Application\DataTransformer; interface CommandBus { diff --git a/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php new file mode 100644 index 0000000..014fbcf --- /dev/null +++ b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php @@ -0,0 +1,47 @@ +commandHandlers = []; + } + + /** + * @param Command $command + * @return DataTransformer + * @throws SorryCommandHandlerNotFound + */ + public function handle(Command $command): DataTransformer + { + $class = get_class($command); + if (!isset($this->commandHandlers[$class])) { + throw new SorryCommandHandlerNotFound($class); + } + + $handler = $this->commandHandlers[$class]; + return $handler->handle($command); + } + + /** + * @param Command $command + * @param CommandHandler $commandHandler + */ + public function register(Command $command, CommandHandler $commandHandler): void + { + $class = get_class($command); + $this->commandHandlers[$class] = $commandHandler; + } +} diff --git a/src/TicTacToe/Shared/Infrastructure/CommandBus/Exception/SorryCommandHandlerNotFound.php b/src/TicTacToe/Shared/Infrastructure/CommandBus/Exception/SorryCommandHandlerNotFound.php new file mode 100644 index 0000000..edecc97 --- /dev/null +++ b/src/TicTacToe/Shared/Infrastructure/CommandBus/Exception/SorryCommandHandlerNotFound.php @@ -0,0 +1,17 @@ + Date: Thu, 13 Jun 2019 01:41:06 +0200 Subject: [PATCH 48/75] more player tests. --- .../Engine/Domain/Model/Player/PlayerTest.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/unit/Engine/Domain/Model/Player/PlayerTest.php b/tests/unit/Engine/Domain/Model/Player/PlayerTest.php index ef3bcfa..7f80b19 100644 --- a/tests/unit/Engine/Domain/Model/Player/PlayerTest.php +++ b/tests/unit/Engine/Domain/Model/Player/PlayerTest.php @@ -3,6 +3,7 @@ declare(strict_types = 1); use PHPUnit\Framework\TestCase; +use TicTacToe\Engine\Domain\Model\Player\Exception\SorryInvalidPlayerToken; use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNameIsTooLong; use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNameIsTooShort; use TicTacToe\Engine\Domain\Model\Player\Player; @@ -21,6 +22,27 @@ public function testPlayerCreatedSuccessfully() self::assertInstanceOf(PlayerId::class, $player->id()); } + public function testPlayerCreatedWithPlayingTokenSuccessfully() + { + $player = Player::createPlayerWithToken( + "mina", + 'x' + ); + + self::assertEquals("mina", $player->name()); + self::assertEquals('x', $player->playingToken()); + self::assertInstanceOf(PlayerId::class, $player->id()); + } + + public function testPlayerThrowsInvalidPlayerTokenWhenInvalidToken() + { + self::expectException(SorryInvalidPlayerToken::class); + $player = Player::createPlayerWithToken( + "mina", + 'z' + ); + } + public function testPlayerCreatedWithPlayingTokenXSuccessfully() { $player = Player::createPlayerWithTokenX("mina"); From 06d6cffe857daecd521e8908006683b920809d4f Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 11:59:08 +0200 Subject: [PATCH 49/75] Game repository. --- .../Domain/Model/Game/GameRepository.php | 30 +++++++++++ .../InMemory/InMemoryGameRepository.php | 52 +++++++++++++++++++ .../InMemory/InMemoryPlayerRepository.php | 4 +- 3 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 src/TicTacToe/Engine/Domain/Model/Game/GameRepository.php create mode 100644 src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryGameRepository.php diff --git a/src/TicTacToe/Engine/Domain/Model/Game/GameRepository.php b/src/TicTacToe/Engine/Domain/Model/Game/GameRepository.php new file mode 100644 index 0000000..d86411a --- /dev/null +++ b/src/TicTacToe/Engine/Domain/Model/Game/GameRepository.php @@ -0,0 +1,30 @@ +games[(string) $game->id()] = $game; + } + + /** + * @param GameId $gameId + * @return Game|null + */ + public function ofId(GameId $gameId): ?Game + { + if (!isset($this->games[(string) $gameId])) { + return null; + } + + return $this->games[(string) $gameId]; + } + + /** + * @return GameId + */ + public function nextIdentity(): GameId + { + return new GameId(); + } + + /** + * @return array + */ + public function games(): array + { + return $this->games; + } +} diff --git a/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php index 8f4c0e1..8a6f7a7 100644 --- a/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php +++ b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php @@ -20,11 +20,11 @@ public function add(Player $player) public function ofId(PlayerId $playerId): ?Player { - if (!isset($this->players[(string)$playerId->id()])) { + if (!isset($this->players[(string) $playerId])) { return null; } - return $this->players[$playerId->id()]; + return $this->players[(string) $playerId]; } public function nextIdentity(): PlayerId From e0e327a22fa9f9b7234537228f0f15416e69d795 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 12:14:07 +0200 Subject: [PATCH 50/75] green PlayerRepository tests. --- .../InMemory/InMemoryPlayerRepositoryTest.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php diff --git a/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php b/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php new file mode 100644 index 0000000..588f8c0 --- /dev/null +++ b/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php @@ -0,0 +1,50 @@ +repository = new InMemoryPlayerRepository(); + } + + public function testItCanSaveAndGetPlayerByIdentity() + { + $player = $this->createPlayer(); + + $this->repository->add($player); + + self::assertEquals(1, count($this->repository->players())); + + $retrievedPlayer = $this->repository->ofId($player->id()); + self::assertEquals($player->id(), $retrievedPlayer->id()); + self::assertEquals($player->name(), $retrievedPlayer->name()); + self::assertEquals($player->playingToken(), $retrievedPlayer->playingToken()); + } + + public function testItGenerateNextIdentity() + { + $nextId = $this->repository->nextIdentity(); + + self::assertInstanceOf(PlayerId::class, $nextId); + self::assertTrue(Uuid::isValid((string) $nextId)); + } + + protected function createPlayer(string $name = 'foobar') + { + $player = Player::createPlayerWithTokenX($name); + + return $player; + } +} From 89b83d9d95781b83ab0d4baf5dccc878756ab973 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 13:05:17 +0200 Subject: [PATCH 51/75] red Game tests. --- .../CreatePlayerCommand.php | 2 +- .../CreatePlayerHandler.php | 4 +- .../CreatePlayerResponseDto.php} | 4 +- .../Engine/Domain/Model/Game/Game.php | 17 ++++---- .../Domain/Model/Player/PlayerIdSet.php | 40 +++++++++++++++++++ .../Engine/Domain/Model/Player/PlayerSet.php | 40 ------------------- .../InMemory/InMemoryPlayerRepositoryTest.php | 7 ++++ 7 files changed, 61 insertions(+), 53 deletions(-) rename src/TicTacToe/Engine/Application/{CreatePlayer => CreateNewPlayer}/CreatePlayerCommand.php (90%) rename src/TicTacToe/Engine/Application/{CreatePlayer => CreateNewPlayer}/CreatePlayerHandler.php (89%) rename src/TicTacToe/Engine/Application/{CreatePlayer/CreatePlayerDto.php => CreateNewPlayer/CreatePlayerResponseDto.php} (89%) create mode 100644 src/TicTacToe/Engine/Domain/Model/Player/PlayerIdSet.php delete mode 100644 src/TicTacToe/Engine/Domain/Model/Player/PlayerSet.php diff --git a/src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerCommand.php b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerCommand.php similarity index 90% rename from src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerCommand.php rename to src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerCommand.php index e473196..b127f44 100644 --- a/src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerCommand.php +++ b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerCommand.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Engine\Application\CreatePlayer; +namespace TicTacToe\Engine\Application\CreateNewPlayer; use TicTacToe\Shared\Application\Command; diff --git a/src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerHandler.php b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerHandler.php similarity index 89% rename from src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerHandler.php rename to src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerHandler.php index e208310..79d2c94 100644 --- a/src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerHandler.php +++ b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerHandler.php @@ -2,7 +2,7 @@ declare(strict_types = 1); -namespace TicTacToe\Engine\Application\CreatePlayer; +namespace TicTacToe\Engine\Application\CreateNewPlayer; use TicTacToe\Engine\Domain\Model\Player\Player; use TicTacToe\Engine\Domain\Model\Player\PlayerRepository; @@ -37,6 +37,6 @@ public function handle(Command $command): DataTransformer $this->playerRepository->add($player); - return new CreatePlayerDto($player); + return new CreatePlayerResponseDto($player); } } diff --git a/src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerDto.php b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerResponseDto.php similarity index 89% rename from src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerDto.php rename to src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerResponseDto.php index 1ca81f1..fac5424 100644 --- a/src/TicTacToe/Engine/Application/CreatePlayer/CreatePlayerDto.php +++ b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerResponseDto.php @@ -2,12 +2,12 @@ declare(strict_types = 1); -namespace TicTacToe\Engine\Application\CreatePlayer; +namespace TicTacToe\Engine\Application\CreateNewPlayer; use TicTacToe\Engine\Domain\Model\Player\Player; use TicTacToe\Shared\Application\DataTransformer; -final class CreatePlayerDto implements DataTransformer +final class CreatePlayerResponseDto implements DataTransformer { /** @var string */ private $playerId; diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Game.php b/src/TicTacToe/Engine/Domain/Model/Game/Game.php index 9a22053..c72c75a 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/Game.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Game.php @@ -8,7 +8,8 @@ use TicTacToe\Engine\Domain\Model\Game\Event\GameCreated; use TicTacToe\Engine\Domain\Model\Game\Exception\SorryTooManyPlayers; use TicTacToe\Engine\Domain\Model\Player\Player; -use TicTacToe\Engine\Domain\Model\Player\PlayerSet; +use TicTacToe\Engine\Domain\Model\Player\PlayerId; +use TicTacToe\Engine\Domain\Model\Player\PlayerIdSet; use TicTacToe\Shared\Domain\Model\AggregateRoot; final class Game extends AggregateRoot @@ -16,8 +17,8 @@ final class Game extends AggregateRoot /** @var GameId */ private $id; - /** @var PlayerSet */ - private $players; + /** @var PlayerIdSet */ + private $playerIds; /** @var Board */ private $board; @@ -27,15 +28,15 @@ final class Game extends AggregateRoot public const MAX_PLAYERS = 2; - private function __construct(GameId $gameId, Board $board, Player ...$players) + private function __construct(GameId $gameId, Board $board, PlayerId ...$playerIds) { - if (count($players) > self::MAX_PLAYERS) { + if (count($playerIds) > self::MAX_PLAYERS) { throw new SorryTooManyPlayers("Only " . self::MAX_PLAYERS . " players allowed."); } $this->id = $gameId; $this->board = $board; - $this->players = new PlayerSet(...$players); + $this->playerIds = new PlayerIdSet(...$playerIds); $this->createdAt = new \DateTimeImmutable(); } @@ -55,9 +56,9 @@ public function id(): GameId return $this->id; } - public function players(): PlayerSet + public function players(): PlayerIdSet { - return $this->players; + return $this->playerIds; } public function board(): Board diff --git a/src/TicTacToe/Engine/Domain/Model/Player/PlayerIdSet.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerIdSet.php new file mode 100644 index 0000000..129cef5 --- /dev/null +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerIdSet.php @@ -0,0 +1,40 @@ +playerIds = $playerIds; + } + + /** + * @return array|PlayerId[] + */ + public function toArray(): array + { + return $this->playerIds; + } + + public function getIterator(): \Traversable + { + return new \ArrayIterator($this->toArray()); + } + + public function count() + { + return count($this->playerIds); + } +} diff --git a/src/TicTacToe/Engine/Domain/Model/Player/PlayerSet.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerSet.php deleted file mode 100644 index 6e53635..0000000 --- a/src/TicTacToe/Engine/Domain/Model/Player/PlayerSet.php +++ /dev/null @@ -1,40 +0,0 @@ -players = $players; - } - - /** - * @return array|Player[] - */ - public function toArray(): array - { - return $this->players; - } - - public function getIterator(): \Traversable - { - return new \ArrayIterator($this->toArray()); - } - - public function count() - { - return count($this->players); - } -} diff --git a/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php b/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php index 588f8c0..ba69812 100644 --- a/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php +++ b/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php @@ -41,6 +41,13 @@ public function testItGenerateNextIdentity() self::assertTrue(Uuid::isValid((string) $nextId)); } + public function testItReturnsNullIfPlayerNotFound() + { + $playerId = new PlayerId('1'); + $retrievedPlayer = $this->repository->ofId($playerId); + self::assertEquals(null, $retrievedPlayer); + } + protected function createPlayer(string $name = 'foobar') { $player = Player::createPlayerWithTokenX($name); From 0af4f3f3cfc8681e004a86aec09cc4fc6fcc682e Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 13:08:31 +0200 Subject: [PATCH 52/75] green Game tests. --- src/TicTacToe/Engine/Domain/Model/Game/Game.php | 6 +++--- tests/unit/Engine/Domain/Model/Game/GameTest.php | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Game.php b/src/TicTacToe/Engine/Domain/Model/Game/Game.php index c72c75a..8a1cde6 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/Game.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Game.php @@ -40,9 +40,9 @@ private function __construct(GameId $gameId, Board $board, PlayerId ...$playerId $this->createdAt = new \DateTimeImmutable(); } - public static function start(GameId $gameId, Board $board, Player ...$players) + public static function start(GameId $gameId, Board $board, PlayerId ...$playerIds) { - $game = new self($gameId, $board, ...$players); + $game = new self($gameId, $board, ...$playerIds); $game->record( new GameCreated($game) @@ -56,7 +56,7 @@ public function id(): GameId return $this->id; } - public function players(): PlayerIdSet + public function playerIds(): PlayerIdSet { return $this->playerIds; } diff --git a/tests/unit/Engine/Domain/Model/Game/GameTest.php b/tests/unit/Engine/Domain/Model/Game/GameTest.php index 641e630..430a435 100644 --- a/tests/unit/Engine/Domain/Model/Game/GameTest.php +++ b/tests/unit/Engine/Domain/Model/Game/GameTest.php @@ -14,10 +14,10 @@ class GameTest extends TestCase public function testItCreatesGameSuccessfully() { $gameId = new GameId(); - $players = $this->createPlayers(2); - $game = Game::start($gameId, Board::create3By3Board(), ...$players); + $playerIds = $this->createPlayers(2); + $game = Game::start($gameId, Board::create3By3Board(), ...$playerIds); - self::assertEquals(2, $game->players()->count()); + self::assertEquals(2, $game->playerIds()->count()); self::assertInstanceOf(GameId::class, $game->id()); self::assertInstanceOf(Board::class, $game->board()); } @@ -25,9 +25,9 @@ public function testItCreatesGameSuccessfully() public function testItThrowsTooManyPlayersWhenMorePlayersCreated() { $gameId = new GameId(); - $players = $this->createPlayers(3); + $playerIds = $this->createPlayers(3); self::expectException(SorryTooManyPlayers::class); - Game::start($gameId, Board::create3By3Board(), ...$players); + Game::start($gameId, Board::create3By3Board(), ...$playerIds); } public function randomizeString(int $length) @@ -46,9 +46,9 @@ public function createPlayers(int $count) $players = []; for($i = 0; $i < $count; $i++) { if ($i % 2 == 0) { - $players[] = Player::createPlayerWithTokenX($this->randomizeString(5)); + $players[] = Player::createPlayerWithTokenX($this->randomizeString(5))->id(); } else { - $players[] = Player::createPlayerWithTokenY($this->randomizeString(5)); + $players[] = Player::createPlayerWithTokenY($this->randomizeString(5))->id(); } } From 77fc5615db7c156b44375a2b3b38d1584bcf8eca Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 13:32:43 +0200 Subject: [PATCH 53/75] CreateNewGame command and handler. --- .../CreateNewGame/CreateNewGameCommand.php | 32 ++++++++++ .../CreateNewGame/CreateNewGameHandler.php | 58 +++++++++++++++++ .../CreateNewGameResponseDto.php | 64 +++++++++++++++++++ ...Command.php => CreateNewPlayerCommand.php} | 2 +- ...Handler.php => CreateNewPlayerHandler.php} | 6 +- ...Dto.php => CreateNewPlayerResponseDto.php} | 18 ++++-- .../Exception/SorryWrongCommand.php | 15 +++++ 7 files changed, 187 insertions(+), 8 deletions(-) create mode 100644 src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameCommand.php create mode 100644 src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameHandler.php create mode 100644 src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameResponseDto.php rename src/TicTacToe/Engine/Application/CreateNewPlayer/{CreatePlayerCommand.php => CreateNewPlayerCommand.php} (90%) rename src/TicTacToe/Engine/Application/CreateNewPlayer/{CreatePlayerHandler.php => CreateNewPlayerHandler.php} (84%) rename src/TicTacToe/Engine/Application/CreateNewPlayer/{CreatePlayerResponseDto.php => CreateNewPlayerResponseDto.php} (66%) create mode 100644 src/TicTacToe/Shared/Application/Exception/SorryWrongCommand.php diff --git a/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameCommand.php b/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameCommand.php new file mode 100644 index 0000000..62dbf49 --- /dev/null +++ b/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameCommand.php @@ -0,0 +1,32 @@ +playerIds = $playerIds; + $this->boardSize = $boardSize; + } + + public function playerIds(): array + { + return $this->playerIds; + } + + public function boardSize(): int + { + return $this->boardSize; + } +} diff --git a/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameHandler.php b/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameHandler.php new file mode 100644 index 0000000..bf22c04 --- /dev/null +++ b/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameHandler.php @@ -0,0 +1,58 @@ +gameRepository = $gameRepository; + } + + /** + * @inheritDoc + */ + public function handles(): string + { + return CreateNewGameCommand::class; + } + + /** + * @inheritDoc + */ + public function handle(Command $command): DataTransformer + { + if (!$command instanceof CreateNewGameCommand) { + throw new SorryWrongCommand(); + } + + $playerIds = array_map(function (string $playerId) { + return new PlayerId($playerId); + }, $command->playerIds()); + + $game = Game::start( + new GameId(), + new Board($command->boardSize()), + ...$playerIds + ); + + $this->gameRepository->add($game); + + return new CreateNewGameResponseDto($game); + } +} diff --git a/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameResponseDto.php b/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameResponseDto.php new file mode 100644 index 0000000..268a42c --- /dev/null +++ b/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameResponseDto.php @@ -0,0 +1,64 @@ +gameId = (string) $game->id(); + $this->boardSize = $game->board()->size(); + $this->playerIds = $game->playerIds()->toArray(); + $this->createdAt = $game->createdAt(); + } + + public function gameId(): string + { + return $this->gameId; + } + + public function boardSize(): int + { + return $this->boardSize; + } + + public function playerIds(): array + { + return $this->playerIds; + } + + public function createdAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + /** + * @return array + */ + public function toArray(): array + { + return [ + 'id' => $this->gameId, + 'boardSize' => $this->boardSize, + 'playerIds' => $this->playerIds, + 'createdAt' => $this->createdAt->format(\DateTimeImmutable::ATOM) + ]; + } +} diff --git a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerCommand.php b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerCommand.php similarity index 90% rename from src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerCommand.php rename to src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerCommand.php index b127f44..ae80af6 100644 --- a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerCommand.php +++ b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerCommand.php @@ -6,7 +6,7 @@ use TicTacToe\Shared\Application\Command; -final class CreatePlayerCommand implements Command +final class CreateNewPlayerCommand implements Command { /** @var string */ private $name; diff --git a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerHandler.php b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerHandler.php similarity index 84% rename from src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerHandler.php rename to src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerHandler.php index 79d2c94..a4714cd 100644 --- a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerHandler.php +++ b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerHandler.php @@ -10,7 +10,7 @@ use TicTacToe\Shared\Application\CommandHandler; use TicTacToe\Shared\Application\DataTransformer; -final class CreatePlayerHandler implements CommandHandler +final class CreateNewPlayerHandler implements CommandHandler { /** @var PlayerRepository */ private $playerRepository; @@ -25,7 +25,7 @@ public function __construct(PlayerRepository $playerRepository) */ public function handles(): string { - return CreatePlayerCommand::class; + return CreateNewPlayerCommand::class; } /** @@ -37,6 +37,6 @@ public function handle(Command $command): DataTransformer $this->playerRepository->add($player); - return new CreatePlayerResponseDto($player); + return new CreateNewPlayerResponseDto($player); } } diff --git a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerResponseDto.php b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerResponseDto.php similarity index 66% rename from src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerResponseDto.php rename to src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerResponseDto.php index fac5424..d703391 100644 --- a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreatePlayerResponseDto.php +++ b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerResponseDto.php @@ -7,7 +7,7 @@ use TicTacToe\Engine\Domain\Model\Player\Player; use TicTacToe\Shared\Application\DataTransformer; -final class CreatePlayerResponseDto implements DataTransformer +final class CreateNewPlayerResponseDto implements DataTransformer { /** @var string */ private $playerId; @@ -18,11 +18,15 @@ final class CreatePlayerResponseDto implements DataTransformer /** @var string */ private $playerName; + /** @var \DateTimeImmutable */ + private $createdAt; + public function __construct(Player $player) { $this->playerId = (string) $player->id(); $this->playerToken = $player->playingToken(); $this->playerName = $player->name(); + $this->createdAt = $player->createdAt(); } public function playerId(): string @@ -40,15 +44,21 @@ public function playerToken(): string return $this->playerToken; } + public function createdAt(): \DateTimeImmutable + { + return $this->createdAt; + } + /** * @return array */ public function toArray(): array { return [ - 'playerId' => $this->playerId, - 'playerName' => $this->playerName, - 'playerToken' => $this->playerToken + 'id' => $this->playerId, + 'name' => $this->playerName, + 'token' => $this->playerToken, + 'createdAt' => $this->createdAt->format(\DateTimeImmutable::ATOM) ]; } } diff --git a/src/TicTacToe/Shared/Application/Exception/SorryWrongCommand.php b/src/TicTacToe/Shared/Application/Exception/SorryWrongCommand.php new file mode 100644 index 0000000..f3889ec --- /dev/null +++ b/src/TicTacToe/Shared/Application/Exception/SorryWrongCommand.php @@ -0,0 +1,15 @@ + Date: Thu, 13 Jun 2019 13:35:23 +0200 Subject: [PATCH 54/75] throw error if wrong command passed. --- .../Application/CreateNewPlayer/CreateNewPlayerHandler.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerHandler.php b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerHandler.php index a4714cd..d3d86b6 100644 --- a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerHandler.php +++ b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerHandler.php @@ -9,6 +9,7 @@ use TicTacToe\Shared\Application\Command; use TicTacToe\Shared\Application\CommandHandler; use TicTacToe\Shared\Application\DataTransformer; +use TicTacToe\Shared\Application\Exception\SorryWrongCommand; final class CreateNewPlayerHandler implements CommandHandler { @@ -33,6 +34,9 @@ public function handles(): string */ public function handle(Command $command): DataTransformer { + if (!$command instanceof CreateNewPlayerCommand) { + throw new SorryWrongCommand(); + } $player = Player::createPlayerWithToken($command->name(), $command->token()); $this->playerRepository->add($player); From bc67e75f9a7633b0162f32fa5d8ddd6322f64e2f Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 13 Jun 2019 13:41:37 +0200 Subject: [PATCH 55/75] Input interface. --- .../Presentation/Console/ConsoleInput.php | 68 ++++++++++++ .../Presentation/Console/ConsoleOutput.php | 8 +- src/TicTacToe/Engine/Presentation/Input.php | 19 ++++ src/TicTacToe/IO/IOHandler.php | 105 ------------------ 4 files changed, 91 insertions(+), 109 deletions(-) create mode 100644 src/TicTacToe/Engine/Presentation/Console/ConsoleInput.php create mode 100644 src/TicTacToe/Engine/Presentation/Input.php delete mode 100644 src/TicTacToe/IO/IOHandler.php diff --git a/src/TicTacToe/Engine/Presentation/Console/ConsoleInput.php b/src/TicTacToe/Engine/Presentation/Console/ConsoleInput.php new file mode 100644 index 0000000..584b122 --- /dev/null +++ b/src/TicTacToe/Engine/Presentation/Console/ConsoleInput.php @@ -0,0 +1,68 @@ +readStringFromStream(); + if (empty($input) && !$allowEmpty) { + throw new \InvalidArgumentException("Input cannot be empty."); + } + if (!is_string($input)) { + throw new \InvalidArgumentException("Input is not a valid 'string'."); + } + + return trim($input); + } + + /** + * @inheritDoc + */ + public function readInteger(): int + { + $input = $this->readIntegerFromStream(); + if (!empty($input)) { + if (!is_integer($input)) { + throw new \InvalidArgumentException("Input is not a valid 'integer'."); + } + } + + $input = intval($input); + return $input; + } + + /** + * @codeCoverageIgnore + * + * Read string from stream + * + * @return string + */ + protected function readStringFromStream() + { + $string = trim(fgets(STDIN)); + return $string; + } + + /** + * @codeCoverageIgnore + * + * Return integer from stream + * + * @return integer + */ + protected function readIntegerFromStream() + { + fscanf(STDIN, "%d\n", $number); + return $number; + } +} diff --git a/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php b/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php index 82d7e3e..df00dbd 100644 --- a/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php +++ b/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php @@ -8,10 +8,10 @@ final class ConsoleOutput implements Output { - private const ERROR = "\033[31mERROR: %s"; - private const SUCCESS = "\033[32m%s"; - private const INFO = "\033[0m%s"; - private const WARNING = "\033[33mWarning: %s"; + private const ERROR = "\033[31mERROR: %s\n"; + private const SUCCESS = "\033[32m%s\n"; + private const INFO = "\033[0mINFO: %s\n"; + private const WARNING = "\033[33mWarning: %s\n"; public function error(string $error) { diff --git a/src/TicTacToe/Engine/Presentation/Input.php b/src/TicTacToe/Engine/Presentation/Input.php new file mode 100644 index 0000000..6b798dd --- /dev/null +++ b/src/TicTacToe/Engine/Presentation/Input.php @@ -0,0 +1,19 @@ +write($line . PHP_EOL, $type); - } - } elseif (!is_array($output)) { - $this->write($output . PHP_EOL, $type); - } - } - - public function readInteger() - { - $input = $this->readIntegerFromStream(); - if (!empty($input)) { - if (!is_integer($input)) { - throw new \InvalidArgumentException("Input is not a valid 'integer'."); - } - } - - $input = intval($input); - return $input; - } - - public function readString($allowEmpty = false) - { - $input = $this->readStringFromStream(); - if (empty($input) && !$allowEmpty) { - throw new \InvalidArgumentException("Input cannot be empty."); - } - if (!is_string($input)) { - throw new \InvalidArgumentException("Input is not a valid 'string'."); - } - - return trim($input); - } -} From e018f65a9522e1c4d4d5db52ae2e329dbef82da3 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Fri, 14 Jun 2019 14:34:21 +0200 Subject: [PATCH 56/75] CreateNewPlayerHandler test. --- Makefile | 8 +-- composer.json | 9 ++- phpunit.xml | 9 +-- .../CreateNewPlayerHandlerTest.php | 60 +++++++++++++++++++ .../Engine/Domain/Model/Board/BoardTest.php | 2 + .../Engine/Domain/Model/Board/CellTest.php | 2 + .../Engine/Domain/Model/Game/GameIdTest.php | 2 + .../Engine/Domain/Model/Game/GameTest.php | 2 + .../Model/Player/Event/PlayerCreatedTest.php | 2 + .../Domain/Model/Player/PlayerIdTest.php | 2 + .../Domain/Model/Player/PlayerNameTest.php | 2 + .../Engine/Domain/Model/Player/PlayerTest.php | 2 + .../Domain/Model/Player/PlayerTokenTest.php | 2 + .../InMemory/InMemoryPlayerRepositoryTest.php | 2 + tests/unit/WrongCommand.php | 12 ++++ 15 files changed, 106 insertions(+), 12 deletions(-) create mode 100644 tests/unit/Engine/Application/CreateNewPlayer/CreateNewPlayerHandlerTest.php create mode 100644 tests/unit/WrongCommand.php diff --git a/Makefile b/Makefile index 576e516..972d0e9 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ else CMD := docker-compose exec php endif -all: clear container-up lint-composer lint-php composer phpcs tests static-analysis +all: container-up clear lint-composer lint-php composer phpcs tests lint-composer: @echo "\n==> Validating composer.json and composer.lock:" @@ -39,10 +39,6 @@ tests: @echo "\n==> Running tests" $(CMD) bin/phpunit -static-analysis: - @echo "\n==> Running static analysis" - $(CMD) bin/phpstan -l 7 -c phpstan.neon src tests - container-stop: @echo "\n==> Stopping docker container" $(DOCKER_COMPOSE) stop @@ -55,7 +51,7 @@ container-up: @echo "\n==> Docker container building and starting ..." $(DOCKER_COMPOSE) up --build -d -tear-down: container-stop container-down +tear-down: clear container-stop container-down .PHONY: lint-php lint-composer phpcs phpcbf composer clear tests coverage container-up static-analysis container-stop container-down diff --git a/composer.json b/composer.json index cd0ba09..b38d26b 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,13 @@ "phpunit/phpunit": "^7" }, "autoload": { - "psr-0": { - "TicTacToe": "src/" + "psr-4": { + "": "./src/" + } + }, + "autoload-dev": { + "psr-4": { + "unit\\TicTacToe\\": "./tests/unit" } }, "config": { diff --git a/phpunit.xml b/phpunit.xml index a871f37..3f8192b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,15 +1,16 @@ - + - ./tests/ + ./tests/unit - + ./src/TicTacToe/ - ./src/TicTacToe/Test/ ./vendor/ diff --git a/tests/unit/Engine/Application/CreateNewPlayer/CreateNewPlayerHandlerTest.php b/tests/unit/Engine/Application/CreateNewPlayer/CreateNewPlayerHandlerTest.php new file mode 100644 index 0000000..b8ee908 --- /dev/null +++ b/tests/unit/Engine/Application/CreateNewPlayer/CreateNewPlayerHandlerTest.php @@ -0,0 +1,60 @@ +playerRepository = new InMemoryPlayerRepository(); + $this->handler = new CreateNewPlayerHandler( + $this->playerRepository + ); + } + + public function testItHandlesCorrectClass() + { + self::assertEquals(CreateNewPlayerCommand::class, $this->handler->handles()); + } + + public function testItCanCreateANewPlayer() + { + $command = $this->createCommand(); + + /** @var CreateNewPlayerResponseDto $playerDto */ + $playerDto = $this->handler->handle($command); + $retreivedPlayer = $this->playerRepository->ofId(new PlayerId($playerDto->playerId())); + self::assertEquals($retreivedPlayer->name(), $playerDto->playerName()); + self::assertEquals($retreivedPlayer->playingToken(), $playerDto->playerToken()); + } + + public function testItThrowsSorryWrongCommandWhenWrongCommandPassed() + { + $command = new WrongCommand(); + + self::expectException(SorryWrongCommand::class); + $this->handler->handle($command); + } + + private function createCommand(string $name = 'player', string $token = 'x') + { + return new CreateNewPlayerCommand($name, $token); + } +} diff --git a/tests/unit/Engine/Domain/Model/Board/BoardTest.php b/tests/unit/Engine/Domain/Model/Board/BoardTest.php index cbbf169..ae05988 100644 --- a/tests/unit/Engine/Domain/Model/Board/BoardTest.php +++ b/tests/unit/Engine/Domain/Model/Board/BoardTest.php @@ -2,6 +2,8 @@ declare(strict_types = 1); +namespace unit\TicTacToe\Engine\Domain\Model\Board; + use PHPUnit\Framework\TestCase; use TicTacToe\Engine\Domain\Model\Board\Board; use TicTacToe\Engine\Domain\Model\Board\Exception\SorryBoardSizeIsNotValid; diff --git a/tests/unit/Engine/Domain/Model/Board/CellTest.php b/tests/unit/Engine/Domain/Model/Board/CellTest.php index 424afef..31a0420 100644 --- a/tests/unit/Engine/Domain/Model/Board/CellTest.php +++ b/tests/unit/Engine/Domain/Model/Board/CellTest.php @@ -2,6 +2,8 @@ declare(strict_types = 1); +namespace unit\TicTacToe\Engine\Domain\Model\Board; + use PHPUnit\Framework\TestCase; use TicTacToe\Engine\Domain\Model\Board\Cell; use TicTacToe\Engine\Domain\Model\Player\PlayerToken; diff --git a/tests/unit/Engine/Domain/Model/Game/GameIdTest.php b/tests/unit/Engine/Domain/Model/Game/GameIdTest.php index 2a31508..792541f 100644 --- a/tests/unit/Engine/Domain/Model/Game/GameIdTest.php +++ b/tests/unit/Engine/Domain/Model/Game/GameIdTest.php @@ -2,6 +2,8 @@ declare(strict_types = 1); +namespace unit\TicTacToe\Engine\Domain\Model\Game; + use PHPUnit\Framework\TestCase; use Ramsey\Uuid\Uuid; use TicTacToe\Engine\Domain\Model\Game\GameId; diff --git a/tests/unit/Engine/Domain/Model/Game/GameTest.php b/tests/unit/Engine/Domain/Model/Game/GameTest.php index 430a435..83c3a28 100644 --- a/tests/unit/Engine/Domain/Model/Game/GameTest.php +++ b/tests/unit/Engine/Domain/Model/Game/GameTest.php @@ -2,6 +2,8 @@ declare(strict_types = 1); +namespace unit\TicTacToe\Engine\Domain\Model\Game; + use PHPUnit\Framework\TestCase; use TicTacToe\Engine\Domain\Model\Board\Board; use TicTacToe\Engine\Domain\Model\Game\Exception\SorryTooManyPlayers; diff --git a/tests/unit/Engine/Domain/Model/Player/Event/PlayerCreatedTest.php b/tests/unit/Engine/Domain/Model/Player/Event/PlayerCreatedTest.php index 2b61fb3..a294e34 100644 --- a/tests/unit/Engine/Domain/Model/Player/Event/PlayerCreatedTest.php +++ b/tests/unit/Engine/Domain/Model/Player/Event/PlayerCreatedTest.php @@ -2,6 +2,8 @@ declare(strict_types = 1); +namespace unit\TicTacToe\Engine\Domain\Model\Player\Event; + use PHPUnit\Framework\TestCase; use TicTacToe\Engine\Domain\Model\Player\Event\PlayerCreated; use TicTacToe\Engine\Domain\Model\Player\Player; diff --git a/tests/unit/Engine/Domain/Model/Player/PlayerIdTest.php b/tests/unit/Engine/Domain/Model/Player/PlayerIdTest.php index c271c74..def5b11 100644 --- a/tests/unit/Engine/Domain/Model/Player/PlayerIdTest.php +++ b/tests/unit/Engine/Domain/Model/Player/PlayerIdTest.php @@ -2,6 +2,8 @@ declare(strict_types = 1); +namespace unit\TicTacToe\Engine\Domain\Model\Player; + use PHPUnit\Framework\TestCase; use Ramsey\Uuid\Uuid; use TicTacToe\Engine\Domain\Model\Player\PlayerId; diff --git a/tests/unit/Engine/Domain/Model/Player/PlayerNameTest.php b/tests/unit/Engine/Domain/Model/Player/PlayerNameTest.php index 21edee1..911b3ba 100644 --- a/tests/unit/Engine/Domain/Model/Player/PlayerNameTest.php +++ b/tests/unit/Engine/Domain/Model/Player/PlayerNameTest.php @@ -2,6 +2,8 @@ declare(strict_types = 1); +namespace unit\TicTacToe\Engine\Domain\Model\Player; + use PHPUnit\Framework\TestCase; use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNameIsTooShort; use TicTacToe\Engine\Domain\Model\Player\PlayerName; diff --git a/tests/unit/Engine/Domain/Model/Player/PlayerTest.php b/tests/unit/Engine/Domain/Model/Player/PlayerTest.php index 7f80b19..67b9359 100644 --- a/tests/unit/Engine/Domain/Model/Player/PlayerTest.php +++ b/tests/unit/Engine/Domain/Model/Player/PlayerTest.php @@ -2,6 +2,8 @@ declare(strict_types = 1); +namespace unit\TicTacToe\Engine\Domain\Model\Player; + use PHPUnit\Framework\TestCase; use TicTacToe\Engine\Domain\Model\Player\Exception\SorryInvalidPlayerToken; use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNameIsTooLong; diff --git a/tests/unit/Engine/Domain/Model/Player/PlayerTokenTest.php b/tests/unit/Engine/Domain/Model/Player/PlayerTokenTest.php index 1e405fb..f361b8c 100644 --- a/tests/unit/Engine/Domain/Model/Player/PlayerTokenTest.php +++ b/tests/unit/Engine/Domain/Model/Player/PlayerTokenTest.php @@ -2,6 +2,8 @@ declare(strict_types = 1); +namespace unit\TicTacToe\Engine\Domain\Model\Player; + use PHPUnit\Framework\TestCase; use TicTacToe\Engine\Domain\Model\Player\Exception\SorryInvalidPlayerToken; use TicTacToe\Engine\Domain\Model\Player\PlayerToken; diff --git a/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php b/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php index ba69812..8a67dd7 100644 --- a/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php +++ b/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php @@ -2,6 +2,8 @@ declare(strict_types = 1); +namespace unit\TicTacToe\Engine\Infrastructure\Persistence\InMemory; + use PHPUnit\Framework\TestCase; use Ramsey\Uuid\Uuid; use TicTacToe\Engine\Domain\Model\Player\Player; diff --git a/tests/unit/WrongCommand.php b/tests/unit/WrongCommand.php new file mode 100644 index 0000000..9f89cf8 --- /dev/null +++ b/tests/unit/WrongCommand.php @@ -0,0 +1,12 @@ + Date: Fri, 14 Jun 2019 14:38:54 +0200 Subject: [PATCH 57/75] fix composer. --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b38d26b..8d67021 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,8 @@ "phpunit/phpunit": "^7" }, "autoload": { - "psr-4": { - "": "./src/" + "psr-0": { + "TicTacToe": "./src/" } }, "autoload-dev": { From 189b35680358b8857d402aca1be07fc06578ea39 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 18 Jun 2019 13:22:30 +0200 Subject: [PATCH 58/75] update composer packages --- composer.lock | 645 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 413 insertions(+), 232 deletions(-) diff --git a/composer.lock b/composer.lock index dc07572..ca24471 100644 --- a/composer.lock +++ b/composer.lock @@ -135,16 +135,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "2.8.1", + "version": "2.9.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d" + "reference": "2acf168de78487db620ab4bc524135a13cfe6745" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", - "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745", + "reference": "2acf168de78487db620ab4bc524135a13cfe6745", "shasum": "" }, "require": { @@ -209,20 +209,20 @@ "phpcs", "standards" ], - "time": "2017-03-01T22:17:45+00:00" + "time": "2018-11-07T22:31:41+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.9.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + "reference": "82ebae02209c21113908c229e9883c419720738a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", + "reference": "82ebae02209c21113908c229e9883c419720738a", "shasum": "" }, "require": { @@ -234,7 +234,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -267,22 +267,22 @@ "polyfill", "portable" ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2019-02-06T07:57:58+00:00" } ], "packages-dev": [ { "name": "composer/xdebug-handler", - "version": "1.3.0", + "version": "1.3.3", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c" + "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/b8e9745fb9b06ea6664d8872c4505fb16df4611c", - "reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/46867cbf8ca9fb8d60c506895449eb799db1184f", + "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f", "shasum": "" }, "require": { @@ -313,31 +313,33 @@ "Xdebug", "performance" ], - "time": "2018-08-31T19:07:57+00:00" + "time": "2019-05-27T17:52:04+00:00" }, { "name": "doctrine/instantiator", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + "reference": "a2c590166b2133a4633738648b6b064edae0814a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", + "reference": "a2c590166b2133a4633738648b6b064edae0814a", "shasum": "" }, "require": { "php": "^7.1" }, "require-dev": { - "athletic/athletic": "~0.1.8", + "doctrine/coding-standard": "^6.0", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2" + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { @@ -362,12 +364,12 @@ } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ "constructor", "instantiate" ], - "time": "2017-07-22T11:58:36+00:00" + "time": "2019-03-17T17:37:11+00:00" }, { "name": "jean85/pretty-package-versions", @@ -422,16 +424,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.8.1", + "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" + "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", + "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", "shasum": "" }, "require": { @@ -466,43 +468,40 @@ "object", "object graph" ], - "time": "2018-06-11T23:09:50+00:00" + "time": "2019-04-07T13:18:21+00:00" }, { "name": "nette/bootstrap", - "version": "v2.4.6", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/nette/bootstrap.git", - "reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543" + "reference": "e1075af05c211915e03e0c86542f3ba5433df4a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/bootstrap/zipball/268816e3f1bb7426c3a4ceec2bd38a036b532543", - "reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543", + "url": "https://api.github.com/repos/nette/bootstrap/zipball/e1075af05c211915e03e0c86542f3ba5433df4a3", + "reference": "e1075af05c211915e03e0c86542f3ba5433df4a3", "shasum": "" }, "require": { - "nette/di": "~2.4.7", - "nette/utils": "~2.4", - "php": ">=5.6.0" - }, - "conflict": { - "nette/nette": "<2.2" + "nette/di": "^3.0", + "nette/utils": "^3.0", + "php": ">=7.1" }, "require-dev": { - "latte/latte": "~2.2", - "nette/application": "~2.3", - "nette/caching": "~2.3", - "nette/database": "~2.3", - "nette/forms": "~2.3", - "nette/http": "~2.4.0", - "nette/mail": "~2.3", - "nette/robot-loader": "^2.4.2 || ^3.0", - "nette/safe-stream": "~2.2", - "nette/security": "~2.3", - "nette/tester": "~2.0", - "tracy/tracy": "^2.4.1" + "latte/latte": "^2.2", + "nette/application": "^3.0", + "nette/caching": "^3.0", + "nette/database": "^3.0", + "nette/forms": "^3.0", + "nette/http": "^3.0", + "nette/mail": "^3.0", + "nette/robot-loader": "^3.0", + "nette/safe-stream": "^2.2", + "nette/security": "^3.0", + "nette/tester": "^2.0", + "tracy/tracy": "^2.6" }, "suggest": { "nette/robot-loader": "to use Configurator::createRobotLoader()", @@ -511,7 +510,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -542,46 +541,50 @@ "configurator", "nette" ], - "time": "2018-05-17T12:52:20+00:00" + "time": "2019-03-26T12:59:07+00:00" }, { "name": "nette/di", - "version": "v2.4.14", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/nette/di.git", - "reference": "923da3e2c0aa53162ef455472c0ac7787b096c5a" + "reference": "19d83539245aaacb59470828919182411061841f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/di/zipball/923da3e2c0aa53162ef455472c0ac7787b096c5a", - "reference": "923da3e2c0aa53162ef455472c0ac7787b096c5a", + "url": "https://api.github.com/repos/nette/di/zipball/19d83539245aaacb59470828919182411061841f", + "reference": "19d83539245aaacb59470828919182411061841f", "shasum": "" }, "require": { "ext-tokenizer": "*", - "nette/neon": "^2.3.3 || ~3.0.0", - "nette/php-generator": "^2.6.1 || ~3.0.0", - "nette/utils": "^2.4.3 || ~3.0.0", - "php": ">=5.6.0" + "nette/neon": "^3.0", + "nette/php-generator": "^3.2.2", + "nette/robot-loader": "^3.2", + "nette/schema": "^1.0", + "nette/utils": "^3.0", + "php": ">=7.1" }, "conflict": { - "nette/bootstrap": "<2.4", - "nette/nette": "<2.2" + "nette/bootstrap": "<3.0" }, "require-dev": { - "nette/tester": "^2.0", + "nette/tester": "^2.2", "tracy/tracy": "^2.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { "classmap": [ "src/" + ], + "files": [ + "src/compatibility.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -611,37 +614,37 @@ "nette", "static" ], - "time": "2018-09-17T15:47:40+00:00" + "time": "2019-04-03T19:35:46+00:00" }, { "name": "nette/finder", - "version": "v2.4.2", + "version": "v2.5.0", "source": { "type": "git", "url": "https://github.com/nette/finder.git", - "reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0" + "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/finder/zipball/ee951a656cb8ac622e5dd33474a01fd2470505a0", - "reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0", + "url": "https://api.github.com/repos/nette/finder/zipball/6be1b83ea68ac558aff189d640abe242e0306fe2", + "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2", "shasum": "" }, "require": { - "nette/utils": "~2.4", - "php": ">=5.6.0" + "nette/utils": "^2.4 || ~3.0.0", + "php": ">=7.1" }, "conflict": { "nette/nette": "<2.2" }, "require-dev": { - "nette/tester": "~2.0", + "nette/tester": "^2.0", "tracy/tracy": "^2.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -665,7 +668,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🔍 Nette Finder: find files and directories with an intuitive API.", + "description": "? Nette Finder: find files and directories with an intuitive API.", "homepage": "https://nette.org", "keywords": [ "filesystem", @@ -673,35 +676,35 @@ "iterator", "nette" ], - "time": "2018-06-28T11:49:23+00:00" + "time": "2019-02-28T18:13:25+00:00" }, { "name": "nette/neon", - "version": "v2.4.3", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/nette/neon.git", - "reference": "5e72b1dd3e2d34f0863c5561139a19df6a1ef398" + "reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/neon/zipball/5e72b1dd3e2d34f0863c5561139a19df6a1ef398", - "reference": "5e72b1dd3e2d34f0863c5561139a19df6a1ef398", + "url": "https://api.github.com/repos/nette/neon/zipball/cbff32059cbdd8720deccf9e9eace6ee516f02eb", + "reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb", "shasum": "" }, "require": { "ext-iconv": "*", "ext-json": "*", - "php": ">=5.6.0" + "php": ">=7.0" }, "require-dev": { - "nette/tester": "~2.0", + "nette/tester": "^2.0", "tracy/tracy": "^2.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -725,7 +728,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🍸 Nette NEON: encodes and decodes NEON file format.", + "description": "? Nette NEON: encodes and decodes NEON file format.", "homepage": "http://ne-on.org", "keywords": [ "export", @@ -734,28 +737,25 @@ "nette", "yaml" ], - "time": "2018-03-21T12:12:21+00:00" + "time": "2019-02-05T21:30:40+00:00" }, { "name": "nette/php-generator", - "version": "v3.0.5", + "version": "v3.2.2", "source": { "type": "git", "url": "https://github.com/nette/php-generator.git", - "reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff" + "reference": "acff8b136fad84b860a626d133e791f95781f9f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/php-generator/zipball/ea90209c2e8a7cd087b2742ca553c047a8df5eff", - "reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff", + "url": "https://api.github.com/repos/nette/php-generator/zipball/acff8b136fad84b860a626d133e791f95781f9f5", + "reference": "acff8b136fad84b860a626d133e791f95781f9f5", "shasum": "" }, "require": { "nette/utils": "^2.4.2 || ~3.0.0", - "php": ">=7.0" - }, - "conflict": { - "nette/nette": "<2.2" + "php": ">=7.1" }, "require-dev": { "nette/tester": "^2.0", @@ -764,7 +764,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -788,7 +788,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.2 features.", + "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.3 features.", "homepage": "https://nette.org", "keywords": [ "code", @@ -796,30 +796,27 @@ "php", "scaffolding" ], - "time": "2018-08-09T14:32:27+00:00" + "time": "2019-03-15T03:41:13+00:00" }, { "name": "nette/robot-loader", - "version": "v3.1.0", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/nette/robot-loader.git", - "reference": "fc76c70e740b10f091e502b2e393d0be912f38d4" + "reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/robot-loader/zipball/fc76c70e740b10f091e502b2e393d0be912f38d4", - "reference": "fc76c70e740b10f091e502b2e393d0be912f38d4", + "url": "https://api.github.com/repos/nette/robot-loader/zipball/0712a0e39ae7956d6a94c0ab6ad41aa842544b5c", + "reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c", "shasum": "" }, "require": { "ext-tokenizer": "*", - "nette/finder": "^2.3 || ^3.0", - "nette/utils": "^2.4 || ^3.0", - "php": ">=5.6.0" - }, - "conflict": { - "nette/nette": "<2.2" + "nette/finder": "^2.5", + "nette/utils": "^3.0", + "php": ">=7.1" }, "require-dev": { "nette/tester": "^2.0", @@ -828,7 +825,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -852,7 +849,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.", + "description": "? Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.", "homepage": "https://nette.org", "keywords": [ "autoload", @@ -861,27 +858,81 @@ "nette", "trait" ], - "time": "2018-08-13T14:19:06+00:00" + "time": "2019-03-08T21:57:24+00:00" + }, + { + "name": "nette/schema", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/nette/schema.git", + "reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/schema/zipball/6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d", + "reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d", + "shasum": "" + }, + "require": { + "nette/utils": "^3.0.1", + "php": ">=7.1" + }, + "require-dev": { + "nette/tester": "^2.2", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "📐 Nette Schema: validating data structures against a given Schema.", + "homepage": "https://nette.org", + "keywords": [ + "config", + "nette" + ], + "time": "2019-04-03T15:53:25+00:00" }, { "name": "nette/utils", - "version": "v2.5.3", + "version": "v3.0.1", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce" + "reference": "bd961f49b211997202bda1d0fbc410905be370d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/17b9f76f2abd0c943adfb556e56f2165460b15ce", - "reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce", + "url": "https://api.github.com/repos/nette/utils/zipball/bd961f49b211997202bda1d0fbc410905be370d4", + "reference": "bd961f49b211997202bda1d0fbc410905be370d4", "shasum": "" }, "require": { - "php": ">=5.6.0" - }, - "conflict": { - "nette/nette": "<2.2" + "php": ">=7.1" }, "require-dev": { "nette/tester": "~2.0", @@ -890,7 +941,7 @@ "suggest": { "ext-gd": "to use Image", "ext-iconv": "to use Strings::webalize() and toAscii()", - "ext-intl": "for script transliteration in Strings::webalize() and toAscii()", + "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", "ext-json": "to use Nette\\Utils\\Json", "ext-mbstring": "to use Strings::lower() etc...", "ext-xml": "to use Strings::length() etc. when mbstring is not available" @@ -898,15 +949,12 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "3.0-dev" } }, "autoload": { "classmap": [ "src/" - ], - "files": [ - "src/loader.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -943,20 +991,20 @@ "utility", "validation" ], - "time": "2018-09-18T10:22:16+00:00" + "time": "2019-03-22T01:00:30+00:00" }, { "name": "nikic/php-parser", - "version": "v4.1.0", + "version": "v4.2.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "d0230c5c77a7e3cfa69446febf340978540958c0" + "reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/d0230c5c77a7e3cfa69446febf340978540958c0", - "reference": "d0230c5c77a7e3cfa69446febf340978540958c0", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bd73cc04c3843ad8d6b0bfc0956026a151fc420", + "reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420", "shasum": "" }, "require": { @@ -972,7 +1020,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -994,20 +1042,20 @@ "parser", "php" ], - "time": "2018-10-10T09:24:14+00:00" + "time": "2019-05-25T20:07:01+00:00" }, { "name": "ocramius/package-versions", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/Ocramius/PackageVersions.git", - "reference": "4489d5002c49d55576fa0ba786f42dbb009be46f" + "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/4489d5002c49d55576fa0ba786f42dbb009be46f", - "reference": "4489d5002c49d55576fa0ba786f42dbb009be46f", + "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", + "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", "shasum": "" }, "require": { @@ -1016,6 +1064,7 @@ }, "require-dev": { "composer/composer": "^1.6.3", + "doctrine/coding-standard": "^5.0.1", "ext-zip": "*", "infection/infection": "^0.7.1", "phpunit/phpunit": "^7.0.0" @@ -1043,7 +1092,7 @@ } ], "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", - "time": "2018-02-05T13:05:30+00:00" + "time": "2019-02-21T12:16:21+00:00" }, { "name": "phar-io/manifest", @@ -1203,16 +1252,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.0", + "version": "4.3.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08" + "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", + "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", "shasum": "" }, "require": { @@ -1250,7 +1299,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-11-30T07:14:17+00:00" + "time": "2019-04-30T17:48:53+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -1301,16 +1350,16 @@ }, { "name": "phpspec/prophecy", - "version": "1.8.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" + "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76", + "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76", "shasum": "" }, "require": { @@ -1331,8 +1380,8 @@ } }, "autoload": { - "psr-0": { - "Prophecy\\": "src/" + "psr-4": { + "Prophecy\\": "src/Prophecy" } }, "notification-url": "https://packagist.org/downloads/", @@ -1360,32 +1409,33 @@ "spy", "stub" ], - "time": "2018-08-05T17:53:17+00:00" + "time": "2019-06-13T12:50:23+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "0.3", + "version": "0.3.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "ed3223362174b8067729930439e139794e9e514a" + "reference": "8c4ef2aefd9788238897b678a985e1d5c8df6db4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/ed3223362174b8067729930439e139794e9e514a", - "reference": "ed3223362174b8067729930439e139794e9e514a", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/8c4ef2aefd9788238897b678a985e1d5c8df6db4", + "reference": "8c4ef2aefd9788238897b678a985e1d5c8df6db4", "shasum": "" }, "require": { "php": "~7.1" }, "require-dev": { - "consistence/coding-standard": "^2.0.0", + "consistence/coding-standard": "^3.5", "jakub-onderka/php-parallel-lint": "^0.9.2", "phing/phing": "^2.16.0", - "phpstan/phpstan": "^0.10@dev", + "phpstan/phpstan": "^0.10", "phpunit/phpunit": "^6.3", - "slevomat/coding-standard": "^3.3.0", + "slevomat/coding-standard": "^4.7.2", + "squizlabs/php_codesniffer": "^3.3.2", "symfony/process": "^3.4 || ^4.0" }, "type": "library", @@ -1406,20 +1456,20 @@ "MIT" ], "description": "PHPDoc parser with support for nullable, intersection and generic types", - "time": "2018-06-20T17:48:01+00:00" + "time": "2019-06-07T19:13:52+00:00" }, { "name": "phpstan/phpstan", - "version": "0.10.5", + "version": "0.10.8", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "c6a8cd1fe08a23b9d101a55ffa9ff6b91d71ef5d" + "reference": "4f828460a0276180da76c670a0a6e592e7c38b71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c6a8cd1fe08a23b9d101a55ffa9ff6b91d71ef5d", - "reference": "c6a8cd1fe08a23b9d101a55ffa9ff6b91d71ef5d", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/4f828460a0276180da76c670a0a6e592e7c38b71", + "reference": "4f828460a0276180da76c670a0a6e592e7c38b71", "shasum": "" }, "require": { @@ -1435,6 +1485,9 @@ "symfony/console": "~3.2 || ~4.0", "symfony/finder": "~3.2 || ~4.0" }, + "conflict": { + "symfony/console": "3.4.16 || 4.1.5" + }, "require-dev": { "brianium/paratest": "^2.0", "consistence/coding-standard": "^3.5", @@ -1451,7 +1504,8 @@ "phpstan/phpstan-phpunit": "^0.10", "phpstan/phpstan-strict-rules": "^0.10", "phpunit/phpunit": "^7.0", - "slevomat/coding-standard": "^4.7.2" + "slevomat/coding-standard": "^4.7.2", + "squizlabs/php_codesniffer": "^3.3.2" }, "bin": [ "bin/phpstan" @@ -1475,7 +1529,7 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", - "time": "2018-10-20T17:24:55+00:00" + "time": "2019-01-08T09:51:19+00:00" }, { "name": "phpstan/phpstan-doctrine", @@ -1534,16 +1588,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "6.1.3", + "version": "6.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "4d3ae9b21a7d7e440bd0cf65565533117976859f" + "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/4d3ae9b21a7d7e440bd0cf65565533117976859f", - "reference": "4d3ae9b21a7d7e440bd0cf65565533117976859f", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", + "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", "shasum": "" }, "require": { @@ -1593,7 +1647,7 @@ "testing", "xunit" ], - "time": "2018-10-23T05:59:32+00:00" + "time": "2018-10-31T16:06:48+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1688,16 +1742,16 @@ }, { "name": "phpunit/php-timer", - "version": "2.0.0", + "version": "2.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f" + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b8454ea6958c3dee38453d3bd571e023108c91f", - "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", "shasum": "" }, "require": { @@ -1709,7 +1763,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -1733,7 +1787,7 @@ "keywords": [ "timer" ], - "time": "2018-02-01T13:07:23+00:00" + "time": "2019-06-07T04:22:29+00:00" }, { "name": "phpunit/php-token-stream", @@ -1786,16 +1840,16 @@ }, { "name": "phpunit/phpunit", - "version": "7.4.3", + "version": "7.5.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c151651fb6ed264038d486ea262e243af72e5e64" + "reference": "9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c151651fb6ed264038d486ea262e243af72e5e64", - "reference": "c151651fb6ed264038d486ea262e243af72e5e64", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c", + "reference": "9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c", "shasum": "" }, "require": { @@ -1813,10 +1867,10 @@ "phpunit/php-code-coverage": "^6.0.7", "phpunit/php-file-iterator": "^2.0.1", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.0", + "phpunit/php-timer": "^2.1", "sebastian/comparator": "^3.0", "sebastian/diff": "^3.0", - "sebastian/environment": "^3.1 || ^4.0", + "sebastian/environment": "^4.0", "sebastian/exporter": "^3.1", "sebastian/global-state": "^2.0", "sebastian/object-enumerator": "^3.0.3", @@ -1840,7 +1894,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.4-dev" + "dev-master": "7.5-dev" } }, "autoload": { @@ -1866,20 +1920,20 @@ "testing", "xunit" ], - "time": "2018-10-23T05:57:41+00:00" + "time": "2019-05-28T11:59:40+00:00" }, { "name": "psr/log", - "version": "1.0.2", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", "shasum": "" }, "require": { @@ -1913,7 +1967,7 @@ "psr", "psr-3" ], - "time": "2016-10-10T12:19:37+00:00" + "time": "2018-11-20T15:27:04+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -2026,23 +2080,23 @@ }, { "name": "sebastian/diff", - "version": "3.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "366541b989927187c4ca70490a35615d3fef2dce" + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/366541b989927187c4ca70490a35615d3fef2dce", - "reference": "366541b989927187c4ca70490a35615d3fef2dce", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", "shasum": "" }, "require": { "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^7.0", + "phpunit/phpunit": "^7.5 || ^8.0", "symfony/process": "^2 || ^3.3 || ^4" }, "type": "library", @@ -2078,32 +2132,35 @@ "unidiff", "unified diff" ], - "time": "2018-06-10T07:54:39+00:00" + "time": "2019-02-04T06:01:07+00:00" }, { "name": "sebastian/environment", - "version": "3.1.0", + "version": "4.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" + "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/f2a2c8e1c97c11ace607a7a667d73d47c19fe404", + "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^6.1" + "phpunit/phpunit": "^7.5" + }, + "suggest": { + "ext-posix": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -2128,7 +2185,7 @@ "environment", "hhvm" ], - "time": "2017-07-01T08:51:00+00:00" + "time": "2019-05-05T09:05:15+00:00" }, { "name": "sebastian/exporter", @@ -2480,36 +2537,43 @@ }, { "name": "symfony/console", - "version": "v4.1.7", + "version": "v4.3.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "432122af37d8cd52fba1b294b11976e0d20df595" + "reference": "d50bbeeb0e17e6dd4124ea391eff235e932cbf64" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/432122af37d8cd52fba1b294b11976e0d20df595", - "reference": "432122af37d8cd52fba1b294b11976e0d20df595", + "url": "https://api.github.com/repos/symfony/console/zipball/d50bbeeb0e17e6dd4124ea391eff235e932cbf64", + "reference": "d50bbeeb0e17e6dd4124ea391eff235e932cbf64", "shasum": "" }, "require": { "php": "^7.1.3", - "symfony/polyfill-mbstring": "~1.0" + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.8", + "symfony/service-contracts": "^1.1" }, "conflict": { "symfony/dependency-injection": "<3.4", + "symfony/event-dispatcher": "<4.3", "symfony/process": "<3.3" }, + "provide": { + "psr/log-implementation": "1.0" + }, "require-dev": { "psr/log": "~1.0", "symfony/config": "~3.4|~4.0", "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "~3.4|~4.0", + "symfony/event-dispatcher": "^4.3", "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.4|~4.0" + "symfony/process": "~3.4|~4.0", + "symfony/var-dumper": "^4.3" }, "suggest": { - "psr/log-implementation": "For using the console logger", + "psr/log": "For using the console logger", "symfony/event-dispatcher": "", "symfony/lock": "", "symfony/process": "" @@ -2517,7 +2581,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "4.3-dev" } }, "autoload": { @@ -2544,20 +2608,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-10-31T09:30:44+00:00" + "time": "2019-06-05T13:25:51+00:00" }, { "name": "symfony/finder", - "version": "v4.1.7", + "version": "v4.3.1", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "1f17195b44543017a9c9b2d437c670627e96ad06" + "reference": "b3d4f4c0e4eadfdd8b296af9ca637cfbf51d8176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/1f17195b44543017a9c9b2d437c670627e96ad06", - "reference": "1f17195b44543017a9c9b2d437c670627e96ad06", + "url": "https://api.github.com/repos/symfony/finder/zipball/b3d4f4c0e4eadfdd8b296af9ca637cfbf51d8176", + "reference": "b3d4f4c0e4eadfdd8b296af9ca637cfbf51d8176", "shasum": "" }, "require": { @@ -2566,7 +2630,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "4.3-dev" } }, "autoload": { @@ -2593,20 +2657,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2018-10-03T08:47:56+00:00" + "time": "2019-05-26T20:47:49+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "c79c051f5b3a46be09205c73b80b346e4153e494" + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", - "reference": "c79c051f5b3a46be09205c73b80b346e4153e494", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", "shasum": "" }, "require": { @@ -2618,7 +2682,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -2652,20 +2716,136 @@ "portable", "shim" ], - "time": "2018-09-21T13:07:52+00:00" + "time": "2019-02-06T07:57:58+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", + "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2019-02-06T07:57:58+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v1.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/191afdcb5804db960d26d8566b7e9a2843cab3a0", + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "suggest": { + "psr/container": "", + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2019-05-28T07:50:59+00:00" }, { "name": "theseer/tokenizer", - "version": "1.1.0", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", - "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", "shasum": "" }, "require": { @@ -2692,24 +2872,25 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2017-04-07T12:08:54+00:00" + "time": "2019-06-13T22:48:21+00:00" }, { "name": "webmozart/assert", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" }, "require-dev": { "phpunit/phpunit": "^4.6", @@ -2742,7 +2923,7 @@ "check", "validate" ], - "time": "2018-01-29T19:49:41+00:00" + "time": "2018-12-25T11:19:39+00:00" } ], "aliases": [], From 08892e1b7082723840f52c0d58b6b0c196d87d2b Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Mon, 1 Jul 2019 11:19:25 +0200 Subject: [PATCH 59/75] play is not available in ddd branch yet. --- Makefile | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 972d0e9..e89d29c 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ else CMD := docker-compose exec php endif -all: container-up clear lint-composer lint-php composer phpcs tests +all: container-up clear composer lint-composer lint-php phpcs tests lint-composer: @echo "\n==> Validating composer.json and composer.lock:" diff --git a/README.md b/README.md index 69efa50..b980276 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Run `make all` will do all the magic for you. ### Start playing -To start playing the game, you need to run `make play` +TODO, refactoring has to be finished first. ### Unit tests From b1b8de6843d8265306258e291f0cfc0adb42306b Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 10 Jul 2019 19:12:33 +0200 Subject: [PATCH 60/75] more verbosity in Makefile --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index e89d29c..031fb6a 100644 --- a/Makefile +++ b/Makefile @@ -27,12 +27,14 @@ clear: $(CMD) rm -rf bin/php* phpcs: + @echo "\n==> Checking style guidelines" $(CMD) bin/phpcs --standard=phpcs.xml -p phpcbf: $(CMD) bin/phpcbf coverage: + @echo "\n==> Generating coverage report" $(CMD) bin/phpunit --coverage-html coverage tests: From 45c158b0226bee33ac7a1a36983e388855c3d59e Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 22 Oct 2019 16:46:08 +0200 Subject: [PATCH 61/75] make cell accept string and not playertoken. --- src/TicTacToe/Engine/Domain/Model/Board/Cell.php | 9 +++++++-- .../unit/Engine/Domain/Model/Board/CellTest.php | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/TicTacToe/Engine/Domain/Model/Board/Cell.php b/src/TicTacToe/Engine/Domain/Model/Board/Cell.php index 5d19423..dffe4cc 100644 --- a/src/TicTacToe/Engine/Domain/Model/Board/Cell.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Cell.php @@ -8,10 +8,10 @@ final class Cell { - /** @var PlayerToken|null */ + /** @var string */ private $value; - public function __construct(?PlayerToken $value = null) + public function __construct(string $value = '') { $this->value = $value; } @@ -25,4 +25,9 @@ public static function empty(): Cell { return new Cell(); } + + public static function createFromPlayerToken(PlayerToken $playerToken): Cell + { + return new Cell((string) $playerToken); + } } diff --git a/tests/unit/Engine/Domain/Model/Board/CellTest.php b/tests/unit/Engine/Domain/Model/Board/CellTest.php index 31a0420..dccc5d2 100644 --- a/tests/unit/Engine/Domain/Model/Board/CellTest.php +++ b/tests/unit/Engine/Domain/Model/Board/CellTest.php @@ -12,7 +12,21 @@ class CellTest extends TestCase { public function testCellCreatedSuccessfully() { - $cell = new Cell(PlayerToken::createGameTokenX()); + $cell = new Cell('x'); + self::assertEquals('x', (string) $cell); + } + + public function testItCanCreateEmptyCell() + { + $cell = Cell::empty(); + self::assertEquals('', (string) $cell); + } + + public function testItCanCreateCellFromPlayerToken() + { + $playerToken = PlayerToken::createGameTokenX(); + + $cell = Cell::createFromPlayerToken($playerToken); self::assertEquals('x', (string) $cell); } } From 071916565bf4252df72717564825398c3ef80d50 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 23 Oct 2019 11:01:55 +0200 Subject: [PATCH 62/75] add move and position. --- .../Engine/Domain/Model/Board/Board.php | 2 +- .../Board/Exception/SorryInvalidPosition.php | 8 +++ .../Engine/Domain/Model/Board/Position.php | 30 ++++++++++ .../Engine/Domain/Model/Game/Game.php | 1 - .../Engine/Domain/Model/Game/Move.php | 55 +++++++++++++++++++ .../Engine/Domain/Model/Game/MoveId.php | 27 +++++++++ 6 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 src/TicTacToe/Engine/Domain/Model/Board/Exception/SorryInvalidPosition.php create mode 100644 src/TicTacToe/Engine/Domain/Model/Board/Position.php create mode 100644 src/TicTacToe/Engine/Domain/Model/Game/Move.php create mode 100644 src/TicTacToe/Engine/Domain/Model/Game/MoveId.php diff --git a/src/TicTacToe/Engine/Domain/Model/Board/Board.php b/src/TicTacToe/Engine/Domain/Model/Board/Board.php index 1020e2d..391a5ff 100644 --- a/src/TicTacToe/Engine/Domain/Model/Board/Board.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Board.php @@ -19,7 +19,7 @@ final class Board public function __construct(int $size) { if ($size != self::BOARD_SIZE_3) { - throw new SorryBoardSizeIsNotValid("Only allowed size for now is: " . self::BOARD_SIZE_3); + throw new SorryBoardSizeIsNotValid("Only allowed size for board is: " . self::BOARD_SIZE_3); } $this->size = $size; diff --git a/src/TicTacToe/Engine/Domain/Model/Board/Exception/SorryInvalidPosition.php b/src/TicTacToe/Engine/Domain/Model/Board/Exception/SorryInvalidPosition.php new file mode 100644 index 0000000..14a2fb1 --- /dev/null +++ b/src/TicTacToe/Engine/Domain/Model/Board/Exception/SorryInvalidPosition.php @@ -0,0 +1,8 @@ +position = $position; + } + + public function position(): int + { + return $this->position; + } +} diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Game.php b/src/TicTacToe/Engine/Domain/Model/Game/Game.php index 8a1cde6..66b263f 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/Game.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Game.php @@ -7,7 +7,6 @@ use TicTacToe\Engine\Domain\Model\Board\Board; use TicTacToe\Engine\Domain\Model\Game\Event\GameCreated; use TicTacToe\Engine\Domain\Model\Game\Exception\SorryTooManyPlayers; -use TicTacToe\Engine\Domain\Model\Player\Player; use TicTacToe\Engine\Domain\Model\Player\PlayerId; use TicTacToe\Engine\Domain\Model\Player\PlayerIdSet; use TicTacToe\Shared\Domain\Model\AggregateRoot; diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Move.php b/src/TicTacToe/Engine/Domain/Model/Game/Move.php new file mode 100644 index 0000000..54afe74 --- /dev/null +++ b/src/TicTacToe/Engine/Domain/Model/Game/Move.php @@ -0,0 +1,55 @@ +moveId = $moveId; + $this->cell = $cell; + $this->madeBy = $madeBy; + $this->position = $position; + } + + public function moveId(): MoveId + { + return $this->moveId; + } + + public function madeBy(): Player + { + return $this->madeBy; + } + + public function cell(): Cell + { + return $this->cell; + } + + public function position(): Position + { + return $this->position; + } +} diff --git a/src/TicTacToe/Engine/Domain/Model/Game/MoveId.php b/src/TicTacToe/Engine/Domain/Model/Game/MoveId.php new file mode 100644 index 0000000..1996821 --- /dev/null +++ b/src/TicTacToe/Engine/Domain/Model/Game/MoveId.php @@ -0,0 +1,27 @@ +id = null === $id ? Uuid::uuid4()->toString() : $id; + } + + public function equals(MoveId $moveId) + { + return $this->id === (string)$moveId; + } + + public function __toString(): string + { + return $this->id; + } +} From 795b937f6509f504271d017696482c5e5afa07f8 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 24 Oct 2019 11:32:39 +0200 Subject: [PATCH 63/75] add player turn --- .../CreateNewPlayerResponseDto.php | 2 +- .../PlayNewTurn/PlayNewTurnCommand.php | 43 ++++++++++ .../PlayNewTurn/PlayNewTurnHandler.php | 85 +++++++++++++++++++ .../Engine/Domain/Model/Board/Board.php | 23 ++++- .../Engine/Domain/Model/Board/Cell.php | 5 ++ .../Engine/Domain/Model/Board/CellSet.php | 36 ++++++++ .../Engine/Domain/Model/Board/Position.php | 20 ++++- .../Domain/Model/Game/Event/GameCreated.php | 12 +-- .../Model/Game/Event/PlayerTurnPlayed.php | 47 ++++++++++ .../Game/Exception/SorryGameNotFound.php | 8 ++ .../Engine/Domain/Model/Game/Game.php | 10 +++ .../Domain/Model/Game/{Move.php => Turn.php} | 20 ++++- .../Model/Game/{MoveId.php => TurnId.php} | 4 +- .../Domain/Model/Game/TurnRepository.php | 28 ++++++ .../Player/Exception/SorryPlayerNotFound.php | 8 ++ .../Engine/Domain/Model/Player/Player.php | 4 +- .../CreateNewPlayerHandlerTest.php | 2 +- 17 files changed, 330 insertions(+), 27 deletions(-) create mode 100644 src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnCommand.php create mode 100644 src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php create mode 100644 src/TicTacToe/Engine/Domain/Model/Board/CellSet.php create mode 100644 src/TicTacToe/Engine/Domain/Model/Game/Event/PlayerTurnPlayed.php create mode 100644 src/TicTacToe/Engine/Domain/Model/Game/Exception/SorryGameNotFound.php rename src/TicTacToe/Engine/Domain/Model/Game/{Move.php => Turn.php} (73%) rename src/TicTacToe/Engine/Domain/Model/Game/{MoveId.php => TurnId.php} (87%) create mode 100644 src/TicTacToe/Engine/Domain/Model/Game/TurnRepository.php create mode 100644 src/TicTacToe/Engine/Domain/Model/Player/Exception/SorryPlayerNotFound.php diff --git a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerResponseDto.php b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerResponseDto.php index d703391..881ecd2 100644 --- a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerResponseDto.php +++ b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerResponseDto.php @@ -24,7 +24,7 @@ final class CreateNewPlayerResponseDto implements DataTransformer public function __construct(Player $player) { $this->playerId = (string) $player->id(); - $this->playerToken = $player->playingToken(); + $this->playerToken = (string) $player->playingToken(); $this->playerName = $player->name(); $this->createdAt = $player->createdAt(); } diff --git a/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnCommand.php b/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnCommand.php new file mode 100644 index 0000000..a138ed2 --- /dev/null +++ b/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnCommand.php @@ -0,0 +1,43 @@ +playerId = $playerId; + $this->position = $position; + $this->gameId = $gameId; + } + + public function gameId(): string + { + return $this->gameId; + } + + public function playerId(): string + { + return $this->playerId; + } + + public function position(): int + { + return $this->position; + } +} diff --git a/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php b/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php new file mode 100644 index 0000000..de477ee --- /dev/null +++ b/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php @@ -0,0 +1,85 @@ +turnRepository = $turnRepository; + $this->playerRepository = $playerRepository; + $this->gameRepository = $gameRepository; + } + + /** + * @inheritDoc + */ + public function handles(): string + { + return PlayNewTurnCommand::class; + } + + /** + * @inheritDoc + */ + public function handle(Command $command): DataTransformer + { + if (!$command instanceof PlayNewTurnCommand) { + throw new SorryWrongCommand(); + } + + $playerId = $command->playerId(); + $player = $this->playerRepository->ofId(new PlayerId($playerId)); + if ($player === null) { + throw new SorryPlayerNotFound("Player of Id {$playerId} not found."); + } + + $gameId = $command->gameId(); + $game = $this->gameRepository->ofId(new GameId($gameId)); + if ($game === null) { + throw new SorryGameNotFound("Game of Id {$gameId} not found."); + } + + $turn = new Turn( + new TurnId(), + Cell::createFromPlayerToken($player->playingToken()), + new Position($command->position()), + $player + ); + + $game->playerMakeTurn( + $turn + ); + + $this->turnRepository->add($turn); + } +} diff --git a/src/TicTacToe/Engine/Domain/Model/Board/Board.php b/src/TicTacToe/Engine/Domain/Model/Board/Board.php index 391a5ff..42cad71 100644 --- a/src/TicTacToe/Engine/Domain/Model/Board/Board.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Board.php @@ -10,7 +10,7 @@ final class Board { private const BOARD_SIZE_3 = 3; - /** @var [][] */ + /** @var CellSet */ private $cellSet; /** @var int */ @@ -33,11 +33,26 @@ public function size(): int private function initBoard() { - foreach (range(0, $this->size - 1) as $row) { - foreach (range(0, $this->size - 1) as $col) { - $this->cellSet[$row][$col] = Cell::empty(); + foreach (Position::positions() as $position) { + $this->cellSet[$position] = Cell::empty(); + } + } + + public function isFull(): bool + { + /** @var Cell $cell */ + foreach ($this->cellSet as $cell) { + if ($cell->isEmpty()) { + return false; } } + + return true; + } + + public function setCell(Position $position, Cell $cell): Board + { + $this->cellSet[$position->position()] = $cell; } public static function create3By3Board(): Board diff --git a/src/TicTacToe/Engine/Domain/Model/Board/Cell.php b/src/TicTacToe/Engine/Domain/Model/Board/Cell.php index dffe4cc..1cf7324 100644 --- a/src/TicTacToe/Engine/Domain/Model/Board/Cell.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Cell.php @@ -21,6 +21,11 @@ public function __toString(): string return (string) $this->value; } + public function isEmpty(): bool + { + return empty($this->value); + } + public static function empty(): Cell { return new Cell(); diff --git a/src/TicTacToe/Engine/Domain/Model/Board/CellSet.php b/src/TicTacToe/Engine/Domain/Model/Board/CellSet.php new file mode 100644 index 0000000..ea4e1ee --- /dev/null +++ b/src/TicTacToe/Engine/Domain/Model/Board/CellSet.php @@ -0,0 +1,36 @@ +cells = $cells; + } + + public function toArray(): array + { + return $this->cells; + } + + public function getIterator() + { + return new \ArrayIterator($this->toArray()); + } + + public function count() + { + return count($this->cells); + } +} diff --git a/src/TicTacToe/Engine/Domain/Model/Board/Position.php b/src/TicTacToe/Engine/Domain/Model/Board/Position.php index cbbeb2f..0041c2c 100644 --- a/src/TicTacToe/Engine/Domain/Model/Board/Position.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Position.php @@ -7,7 +7,7 @@ final class Position { - public const Valid_Positions = [ + private const VALID_POSITIONS = [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]; @@ -16,9 +16,7 @@ final class Position public function __construct(int $position) { - if (!in_array($position, self::Valid_Positions, true)) { - throw new SorryInvalidPosition('Out of boundary position.'); - } + self::isValid($position); $this->position = $position; } @@ -27,4 +25,18 @@ public function position(): int { return $this->position; } + + public static function positions(): array + { + return self::VALID_POSITIONS; + } + + public static function isValid(int $position): bool + { + if (!in_array($position, self::VALID_POSITIONS, true)) { + throw new SorryInvalidPosition('Out of boundary position.'); + } + + return true; + } } diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php b/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php index 6cfa1e4..83ea37e 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php @@ -18,9 +18,7 @@ public function __construct(Game $game) } /** - * Return event timestamp - * - * @return \DateTimeImmutable + * @inheritDoc */ public function occurredAt(): \DateTimeImmutable { @@ -28,9 +26,7 @@ public function occurredAt(): \DateTimeImmutable } /** - * Return event data as array - * - * @return array + * @inheritDoc */ public function toArray(): array { @@ -41,9 +37,7 @@ public function toArray(): array } /** - * Get event name - * - * @return string + * @inheritDoc */ public function name(): string { diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Event/PlayerTurnPlayed.php b/src/TicTacToe/Engine/Domain/Model/Game/Event/PlayerTurnPlayed.php new file mode 100644 index 0000000..841a525 --- /dev/null +++ b/src/TicTacToe/Engine/Domain/Model/Game/Event/PlayerTurnPlayed.php @@ -0,0 +1,47 @@ +turn = $turn; + } + + /** + * @inheritDoc + */ + public function occurredAt(): \DateTimeImmutable + { + return $this->turn->createdAt(); + } + + /** + * @inheritDoc + */ + public function toArray(): array + { + return [ + 'turnId' => (string) $this->turn->moveId(), + 'madeBy' => (string) $this->turn->madeBy()->id(), + 'position' => $this->turn->position()->position(), + 'createdAt' => $this->turn->createdAt()->format(\DateTimeImmutable::ATOM) + ]; + } + + /** + * @inheritDoc + */ + public function name(): string + { + return PlayerTurnPlayed::class; + } +} diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Exception/SorryGameNotFound.php b/src/TicTacToe/Engine/Domain/Model/Game/Exception/SorryGameNotFound.php new file mode 100644 index 0000000..8e40a01 --- /dev/null +++ b/src/TicTacToe/Engine/Domain/Model/Game/Exception/SorryGameNotFound.php @@ -0,0 +1,8 @@ +board = $this->board->setCell($turn->position(), $turn->cell()); + + $this->record( + new PlayerTurnPlayed($turn) + ); + } + public function id(): GameId { return $this->id; diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Move.php b/src/TicTacToe/Engine/Domain/Model/Game/Turn.php similarity index 73% rename from src/TicTacToe/Engine/Domain/Model/Game/Move.php rename to src/TicTacToe/Engine/Domain/Model/Game/Turn.php index 54afe74..c0ceb7a 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/Move.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Turn.php @@ -7,9 +7,12 @@ use TicTacToe\Engine\Domain\Model\Board\Position; use TicTacToe\Engine\Domain\Model\Player\Player; -final class Move +final class Turn { - /** @var MoveId */ + + private $gameId; + + /** @var TurnId */ private $moveId; /** @var Cell */ @@ -21,8 +24,11 @@ final class Move /** @var Position */ private $position; + /** @var \DateTimeImmutable */ + private $createdAt; + public function __construct( - MoveId $moveId, + TurnId $moveId, Cell $cell, Position $position, Player $madeBy @@ -31,9 +37,10 @@ public function __construct( $this->cell = $cell; $this->madeBy = $madeBy; $this->position = $position; + $this->createdAt = new \DateTimeImmutable(); } - public function moveId(): MoveId + public function moveId(): TurnId { return $this->moveId; } @@ -52,4 +59,9 @@ public function position(): Position { return $this->position; } + + public function createdAt(): \DateTimeImmutable + { + return $this->createdAt; + } } diff --git a/src/TicTacToe/Engine/Domain/Model/Game/MoveId.php b/src/TicTacToe/Engine/Domain/Model/Game/TurnId.php similarity index 87% rename from src/TicTacToe/Engine/Domain/Model/Game/MoveId.php rename to src/TicTacToe/Engine/Domain/Model/Game/TurnId.php index 1996821..fac4fc8 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/MoveId.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/TurnId.php @@ -5,7 +5,7 @@ use Ramsey\Uuid\Uuid; -final class MoveId +final class TurnId { /** @var string */ private $id; @@ -15,7 +15,7 @@ public function __construct(?string $id = null) $this->id = null === $id ? Uuid::uuid4()->toString() : $id; } - public function equals(MoveId $moveId) + public function equals(TurnId $moveId) { return $this->id === (string)$moveId; } diff --git a/src/TicTacToe/Engine/Domain/Model/Game/TurnRepository.php b/src/TicTacToe/Engine/Domain/Model/Game/TurnRepository.php new file mode 100644 index 0000000..a3dbaaa --- /dev/null +++ b/src/TicTacToe/Engine/Domain/Model/Game/TurnRepository.php @@ -0,0 +1,28 @@ +name; } - public function playingToken(): string + public function playingToken(): PlayerToken { - return (string) $this->playingToken; + return $this->playingToken; } public function id(): PlayerId diff --git a/tests/unit/Engine/Application/CreateNewPlayer/CreateNewPlayerHandlerTest.php b/tests/unit/Engine/Application/CreateNewPlayer/CreateNewPlayerHandlerTest.php index b8ee908..ef9a990 100644 --- a/tests/unit/Engine/Application/CreateNewPlayer/CreateNewPlayerHandlerTest.php +++ b/tests/unit/Engine/Application/CreateNewPlayer/CreateNewPlayerHandlerTest.php @@ -42,7 +42,7 @@ public function testItCanCreateANewPlayer() $playerDto = $this->handler->handle($command); $retreivedPlayer = $this->playerRepository->ofId(new PlayerId($playerDto->playerId())); self::assertEquals($retreivedPlayer->name(), $playerDto->playerName()); - self::assertEquals($retreivedPlayer->playingToken(), $playerDto->playerToken()); + self::assertEquals((string) $retreivedPlayer->playingToken(), $playerDto->playerToken()); } public function testItThrowsSorryWrongCommandWhenWrongCommandPassed() From 71014f7b8916491e16e958f8501199b531763820 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Fri, 13 Mar 2020 15:32:33 +0100 Subject: [PATCH 64/75] use php alpine for lighter image. --- .travis.yml | 2 +- Makefile | 15 +++++++++++---- docker-compose.yml | 8 ++++---- docker/php-cli/Dockerfile | 31 ++++++++++++++++++++----------- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index b1e92c0..f177986 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,5 @@ env: - RUNNER=travis language: php php: - - '7.2' + - '7.4' install: make clear lint-composer lint-php composer phpcs tests diff --git a/Makefile b/Makefile index 031fb6a..499a7c3 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,14 @@ COMPOSER ?= composer DOCKER_COMPOSE = docker-compose PROJECT = "TicTacToe." +COMPOSE_PROJECT_NAME ?= $(notdir $(shell pwd)) +PHP_SERVICE = php +PHP_CMD = php ifeq ($(RUNNER), travis) CMD := else - CMD := docker-compose exec php + CMD := docker-compose exec $(PHP_SERVICE) endif all: container-up clear composer lint-composer lint-php phpcs tests @@ -16,7 +19,7 @@ lint-composer: lint-php: @echo "\n==> Validating all php files:" - @find src -type f -name \*.php | while read file; do php -l "$$file" || exit 1; done + $(CMD) find src tests -type f -iname '*php' -exec $(PHP_CMD) -l {} \; composer: @echo "\n==> Running composer install, runner $(RUNNER)" @@ -49,11 +52,15 @@ container-down: @echo "\n==> Removing docker container" $(DOCKER_COMPOSE) down +container-remove: + @echo "\n==> Removing docker container(s)" + $(DOCKER_COMPOSE) rm + container-up: @echo "\n==> Docker container building and starting ..." $(DOCKER_COMPOSE) up --build -d -tear-down: clear container-stop container-down +tear-down: clear container-stop container-down container-remove -.PHONY: lint-php lint-composer phpcs phpcbf composer clear tests coverage container-up static-analysis container-stop container-down +.PHONY: lint-php lint-composer phpcs phpcbf composer clear tests coverage container-up container-stop container-down container-remove diff --git a/docker-compose.yml b/docker-compose.yml index 1f1f90a..9692b69 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,10 @@ -version: '3' +version: '3.7' services: php: - image: custom-php-cli - container_name: tictactoe build: docker/php-cli tty: true + working_dir: /code + restart: on-failure volumes: - - ./:/code + - ./:/code diff --git a/docker/php-cli/Dockerfile b/docker/php-cli/Dockerfile index 432295a..f4fb48b 100644 --- a/docker/php-cli/Dockerfile +++ b/docker/php-cli/Dockerfile @@ -1,16 +1,25 @@ -FROM php:7-cli +FROM php:7-cli-alpine -RUN apt-get update && apt-get -y install \ - curl \ - zip \ - unzip \ - vim -RUN pecl install xdebug -RUN docker-php-ext-enable xdebug -RUN rm -rf /var/lib/apt/lists/* +RUN apk update \ + && apk add git \ + curl \ + zip \ + unzip \ + vim + +RUN apk add --no-cache $PHPIZE_DEPS \ + && pecl install -f xdebug \ + && docker-php-ext-enable xdebug \ + && rm -rf /var/lib/apt/lists/* # Install Composer -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer -RUN composer --version +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ + && composer --version + +# Set timezone +ENV TIMEZONE=Etc/UCT +RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && echo ${TIMEZONE} > /etc/timezone \ + && printf '[PHP]\ndate.timezone = "%s"\n', ${TIMEZONE} > /usr/local/etc/php/conf.d/tzone.ini \ + && "date" WORKDIR /code From e2a2ae685c1f82b9d5f70ea106b654a36a855645 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Fri, 13 Mar 2020 15:32:42 +0100 Subject: [PATCH 65/75] upgrade to php 4 --- composer.json | 10 +- composer.lock | 807 +++++++++++++++++++++++++++----------------------- 2 files changed, 447 insertions(+), 370 deletions(-) diff --git a/composer.json b/composer.json index 8d67021..568cd6b 100644 --- a/composer.json +++ b/composer.json @@ -10,14 +10,14 @@ } ], "require": { - "php": ">=7.2", - "ramsey/uuid": "^3.8", - "squizlabs/php_codesniffer": "2.*" + "php": ">=7.4", + "ramsey/uuid": "^3.8" }, "require-dev": { "phpstan/phpstan": "^0.10.5", "phpstan/phpstan-doctrine": "^0.10.0", - "phpunit/phpunit": "^7" + "phpunit/phpunit": "^7", + "squizlabs/php_codesniffer": "^3.5" }, "autoload": { "psr-0": { @@ -32,7 +32,7 @@ "config": { "bin-dir": "bin", "platform": { - "php": "7.2" + "php": "7.4" }, "sort-packages": true } diff --git a/composer.lock b/composer.lock index ca24471..f92d5d7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2433582596775155d720482ec27b1075", + "content-hash": "603a70677a4b29600633f2bf1b37a574", "packages": [ { "name": "paragonie/random_compat", @@ -53,44 +53,46 @@ }, { "name": "ramsey/uuid", - "version": "3.8.0", + "version": "3.9.3", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "d09ea80159c1929d75b3f9c60504d613aeb4a1e3" + "reference": "7e1633a6964b48589b142d60542f9ed31bd37a92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/d09ea80159c1929d75b3f9c60504d613aeb4a1e3", - "reference": "d09ea80159c1929d75b3f9c60504d613aeb4a1e3", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/7e1633a6964b48589b142d60542f9ed31bd37a92", + "reference": "7e1633a6964b48589b142d60542f9ed31bd37a92", "shasum": "" }, "require": { - "paragonie/random_compat": "^1.0|^2.0|9.99.99", - "php": "^5.4 || ^7.0", + "ext-json": "*", + "paragonie/random_compat": "^1 | ^2 | 9.99.99", + "php": "^5.4 | ^7 | ^8", "symfony/polyfill-ctype": "^1.8" }, "replace": { "rhumsaa/uuid": "self.version" }, "require-dev": { - "codeception/aspect-mock": "^1.0 | ~2.0.0", - "doctrine/annotations": "~1.2.0", - "goaop/framework": "1.0.0-alpha.2 | ^1.0 | ~2.1.0", - "ircmaxell/random-lib": "^1.1", - "jakub-onderka/php-parallel-lint": "^0.9.0", - "mockery/mockery": "^0.9.9", + "codeception/aspect-mock": "^1 | ^2", + "doctrine/annotations": "^1.2", + "goaop/framework": "1.0.0-alpha.2 | ^1 | ^2.1", + "jakub-onderka/php-parallel-lint": "^1", + "mockery/mockery": "^0.9.11 | ^1", "moontoast/math": "^1.1", - "php-mock/php-mock-phpunit": "^0.3|^1.1", - "phpunit/phpunit": "^4.7|^5.0|^6.5", - "squizlabs/php_codesniffer": "^2.3" + "paragonie/random-lib": "^2", + "php-mock/php-mock-phpunit": "^0.3 | ^1.1", + "phpunit/phpunit": "^4.8 | ^5.4 | ^6.5", + "squizlabs/php_codesniffer": "^3.5" }, "suggest": { "ext-ctype": "Provides support for PHP Ctype functions", "ext-libsodium": "Provides the PECL libsodium extension for use with the SodiumRandomGenerator", + "ext-openssl": "Provides the OpenSSL extension for use with the OpenSslGenerator", "ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator", - "ircmaxell/random-lib": "Provides RandomLib for use with the RandomLibAdapter", "moontoast/math": "Provides support for converting UUID to 128-bit integer (in string form).", + "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter", "ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid", "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." }, @@ -103,13 +105,21 @@ "autoload": { "psr-4": { "Ramsey\\Uuid\\": "src/" - } + }, + "files": [ + "src/functions.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ + { + "name": "Ben Ramsey", + "email": "ben@benramsey.com", + "homepage": "https://benramsey.com" + }, { "name": "Marijn Huizendveld", "email": "marijn.huizendveld@gmail.com" @@ -117,11 +127,6 @@ { "name": "Thibaud Fabre", "email": "thibaud@aztech.io" - }, - { - "name": "Ben Ramsey", - "email": "ben@benramsey.com", - "homepage": "https://benramsey.com" } ], "description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).", @@ -131,98 +136,20 @@ "identifier", "uuid" ], - "time": "2018-07-19T23:38:55+00:00" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "2.9.2", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "2acf168de78487db620ab4bc524135a13cfe6745" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745", - "reference": "2acf168de78487db620ab4bc524135a13cfe6745", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "bin": [ - "scripts/phpcs", - "scripts/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } - }, - "autoload": { - "classmap": [ - "CodeSniffer.php", - "CodeSniffer/CLI.php", - "CodeSniffer/Exception.php", - "CodeSniffer/File.php", - "CodeSniffer/Fixer.php", - "CodeSniffer/Report.php", - "CodeSniffer/Reporting.php", - "CodeSniffer/Sniff.php", - "CodeSniffer/Tokens.php", - "CodeSniffer/Reports/", - "CodeSniffer/Tokenizers/", - "CodeSniffer/DocGenerators/", - "CodeSniffer/Standards/AbstractPatternSniff.php", - "CodeSniffer/Standards/AbstractScopeSniff.php", - "CodeSniffer/Standards/AbstractVariableSniff.php", - "CodeSniffer/Standards/IncorrectPatternException.php", - "CodeSniffer/Standards/Generic/Sniffs/", - "CodeSniffer/Standards/MySource/Sniffs/", - "CodeSniffer/Standards/PEAR/Sniffs/", - "CodeSniffer/Standards/PSR1/Sniffs/", - "CodeSniffer/Standards/PSR2/Sniffs/", - "CodeSniffer/Standards/Squiz/Sniffs/", - "CodeSniffer/Standards/Zend/Sniffs/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", - "keywords": [ - "phpcs", - "standards" - ], - "time": "2018-11-07T22:31:41+00:00" + "time": "2020-02-21T04:36:14+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.11.0", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "82ebae02209c21113908c229e9883c419720738a" + "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", - "reference": "82ebae02209c21113908c229e9883c419720738a", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", + "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", "shasum": "" }, "require": { @@ -234,7 +161,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -250,13 +177,13 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, { "name": "Gert de Pagter", "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony polyfill for ctype functions", @@ -267,30 +194,30 @@ "polyfill", "portable" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2020-01-13T11:15:53+00:00" } ], "packages-dev": [ { "name": "composer/xdebug-handler", - "version": "1.3.3", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f" + "reference": "1ab9842d69e64fb3a01be6b656501032d1b78cb7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/46867cbf8ca9fb8d60c506895449eb799db1184f", - "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/1ab9842d69e64fb3a01be6b656501032d1b78cb7", + "reference": "1ab9842d69e64fb3a01be6b656501032d1b78cb7", "shasum": "" }, "require": { - "php": "^5.3.2 || ^7.0", + "php": "^5.3.2 || ^7.0 || ^8.0", "psr/log": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" }, "type": "library", "autoload": { @@ -308,25 +235,31 @@ "email": "john-stevenson@blueyonder.co.uk" } ], - "description": "Restarts a process without xdebug.", + "description": "Restarts a process without Xdebug.", "keywords": [ "Xdebug", "performance" ], - "time": "2019-05-27T17:52:04+00:00" + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + } + ], + "time": "2020-03-01T12:26:26+00:00" }, { "name": "doctrine/instantiator", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "a2c590166b2133a4633738648b6b064edae0814a" + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", - "reference": "a2c590166b2133a4633738648b6b064edae0814a", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", "shasum": "" }, "require": { @@ -369,7 +302,7 @@ "constructor", "instantiate" ], - "time": "2019-03-17T17:37:11+00:00" + "time": "2019-10-21T16:45:58+00:00" }, { "name": "jean85/pretty-package-versions", @@ -424,16 +357,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.9.1", + "version": "1.9.5", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72" + "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", - "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", + "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", "shasum": "" }, "require": { @@ -468,20 +401,20 @@ "object", "object graph" ], - "time": "2019-04-07T13:18:21+00:00" + "time": "2020-01-17T21:11:47+00:00" }, { "name": "nette/bootstrap", - "version": "v3.0.0", + "version": "v3.0.1", "source": { "type": "git", "url": "https://github.com/nette/bootstrap.git", - "reference": "e1075af05c211915e03e0c86542f3ba5433df4a3" + "reference": "b45a1e33b6a44beb307756522396551e5a9ff249" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/bootstrap/zipball/e1075af05c211915e03e0c86542f3ba5433df4a3", - "reference": "e1075af05c211915e03e0c86542f3ba5433df4a3", + "url": "https://api.github.com/repos/nette/bootstrap/zipball/b45a1e33b6a44beb307756522396551e5a9ff249", + "reference": "b45a1e33b6a44beb307756522396551e5a9ff249", "shasum": "" }, "require": { @@ -489,6 +422,9 @@ "nette/utils": "^3.0", "php": ">=7.1" }, + "conflict": { + "tracy/tracy": "<2.6" + }, "require-dev": { "latte/latte": "^2.2", "nette/application": "^3.0", @@ -541,29 +477,29 @@ "configurator", "nette" ], - "time": "2019-03-26T12:59:07+00:00" + "time": "2019-09-30T08:19:38+00:00" }, { "name": "nette/di", - "version": "v3.0.0", + "version": "v3.0.3", "source": { "type": "git", "url": "https://github.com/nette/di.git", - "reference": "19d83539245aaacb59470828919182411061841f" + "reference": "77d69061cbf8f9cfb7363dd983136f51213d3e41" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/di/zipball/19d83539245aaacb59470828919182411061841f", - "reference": "19d83539245aaacb59470828919182411061841f", + "url": "https://api.github.com/repos/nette/di/zipball/77d69061cbf8f9cfb7363dd983136f51213d3e41", + "reference": "77d69061cbf8f9cfb7363dd983136f51213d3e41", "shasum": "" }, "require": { "ext-tokenizer": "*", "nette/neon": "^3.0", - "nette/php-generator": "^3.2.2", + "nette/php-generator": "^3.3.3", "nette/robot-loader": "^3.2", "nette/schema": "^1.0", - "nette/utils": "^3.0", + "nette/utils": "^3.1", "php": ">=7.1" }, "conflict": { @@ -571,6 +507,7 @@ }, "require-dev": { "nette/tester": "^2.2", + "phpstan/phpstan": "^0.12", "tracy/tracy": "^2.3" }, "type": "library", @@ -582,16 +519,13 @@ "autoload": { "classmap": [ "src/" - ], - "files": [ - "src/compatibility.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause", - "GPL-2.0", - "GPL-3.0" + "GPL-2.0-only", + "GPL-3.0-only" ], "authors": [ { @@ -614,24 +548,24 @@ "nette", "static" ], - "time": "2019-04-03T19:35:46+00:00" + "time": "2020-01-20T12:14:54+00:00" }, { "name": "nette/finder", - "version": "v2.5.0", + "version": "v2.5.2", "source": { "type": "git", "url": "https://github.com/nette/finder.git", - "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2" + "reference": "4ad2c298eb8c687dd0e74ae84206a4186eeaed50" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/finder/zipball/6be1b83ea68ac558aff189d640abe242e0306fe2", - "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2", + "url": "https://api.github.com/repos/nette/finder/zipball/4ad2c298eb8c687dd0e74ae84206a4186eeaed50", + "reference": "4ad2c298eb8c687dd0e74ae84206a4186eeaed50", "shasum": "" }, "require": { - "nette/utils": "^2.4 || ~3.0.0", + "nette/utils": "^2.4 || ^3.0", "php": ">=7.1" }, "conflict": { @@ -639,6 +573,7 @@ }, "require-dev": { "nette/tester": "^2.0", + "phpstan/phpstan": "^0.12", "tracy/tracy": "^2.3" }, "type": "library", @@ -668,7 +603,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "? Nette Finder: find files and directories with an intuitive API.", + "description": "🔍 Nette Finder: find files and directories with an intuitive API.", "homepage": "https://nette.org", "keywords": [ "filesystem", @@ -676,35 +611,36 @@ "iterator", "nette" ], - "time": "2019-02-28T18:13:25+00:00" + "time": "2020-01-03T20:35:40+00:00" }, { "name": "nette/neon", - "version": "v3.0.0", + "version": "v3.1.2", "source": { "type": "git", "url": "https://github.com/nette/neon.git", - "reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb" + "reference": "3c3dcbc6bf6c80dc97b1fc4ba9a22ae67930fc0e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/neon/zipball/cbff32059cbdd8720deccf9e9eace6ee516f02eb", - "reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb", + "url": "https://api.github.com/repos/nette/neon/zipball/3c3dcbc6bf6c80dc97b1fc4ba9a22ae67930fc0e", + "reference": "3c3dcbc6bf6c80dc97b1fc4ba9a22ae67930fc0e", "shasum": "" }, "require": { "ext-iconv": "*", "ext-json": "*", - "php": ">=7.0" + "php": ">=7.1" }, "require-dev": { "nette/tester": "^2.0", + "phpstan/phpstan": "^0.12", "tracy/tracy": "^2.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -715,8 +651,8 @@ "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause", - "GPL-2.0", - "GPL-3.0" + "GPL-2.0-only", + "GPL-3.0-only" ], "authors": [ { @@ -728,8 +664,8 @@ "homepage": "https://nette.org/contributors" } ], - "description": "? Nette NEON: encodes and decodes NEON file format.", - "homepage": "http://ne-on.org", + "description": "🍸 Nette NEON: encodes and decodes NEON file format.", + "homepage": "https://ne-on.org", "keywords": [ "export", "import", @@ -737,34 +673,35 @@ "nette", "yaml" ], - "time": "2019-02-05T21:30:40+00:00" + "time": "2020-03-04T11:47:04+00:00" }, { "name": "nette/php-generator", - "version": "v3.2.2", + "version": "v3.3.4", "source": { "type": "git", "url": "https://github.com/nette/php-generator.git", - "reference": "acff8b136fad84b860a626d133e791f95781f9f5" + "reference": "8fe7e699dca7db186f56d75800cb1ec32e39c856" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/php-generator/zipball/acff8b136fad84b860a626d133e791f95781f9f5", - "reference": "acff8b136fad84b860a626d133e791f95781f9f5", + "url": "https://api.github.com/repos/nette/php-generator/zipball/8fe7e699dca7db186f56d75800cb1ec32e39c856", + "reference": "8fe7e699dca7db186f56d75800cb1ec32e39c856", "shasum": "" }, "require": { - "nette/utils": "^2.4.2 || ~3.0.0", + "nette/utils": "^2.4.2 || ^3.0", "php": ">=7.1" }, "require-dev": { "nette/tester": "^2.0", + "phpstan/phpstan": "^0.12", "tracy/tracy": "^2.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "3.3-dev" } }, "autoload": { @@ -775,8 +712,8 @@ "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause", - "GPL-2.0", - "GPL-3.0" + "GPL-2.0-only", + "GPL-3.0-only" ], "authors": [ { @@ -788,7 +725,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.3 features.", + "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.4 features.", "homepage": "https://nette.org", "keywords": [ "code", @@ -796,30 +733,31 @@ "php", "scaffolding" ], - "time": "2019-03-15T03:41:13+00:00" + "time": "2020-02-09T14:39:09+00:00" }, { "name": "nette/robot-loader", - "version": "v3.2.0", + "version": "v3.2.3", "source": { "type": "git", "url": "https://github.com/nette/robot-loader.git", - "reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c" + "reference": "726c462e73e739e965ec654a667407074cfe83c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/robot-loader/zipball/0712a0e39ae7956d6a94c0ab6ad41aa842544b5c", - "reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c", + "url": "https://api.github.com/repos/nette/robot-loader/zipball/726c462e73e739e965ec654a667407074cfe83c0", + "reference": "726c462e73e739e965ec654a667407074cfe83c0", "shasum": "" }, "require": { "ext-tokenizer": "*", - "nette/finder": "^2.5", + "nette/finder": "^2.5 || ^3.0", "nette/utils": "^3.0", "php": ">=7.1" }, "require-dev": { "nette/tester": "^2.0", + "phpstan/phpstan": "^0.12", "tracy/tracy": "^2.3" }, "type": "library", @@ -836,8 +774,8 @@ "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause", - "GPL-2.0", - "GPL-3.0" + "GPL-2.0-only", + "GPL-3.0-only" ], "authors": [ { @@ -849,7 +787,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "? Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.", + "description": "🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.", "homepage": "https://nette.org", "keywords": [ "autoload", @@ -858,35 +796,34 @@ "nette", "trait" ], - "time": "2019-03-08T21:57:24+00:00" + "time": "2020-02-28T13:10:07+00:00" }, { "name": "nette/schema", - "version": "v1.0.0", + "version": "v1.0.2", "source": { "type": "git", "url": "https://github.com/nette/schema.git", - "reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d" + "reference": "febf71fb4052c824046f5a33f4f769a6e7fa0cb4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/schema/zipball/6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d", - "reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d", + "url": "https://api.github.com/repos/nette/schema/zipball/febf71fb4052c824046f5a33f4f769a6e7fa0cb4", + "reference": "febf71fb4052c824046f5a33f4f769a6e7fa0cb4", "shasum": "" }, "require": { - "nette/utils": "^3.0.1", + "nette/utils": "^3.1", "php": ">=7.1" }, "require-dev": { "nette/tester": "^2.2", + "phpstan/phpstan-nette": "^0.12", "tracy/tracy": "^2.3" }, "type": "library", "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } + "branch-alias": [] }, "autoload": { "classmap": [ @@ -915,20 +852,20 @@ "config", "nette" ], - "time": "2019-04-03T15:53:25+00:00" + "time": "2020-01-06T22:52:48+00:00" }, { "name": "nette/utils", - "version": "v3.0.1", + "version": "v3.1.1", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "bd961f49b211997202bda1d0fbc410905be370d4" + "reference": "2c17d16d8887579ae1c0898ff94a3668997fd3eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/bd961f49b211997202bda1d0fbc410905be370d4", - "reference": "bd961f49b211997202bda1d0fbc410905be370d4", + "url": "https://api.github.com/repos/nette/utils/zipball/2c17d16d8887579ae1c0898ff94a3668997fd3eb", + "reference": "2c17d16d8887579ae1c0898ff94a3668997fd3eb", "shasum": "" }, "require": { @@ -936,6 +873,7 @@ }, "require-dev": { "nette/tester": "~2.0", + "phpstan/phpstan": "^0.12", "tracy/tracy": "^2.3" }, "suggest": { @@ -944,12 +882,13 @@ "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", "ext-json": "to use Nette\\Utils\\Json", "ext-mbstring": "to use Strings::lower() etc...", + "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()", "ext-xml": "to use Strings::length() etc. when mbstring is not available" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -960,8 +899,8 @@ "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause", - "GPL-2.0", - "GPL-3.0" + "GPL-2.0-only", + "GPL-3.0-only" ], "authors": [ { @@ -991,20 +930,20 @@ "utility", "validation" ], - "time": "2019-03-22T01:00:30+00:00" + "time": "2020-02-09T14:10:55+00:00" }, { "name": "nikic/php-parser", - "version": "v4.2.2", + "version": "v4.2.5", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420" + "reference": "b76bbc3c51f22c570648de48e8c2d941ed5e2cf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bd73cc04c3843ad8d6b0bfc0956026a151fc420", - "reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/b76bbc3c51f22c570648de48e8c2d941ed5e2cf2", + "reference": "b76bbc3c51f22c570648de48e8c2d941ed5e2cf2", "shasum": "" }, "require": { @@ -1012,7 +951,8 @@ "php": ">=7.0" }, "require-dev": { - "phpunit/phpunit": "^6.5 || ^7.0" + "ircmaxell/php-yacc": "0.0.4", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0" }, "bin": [ "bin/php-parse" @@ -1042,38 +982,39 @@ "parser", "php" ], - "time": "2019-05-25T20:07:01+00:00" + "time": "2019-10-25T18:33:07+00:00" }, { "name": "ocramius/package-versions", - "version": "1.4.0", + "version": "1.7.0", "source": { "type": "git", "url": "https://github.com/Ocramius/PackageVersions.git", - "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb" + "reference": "651c372efc914aea8223e049f85afaf65e09ba23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", - "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", + "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/651c372efc914aea8223e049f85afaf65e09ba23", + "reference": "651c372efc914aea8223e049f85afaf65e09ba23", "shasum": "" }, "require": { - "composer-plugin-api": "^1.0.0", - "php": "^7.1.0" + "composer-plugin-api": "^1.1.0", + "php": "^7.4.0" }, "require-dev": { - "composer/composer": "^1.6.3", - "doctrine/coding-standard": "^5.0.1", - "ext-zip": "*", - "infection/infection": "^0.7.1", - "phpunit/phpunit": "^7.0.0" + "composer/composer": "^1.9.3", + "doctrine/coding-standard": "^7.0.2", + "ext-zip": "^1.15.0", + "infection/infection": "^0.15.3", + "phpunit/phpunit": "^9.0.1", + "vimeo/psalm": "^3.9.3" }, "type": "composer-plugin", "extra": { "class": "PackageVersions\\Installer", "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.99.x-dev" } }, "autoload": { @@ -1092,7 +1033,17 @@ } ], "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", - "time": "2019-02-21T12:16:21+00:00" + "funding": [ + { + "url": "https://github.com/Ocramius", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/ocramius/package-versions", + "type": "tidelift" + } + ], + "time": "2020-03-06T11:34:16+00:00" }, { "name": "phar-io/manifest", @@ -1198,35 +1149,33 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "1.0.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", "shasum": "" }, "require": { - "php": ">=5.5" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^4.6" + "phpunit/phpunit": "~6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] + "phpDocumentor\\Reflection\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1248,44 +1197,42 @@ "reflection", "static analysis" ], - "time": "2017-09-11T18:02:19+00:00" + "time": "2018-08-07T13:53:10+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.1", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c" + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", "shasum": "" }, "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0", - "phpdocumentor/type-resolver": "^0.4.0", - "webmozart/assert": "^1.0" + "ext-filter": "^7.1", + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0", + "phpdocumentor/type-resolver": "^1.0", + "webmozart/assert": "^1" }, "require-dev": { - "doctrine/instantiator": "~1.0.5", - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.4" + "doctrine/instantiator": "^1", + "mockery/mockery": "^1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "5.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -1296,44 +1243,46 @@ { "name": "Mike van Riel", "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-04-30T17:48:53+00:00" + "time": "2020-02-22T12:28:44+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.4.0", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + "reference": "7462d5f123dfc080dfdf26897032a6513644fc95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95", + "reference": "7462d5f123dfc080dfdf26897032a6513644fc95", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", - "phpdocumentor/reflection-common": "^1.0" + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "ext-tokenizer": "^7.2", + "mockery/mockery": "~1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -1346,37 +1295,38 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-07-14T14:27:02+00:00" + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "time": "2020-02-18T18:59:58+00:00" }, { "name": "phpspec/prophecy", - "version": "1.8.1", + "version": "v1.10.3", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76" + "reference": "451c3cd1418cf640de218914901e51b064abb093" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", + "reference": "451c3cd1418cf640de218914901e51b064abb093", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", + "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", + "phpspec/phpspec": "^2.5 || ^3.2", "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.10.x-dev" } }, "autoload": { @@ -1409,7 +1359,7 @@ "spy", "stub" ], - "time": "2019-06-13T12:50:23+00:00" + "time": "2020-03-05T15:02:03+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -1460,16 +1410,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.10.8", + "version": "0.10.9", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "4f828460a0276180da76c670a0a6e592e7c38b71" + "reference": "61840df60f50e186683ba35ece82efb66bd0ab2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/4f828460a0276180da76c670a0a6e592e7c38b71", - "reference": "4f828460a0276180da76c670a0a6e592e7c38b71", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/61840df60f50e186683ba35ece82efb66bd0ab2c", + "reference": "61840df60f50e186683ba35ece82efb66bd0ab2c", "shasum": "" }, "require": { @@ -1479,7 +1429,7 @@ "nette/di": "^2.4.7 || ^3.0", "nette/robot-loader": "^3.0.1", "nette/utils": "^2.4.5 || ^3.0", - "nikic/php-parser": "^4.0.2", + "nikic/php-parser": "4.0.2 - 4.2.5", "php": "~7.1", "phpstan/phpdoc-parser": "^0.3", "symfony/console": "~3.2 || ~4.0", @@ -1529,7 +1479,7 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", - "time": "2019-01-08T09:51:19+00:00" + "time": "2020-01-07T15:26:30+00:00" }, { "name": "phpstan/phpstan-doctrine", @@ -1791,16 +1741,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "3.0.1", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18" + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c99e3be9d3e85f60646f152f9002d46ed7770d18", - "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", "shasum": "" }, "require": { @@ -1813,7 +1763,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -1836,20 +1786,20 @@ "keywords": [ "tokenizer" ], - "time": "2018-10-30T05:52:18+00:00" + "time": "2019-09-17T06:23:10+00:00" }, { "name": "phpunit/phpunit", - "version": "7.5.12", + "version": "7.5.20", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c" + "reference": "9467db479d1b0487c99733bb1e7944d32deded2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c", - "reference": "9ba59817745b0fe0c1a5a3032dfd4a6d2994ad1c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9467db479d1b0487c99733bb1e7944d32deded2c", + "reference": "9467db479d1b0487c99733bb1e7944d32deded2c", "shasum": "" }, "require": { @@ -1920,20 +1870,69 @@ "testing", "xunit" ], - "time": "2019-05-28T11:59:40+00:00" + "time": "2020-01-08T08:45:45+00:00" + }, + { + "name": "psr/container", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+00:00" }, { "name": "psr/log", - "version": "1.1.0", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" + "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", + "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", "shasum": "" }, "require": { @@ -1942,7 +1941,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { @@ -1967,7 +1966,7 @@ "psr", "psr-3" ], - "time": "2018-11-20T15:27:04+00:00" + "time": "2019-11-01T11:05:21+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -2136,16 +2135,16 @@ }, { "name": "sebastian/environment", - "version": "4.2.2", + "version": "4.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404" + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/f2a2c8e1c97c11ace607a7a667d73d47c19fe404", - "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368", + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368", "shasum": "" }, "require": { @@ -2185,20 +2184,20 @@ "environment", "hhvm" ], - "time": "2019-05-05T09:05:15+00:00" + "time": "2019-11-20T08:46:58+00:00" }, { "name": "sebastian/exporter", - "version": "3.1.0", + "version": "3.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", "shasum": "" }, "require": { @@ -2225,6 +2224,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -2233,17 +2236,13 @@ "name": "Volker Dusch", "email": "github@wallbash.com" }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, { "name": "Adam Harvey", "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" } ], "description": "Provides the functionality to export PHP variables for visualization", @@ -2252,7 +2251,7 @@ "export", "exporter" ], - "time": "2017-04-03T13:19:02+00:00" + "time": "2019-09-14T09:02:43+00:00" }, { "name": "sebastian/global-state", @@ -2535,29 +2534,81 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.5.4", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "dceec07328401de6211037abbb18bda423677e26" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dceec07328401de6211037abbb18bda423677e26", + "reference": "dceec07328401de6211037abbb18bda423677e26", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2020-01-30T22:20:29+00:00" + }, { "name": "symfony/console", - "version": "v4.3.1", + "version": "v4.4.5", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "d50bbeeb0e17e6dd4124ea391eff235e932cbf64" + "reference": "4fa15ae7be74e53f6ec8c83ed403b97e23b665e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d50bbeeb0e17e6dd4124ea391eff235e932cbf64", - "reference": "d50bbeeb0e17e6dd4124ea391eff235e932cbf64", + "url": "https://api.github.com/repos/symfony/console/zipball/4fa15ae7be74e53f6ec8c83ed403b97e23b665e9", + "reference": "4fa15ae7be74e53f6ec8c83ed403b97e23b665e9", "shasum": "" }, "require": { "php": "^7.1.3", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php73": "^1.8", - "symfony/service-contracts": "^1.1" + "symfony/service-contracts": "^1.1|^2" }, "conflict": { "symfony/dependency-injection": "<3.4", - "symfony/event-dispatcher": "<4.3", + "symfony/event-dispatcher": "<4.3|>=5", + "symfony/lock": "<4.4", "symfony/process": "<3.3" }, "provide": { @@ -2565,12 +2616,12 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", + "symfony/config": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^3.4|^4.0|^5.0", "symfony/event-dispatcher": "^4.3", - "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.4|~4.0", - "symfony/var-dumper": "^4.3" + "symfony/lock": "^4.4|^5.0", + "symfony/process": "^3.4|^4.0|^5.0", + "symfony/var-dumper": "^4.3|^5.0" }, "suggest": { "psr/log": "For using the console logger", @@ -2581,7 +2632,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -2608,20 +2659,34 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2019-06-05T13:25:51+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-02-24T13:10:00+00:00" }, { "name": "symfony/finder", - "version": "v4.3.1", + "version": "v4.4.5", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "b3d4f4c0e4eadfdd8b296af9ca637cfbf51d8176" + "reference": "ea69c129aed9fdeca781d4b77eb20b62cf5d5357" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/b3d4f4c0e4eadfdd8b296af9ca637cfbf51d8176", - "reference": "b3d4f4c0e4eadfdd8b296af9ca637cfbf51d8176", + "url": "https://api.github.com/repos/symfony/finder/zipball/ea69c129aed9fdeca781d4b77eb20b62cf5d5357", + "reference": "ea69c129aed9fdeca781d4b77eb20b62cf5d5357", "shasum": "" }, "require": { @@ -2630,7 +2695,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -2657,20 +2722,34 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2019-05-26T20:47:49+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-02-14T07:42:58+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.11.0", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" + "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/34094cfa9abe1f0f14f48f490772db7a775559f2", + "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2", "shasum": "" }, "require": { @@ -2682,7 +2761,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -2716,20 +2795,20 @@ "portable", "shim" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2020-01-13T11:15:53+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.11.0", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd" + "reference": "5e66a0fa1070bf46bec4bea7962d285108edd675" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", - "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/5e66a0fa1070bf46bec4bea7962d285108edd675", + "reference": "5e66a0fa1070bf46bec4bea7962d285108edd675", "shasum": "" }, "require": { @@ -2738,7 +2817,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -2774,33 +2853,33 @@ "portable", "shim" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2020-01-13T11:15:53+00:00" }, { "name": "symfony/service-contracts", - "version": "v1.1.2", + "version": "v2.0.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0" + "reference": "144c5e51266b281231e947b51223ba14acf1a749" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/191afdcb5804db960d26d8566b7e9a2843cab3a0", - "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/144c5e51266b281231e947b51223ba14acf1a749", + "reference": "144c5e51266b281231e947b51223ba14acf1a749", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": "^7.2.5", + "psr/container": "^1.0" }, "suggest": { - "psr/container": "", "symfony/service-implementation": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -2832,7 +2911,7 @@ "interoperability", "standards" ], - "time": "2019-05-28T07:50:59+00:00" + "time": "2019-11-18T17:27:11+00:00" }, { "name": "theseer/tokenizer", @@ -2876,32 +2955,29 @@ }, { "name": "webmozart/assert", - "version": "1.4.0", + "version": "1.7.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" + "reference": "aed98a490f9a8f78468232db345ab9cf606cf598" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", + "url": "https://api.github.com/repos/webmozart/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598", + "reference": "aed98a490f9a8f78468232db345ab9cf606cf598", "shasum": "" }, "require": { "php": "^5.3.3 || ^7.0", "symfony/polyfill-ctype": "^1.8" }, + "conflict": { + "vimeo/psalm": "<3.6.0" + }, "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" + "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -2923,7 +2999,7 @@ "check", "validate" ], - "time": "2018-12-25T11:19:39+00:00" + "time": "2020-02-14T12:15:55+00:00" } ], "aliases": [], @@ -2932,10 +3008,11 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.2" + "php": ">=7.4" }, "platform-dev": [], "platform-overrides": { - "php": "7.2" - } + "php": "7.4" + }, + "plugin-api-version": "1.1.0" } From db597e7302d8d1ccf7f3267d636342778e813b87 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 29 Sep 2022 14:51:56 +0200 Subject: [PATCH 66/75] add phpstan and upgrade to php 8.0 --- .gitignore | 1 + .travis.yml | 4 +- Makefile | 4 + composer.json | 15 +- composer.lock | 2933 ++++++----------- docker-compose.yml | 1 + docker/php-cli/Dockerfile | 2 +- docker/php-cli/php.ini | 12 + phpstan.neon | 8 +- phpunit.xml | 30 +- src/TicTacToe/Application.php | 4 - .../CreateNewGame/CreateNewGameCommand.php | 15 +- .../CreateNewGame/CreateNewGameHandler.php | 6 +- .../CreateNewGameResponseDto.php | 19 +- .../CreateNewPlayerCommand.php | 6 +- .../CreateNewPlayerResponseDto.php | 14 +- .../PlayNewTurn/PlayNewTurnHandler.php | 13 +- .../Engine/Domain/Model/Board/Board.php | 22 +- .../Engine/Domain/Model/Board/Cell.php | 5 +- .../Engine/Domain/Model/Board/CellSet.php | 14 +- .../Engine/Domain/Model/Board/Position.php | 6 +- .../Domain/Model/Game/Event/GameCreated.php | 3 +- .../Model/Game/Event/PlayerTurnPlayed.php | 5 +- .../Engine/Domain/Model/Game/Game.php | 23 +- .../Engine/Domain/Model/Game/GameId.php | 5 +- .../Domain/Model/Game/GameRepository.php | 2 +- .../Engine/Domain/Model/Game/Turn.php | 25 +- .../Engine/Domain/Model/Game/TurnId.php | 5 +- .../Domain/Model/Game/TurnRepository.php | 2 +- .../Model/Player/Event/PlayerCreated.php | 5 +- .../Engine/Domain/Model/Player/Player.php | 20 +- .../Engine/Domain/Model/Player/PlayerId.php | 5 +- .../Domain/Model/Player/PlayerIdSet.php | 16 +- .../Engine/Domain/Model/Player/PlayerName.php | 7 +- .../Domain/Model/Player/PlayerRepository.php | 2 +- .../Domain/Model/Player/PlayerToken.php | 6 +- .../InMemory/InMemoryEventStore.php | 18 +- .../InMemory/InMemoryGameRepository.php | 4 +- .../InMemory/InMemoryPlayerRepository.php | 8 +- .../Presentation/Console/ConsoleInput.php | 38 +- .../Presentation/Console/ConsoleOutput.php | 8 +- src/TicTacToe/Engine/Presentation/Input.php | 9 +- src/TicTacToe/Engine/Presentation/Output.php | 8 +- .../Shared/Application/DataTransformer.php | 2 +- .../Shared/Application/EmptyResponseDto.php | 13 + .../Shared/Domain/Model/AggregateRoot.php | 14 +- src/TicTacToe/Shared/Domain/Model/Event.php | 2 +- .../CommandBus/CommandBusFactory.php | 3 +- .../Shared/Infrastructure/EventStore.php | 2 +- .../CreateNewPlayerHandlerTest.php | 22 +- .../InMemory/InMemoryPlayerRepositoryTest.php | 5 +- 51 files changed, 1275 insertions(+), 2146 deletions(-) create mode 100644 docker/php-cli/php.ini create mode 100644 src/TicTacToe/Shared/Application/EmptyResponseDto.php diff --git a/.gitignore b/.gitignore index 4247d65..41308e8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ coverage/* bin/* !bin/.gitkeep +.phpunit.result.cache \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index f177986..738b76b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,5 @@ env: - RUNNER=travis language: php php: - - '7.4' -install: make clear lint-composer lint-php composer phpcs tests + - '8' +install: make clear lint-composer lint-php composer phpcs tests stan diff --git a/Makefile b/Makefile index 499a7c3..9aba4c2 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,10 @@ tests: @echo "\n==> Running tests" $(CMD) bin/phpunit +stan: + @echo "\n==> Running stan for analysis" + $(CMD) bin/phpstan analyse --memory-limit=-1 src + container-stop: @echo "\n==> Stopping docker container" $(DOCKER_COMPOSE) stop diff --git a/composer.json b/composer.json index 568cd6b..c2e7fb4 100644 --- a/composer.json +++ b/composer.json @@ -10,15 +10,9 @@ } ], "require": { - "php": ">=7.4", + "php": ">=8", "ramsey/uuid": "^3.8" }, - "require-dev": { - "phpstan/phpstan": "^0.10.5", - "phpstan/phpstan-doctrine": "^0.10.0", - "phpunit/phpunit": "^7", - "squizlabs/php_codesniffer": "^3.5" - }, "autoload": { "psr-0": { "TicTacToe": "./src/" @@ -32,8 +26,13 @@ "config": { "bin-dir": "bin", "platform": { - "php": "7.4" + "php": "8" }, "sort-packages": true + }, + "require-dev": { + "phpstan/phpstan": "^1.8", + "phpunit/phpunit": "^9.5", + "squizlabs/php_codesniffer": "^3.7" } } diff --git a/composer.lock b/composer.lock index f92d5d7..88e0397 100644 --- a/composer.lock +++ b/composer.lock @@ -4,24 +4,24 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "603a70677a4b29600633f2bf1b37a574", + "content-hash": "d14ecad59044ee066b708801ee5e9c2c", "packages": [ { "name": "paragonie/random_compat", - "version": "v9.99.99", + "version": "v9.99.100", "source": { "type": "git", "url": "https://github.com/paragonie/random_compat.git", - "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", - "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", "shasum": "" }, "require": { - "php": "^7" + "php": ">= 7" }, "require-dev": { "phpunit/phpunit": "4.*|5.*", @@ -49,26 +49,31 @@ "pseudorandom", "random" ], - "time": "2018-07-02T15:55:56+00:00" + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, + "time": "2020-10-15T08:29:30+00:00" }, { "name": "ramsey/uuid", - "version": "3.9.3", + "version": "3.9.6", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "7e1633a6964b48589b142d60542f9ed31bd37a92" + "reference": "ffa80ab953edd85d5b6c004f96181a538aad35a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/7e1633a6964b48589b142d60542f9ed31bd37a92", - "reference": "7e1633a6964b48589b142d60542f9ed31bd37a92", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/ffa80ab953edd85d5b6c004f96181a538aad35a3", + "reference": "ffa80ab953edd85d5b6c004f96181a538aad35a3", "shasum": "" }, "require": { "ext-json": "*", - "paragonie/random_compat": "^1 | ^2 | 9.99.99", - "php": "^5.4 | ^7 | ^8", + "paragonie/random_compat": "^1 | ^2 | ^9.99.99", + "php": "^5.4 | ^7.0 | ^8.0", "symfony/polyfill-ctype": "^1.8" }, "replace": { @@ -77,14 +82,16 @@ "require-dev": { "codeception/aspect-mock": "^1 | ^2", "doctrine/annotations": "^1.2", - "goaop/framework": "1.0.0-alpha.2 | ^1 | ^2.1", - "jakub-onderka/php-parallel-lint": "^1", + "goaop/framework": "1.0.0-alpha.2 | ^1 | >=2.1.0 <=2.3.2", "mockery/mockery": "^0.9.11 | ^1", "moontoast/math": "^1.1", + "nikic/php-parser": "<=4.5.0", "paragonie/random-lib": "^2", - "php-mock/php-mock-phpunit": "^0.3 | ^1.1", - "phpunit/phpunit": "^4.8 | ^5.4 | ^6.5", - "squizlabs/php_codesniffer": "^3.5" + "php-mock/php-mock-phpunit": "^0.3 | ^1.1 | ^2.6", + "php-parallel-lint/php-parallel-lint": "^1.3", + "phpunit/phpunit": ">=4.8.36 <9.0.0 | >=9.3.0", + "squizlabs/php_codesniffer": "^3.5", + "yoast/phpunit-polyfills": "^1.0" }, "suggest": { "ext-ctype": "Provides support for PHP Ctype functions", @@ -103,12 +110,12 @@ } }, "autoload": { - "psr-4": { - "Ramsey\\Uuid\\": "src/" - }, "files": [ "src/functions.php" - ] + ], + "psr-4": { + "Ramsey\\Uuid\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -136,24 +143,43 @@ "identifier", "uuid" ], - "time": "2020-02-21T04:36:14+00:00" + "support": { + "issues": "https://github.com/ramsey/uuid/issues", + "rss": "https://github.com/ramsey/uuid/releases.atom", + "source": "https://github.com/ramsey/uuid", + "wiki": "https://github.com/ramsey/uuid/wiki" + }, + "funding": [ + { + "url": "https://github.com/ramsey", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/ramsey/uuid", + "type": "tidelift" + } + ], + "time": "2021-09-25T23:07:42+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.14.0", + "version": "v1.26.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38" + "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", - "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", + "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" + }, + "provide": { + "ext-ctype": "*" }, "suggest": { "ext-ctype": "For best performance" @@ -161,16 +187,20 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.14-dev" + "dev-main": "1.26-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -194,92 +224,55 @@ "polyfill", "portable" ], - "time": "2020-01-13T11:15:53+00:00" - } - ], - "packages-dev": [ - { - "name": "composer/xdebug-handler", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/composer/xdebug-handler.git", - "reference": "1ab9842d69e64fb3a01be6b656501032d1b78cb7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/1ab9842d69e64fb3a01be6b656501032d1b78cb7", - "reference": "1ab9842d69e64fb3a01be6b656501032d1b78cb7", - "shasum": "" - }, - "require": { - "php": "^5.3.2 || ^7.0 || ^8.0", - "psr/log": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" - }, - "type": "library", - "autoload": { - "psr-4": { - "Composer\\XdebugHandler\\": "src" - } + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0" }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "John Stevenson", - "email": "john-stevenson@blueyonder.co.uk" - } - ], - "description": "Restarts a process without Xdebug.", - "keywords": [ - "Xdebug", - "performance" - ], "funding": [ { - "url": "https://packagist.com", + "url": "https://symfony.com/sponsor", "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" } ], - "time": "2020-03-01T12:26:26+00:00" - }, + "time": "2022-05-24T11:49:31+00:00" + } + ], + "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.3.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^6.0", + "doctrine/coding-standard": "^9", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-shim": "^0.11", - "phpunit/phpunit": "^7.0" + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.22" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, "autoload": { "psr-4": { "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" @@ -293,7 +286,7 @@ { "name": "Marco Pivetta", "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" + "homepage": "https://ocramius.github.io/" } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", @@ -302,92 +295,60 @@ "constructor", "instantiate" ], - "time": "2019-10-21T16:45:58+00:00" - }, - { - "name": "jean85/pretty-package-versions", - "version": "1.2", - "source": { - "type": "git", - "url": "https://github.com/Jean85/pretty-package-versions.git", - "reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/75c7effcf3f77501d0e0caa75111aff4daa0dd48", - "reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48", - "shasum": "" - }, - "require": { - "ocramius/package-versions": "^1.2.0", - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.4.1" }, - "autoload": { - "psr-4": { - "Jean85\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, { - "name": "Alessandro Lai", - "email": "alessandro.lai85@gmail.com" + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" } ], - "description": "A wrapper for ocramius/package-versions to get pretty versions strings", - "keywords": [ - "composer", - "package", - "release", - "versions" - ], - "time": "2018-06-13T13:22:40+00:00" + "time": "2022-03-03T08:28:38+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.9.5", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, - "replace": { - "myclabs/deep-copy": "self.version" + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" }, "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, "files": [ "src/DeepCopy/deep_copy.php" - ] + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -401,119 +362,99 @@ "object", "object graph" ], - "time": "2020-01-17T21:11:47+00:00" + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2022-03-03T13:19:32+00:00" }, { - "name": "nette/bootstrap", - "version": "v3.0.1", + "name": "nikic/php-parser", + "version": "v4.15.1", "source": { "type": "git", - "url": "https://github.com/nette/bootstrap.git", - "reference": "b45a1e33b6a44beb307756522396551e5a9ff249" + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/bootstrap/zipball/b45a1e33b6a44beb307756522396551e5a9ff249", - "reference": "b45a1e33b6a44beb307756522396551e5a9ff249", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", + "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", "shasum": "" }, "require": { - "nette/di": "^3.0", - "nette/utils": "^3.0", - "php": ">=7.1" - }, - "conflict": { - "tracy/tracy": "<2.6" + "ext-tokenizer": "*", + "php": ">=7.0" }, "require-dev": { - "latte/latte": "^2.2", - "nette/application": "^3.0", - "nette/caching": "^3.0", - "nette/database": "^3.0", - "nette/forms": "^3.0", - "nette/http": "^3.0", - "nette/mail": "^3.0", - "nette/robot-loader": "^3.0", - "nette/safe-stream": "^2.2", - "nette/security": "^3.0", - "nette/tester": "^2.0", - "tracy/tracy": "^2.6" - }, - "suggest": { - "nette/robot-loader": "to use Configurator::createRobotLoader()", - "tracy/tracy": "to use Configurator::enableTracy()" + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" }, + "bin": [ + "bin/php-parse" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.9-dev" } }, "autoload": { - "classmap": [ - "src/" - ] + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause", - "GPL-2.0", - "GPL-3.0" + "BSD-3-Clause" ], "authors": [ { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" + "name": "Nikita Popov" } ], - "description": "🅱 Nette Bootstrap: the simple way to configure and bootstrap your Nette application.", - "homepage": "https://nette.org", + "description": "A PHP parser written in PHP", "keywords": [ - "bootstrapping", - "configurator", - "nette" + "parser", + "php" ], - "time": "2019-09-30T08:19:38+00:00" + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.1" + }, + "time": "2022-09-04T07:30:47+00:00" }, { - "name": "nette/di", - "version": "v3.0.3", + "name": "phar-io/manifest", + "version": "2.0.3", "source": { "type": "git", - "url": "https://github.com/nette/di.git", - "reference": "77d69061cbf8f9cfb7363dd983136f51213d3e41" + "url": "https://github.com/phar-io/manifest.git", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/di/zipball/77d69061cbf8f9cfb7363dd983136f51213d3e41", - "reference": "77d69061cbf8f9cfb7363dd983136f51213d3e41", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", "shasum": "" }, "require": { - "ext-tokenizer": "*", - "nette/neon": "^3.0", - "nette/php-generator": "^3.3.3", - "nette/robot-loader": "^3.2", - "nette/schema": "^1.0", - "nette/utils": "^3.1", - "php": ">=7.1" - }, - "conflict": { - "nette/bootstrap": "<3.0" - }, - "require-dev": { - "nette/tester": "^2.2", - "phpstan/phpstan": "^0.12", - "tracy/tracy": "^2.3" + "ext-dom": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -523,65 +464,50 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause", - "GPL-2.0-only", - "GPL-3.0-only" + "BSD-3-Clause" ], "authors": [ { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" }, { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" } ], - "description": "💎 Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfectly usable autowiring and support for all new PHP 7.1 features.", - "homepage": "https://nette.org", - "keywords": [ - "compiled", - "di", - "dic", - "factory", - "ioc", - "nette", - "static" - ], - "time": "2020-01-20T12:14:54+00:00" + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.3" + }, + "time": "2021-07-20T11:28:43+00:00" }, { - "name": "nette/finder", - "version": "v2.5.2", + "name": "phar-io/version", + "version": "3.2.1", "source": { "type": "git", - "url": "https://github.com/nette/finder.git", - "reference": "4ad2c298eb8c687dd0e74ae84206a4186eeaed50" + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/finder/zipball/4ad2c298eb8c687dd0e74ae84206a4186eeaed50", - "reference": "4ad2c298eb8c687dd0e74ae84206a4186eeaed50", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", "shasum": "" }, "require": { - "nette/utils": "^2.4 || ^3.0", - "php": ">=7.1" - }, - "conflict": { - "nette/nette": "<2.2" - }, - "require-dev": { - "nette/tester": "^2.0", - "phpstan/phpstan": "^0.12", - "tracy/tracy": "^2.3" + "php": "^7.2 || ^8.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev" - } - }, "autoload": { "classmap": [ "src/" @@ -589,119 +515,131 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause", - "GPL-2.0", - "GPL-3.0" + "BSD-3-Clause" ], "authors": [ { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" }, { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" } ], - "description": "🔍 Nette Finder: find files and directories with an intuitive API.", - "homepage": "https://nette.org", - "keywords": [ - "filesystem", - "glob", - "iterator", - "nette" - ], - "time": "2020-01-03T20:35:40+00:00" + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" }, { - "name": "nette/neon", - "version": "v3.1.2", + "name": "phpstan/phpstan", + "version": "1.8.6", "source": { "type": "git", - "url": "https://github.com/nette/neon.git", - "reference": "3c3dcbc6bf6c80dc97b1fc4ba9a22ae67930fc0e" + "url": "https://github.com/phpstan/phpstan.git", + "reference": "c386ab2741e64cc9e21729f891b28b2b10fe6618" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/neon/zipball/3c3dcbc6bf6c80dc97b1fc4ba9a22ae67930fc0e", - "reference": "3c3dcbc6bf6c80dc97b1fc4ba9a22ae67930fc0e", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c386ab2741e64cc9e21729f891b28b2b10fe6618", + "reference": "c386ab2741e64cc9e21729f891b28b2b10fe6618", "shasum": "" }, "require": { - "ext-iconv": "*", - "ext-json": "*", - "php": ">=7.1" + "php": "^7.2|^8.0" }, - "require-dev": { - "nette/tester": "^2.0", - "phpstan/phpstan": "^0.12", - "tracy/tracy": "^2.3" + "conflict": { + "phpstan/phpstan-shim": "*" }, + "bin": [ + "phpstan", + "phpstan.phar" + ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1-dev" - } - }, "autoload": { - "classmap": [ - "src/" + "files": [ + "bootstrap.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause", - "GPL-2.0-only", - "GPL-3.0-only" + "MIT" ], - "authors": [ + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.8.6" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" + "url": "https://github.com/phpstan", + "type": "github" }, { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" } ], - "description": "🍸 Nette NEON: encodes and decodes NEON file format.", - "homepage": "https://ne-on.org", - "keywords": [ - "export", - "import", - "neon", - "nette", - "yaml" - ], - "time": "2020-03-04T11:47:04+00:00" + "time": "2022-09-23T09:54:39+00:00" }, { - "name": "nette/php-generator", - "version": "v3.3.4", + "name": "phpunit/php-code-coverage", + "version": "9.2.17", "source": { "type": "git", - "url": "https://github.com/nette/php-generator.git", - "reference": "8fe7e699dca7db186f56d75800cb1ec32e39c856" + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/php-generator/zipball/8fe7e699dca7db186f56d75800cb1ec32e39c856", - "reference": "8fe7e699dca7db186f56d75800cb1ec32e39c856", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8", + "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8", "shasum": "" }, "require": { - "nette/utils": "^2.4.2 || ^3.0", - "php": ">=7.1" + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.14", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0.3", + "sebastian/version": "^3.0.1", + "theseer/tokenizer": "^1.2.0" }, "require-dev": { - "nette/tester": "^2.0", - "phpstan/phpstan": "^0.12", - "tracy/tracy": "^2.3" + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcov": "*", + "ext-xdebug": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "9.2-dev" } }, "autoload": { @@ -711,59 +649,58 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause", - "GPL-2.0-only", - "GPL-3.0-only" + "BSD-3-Clause" ], "authors": [ { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.4 features.", - "homepage": "https://nette.org", + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", "keywords": [ - "code", - "nette", - "php", - "scaffolding" + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.17" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2020-02-09T14:39:09+00:00" + "time": "2022-08-30T12:24:04+00:00" }, { - "name": "nette/robot-loader", - "version": "v3.2.3", + "name": "phpunit/php-file-iterator", + "version": "3.0.6", "source": { "type": "git", - "url": "https://github.com/nette/robot-loader.git", - "reference": "726c462e73e739e965ec654a667407074cfe83c0" + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/robot-loader/zipball/726c462e73e739e965ec654a667407074cfe83c0", - "reference": "726c462e73e739e965ec654a667407074cfe83c0", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", "shasum": "" }, "require": { - "ext-tokenizer": "*", - "nette/finder": "^2.5 || ^3.0", - "nette/utils": "^3.0", - "php": ">=7.1" + "php": ">=7.3" }, "require-dev": { - "nette/tester": "^2.0", - "phpstan/phpstan": "^0.12", - "tracy/tracy": "^2.3" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -773,117 +710,56 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause", - "GPL-2.0-only", - "GPL-3.0-only" + "BSD-3-Clause" ], "authors": [ { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.", - "homepage": "https://nette.org", + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", "keywords": [ - "autoload", - "class", - "interface", - "nette", - "trait" + "filesystem", + "iterator" ], - "time": "2020-02-28T13:10:07+00:00" - }, - { - "name": "nette/schema", - "version": "v1.0.2", - "source": { - "type": "git", - "url": "https://github.com/nette/schema.git", - "reference": "febf71fb4052c824046f5a33f4f769a6e7fa0cb4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nette/schema/zipball/febf71fb4052c824046f5a33f4f769a6e7fa0cb4", - "reference": "febf71fb4052c824046f5a33f4f769a6e7fa0cb4", - "shasum": "" - }, - "require": { - "nette/utils": "^3.1", - "php": ">=7.1" - }, - "require-dev": { - "nette/tester": "^2.2", - "phpstan/phpstan-nette": "^0.12", - "tracy/tracy": "^2.3" - }, - "type": "library", - "extra": { - "branch-alias": [] - }, - "autoload": { - "classmap": [ - "src/" - ] + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause", - "GPL-2.0", - "GPL-3.0" - ], - "authors": [ - { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, + "funding": [ { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" + "url": "https://github.com/sebastianbergmann", + "type": "github" } ], - "description": "📐 Nette Schema: validating data structures against a given Schema.", - "homepage": "https://nette.org", - "keywords": [ - "config", - "nette" - ], - "time": "2020-01-06T22:52:48+00:00" + "time": "2021-12-02T12:48:52+00:00" }, { - "name": "nette/utils", - "version": "v3.1.1", + "name": "phpunit/php-invoker", + "version": "3.1.1", "source": { "type": "git", - "url": "https://github.com/nette/utils.git", - "reference": "2c17d16d8887579ae1c0898ff94a3668997fd3eb" + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/2c17d16d8887579ae1c0898ff94a3668997fd3eb", - "reference": "2c17d16d8887579ae1c0898ff94a3668997fd3eb", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.3" }, "require-dev": { - "nette/tester": "~2.0", - "phpstan/phpstan": "^0.12", - "tracy/tracy": "^2.3" + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" }, "suggest": { - "ext-gd": "to use Image", - "ext-iconv": "to use Strings::webalize() and toAscii()", - "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", - "ext-json": "to use Nette\\Utils\\Json", - "ext-mbstring": "to use Strings::lower() etc...", - "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()", - "ext-xml": "to use Strings::length() etc. when mbstring is not available" + "ext-pcntl": "*" }, "type": "library", "extra": { @@ -898,75 +774,62 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause", - "GPL-2.0-only", - "GPL-3.0-only" + "BSD-3-Clause" ], "authors": [ { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", - "homepage": "https://nette.org", + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", "keywords": [ - "array", - "core", - "datetime", - "images", - "json", - "nette", - "paginator", - "password", - "slugify", - "string", - "unicode", - "utf-8", - "utility", - "validation" - ], - "time": "2020-02-09T14:10:55+00:00" + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" }, { - "name": "nikic/php-parser", - "version": "v4.2.5", + "name": "phpunit/php-text-template", + "version": "2.0.4", "source": { "type": "git", - "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "b76bbc3c51f22c570648de48e8c2d941ed5e2cf2" + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/b76bbc3c51f22c570648de48e8c2d941ed5e2cf2", - "reference": "b76bbc3c51f22c570648de48e8c2d941ed5e2cf2", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", "shasum": "" }, "require": { - "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.3" }, "require-dev": { - "ircmaxell/php-yacc": "0.0.4", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0" + "phpunit/phpunit": "^9.3" }, - "bin": [ - "bin/php-parse" - ], "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "2.0-dev" } }, "autoload": { - "psr-4": { - "PhpParser\\": "lib/PhpParser" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -974,104 +837,147 @@ ], "authors": [ { - "name": "Nikita Popov" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "A PHP parser written in PHP", + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", "keywords": [ - "parser", - "php" + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2019-10-25T18:33:07+00:00" + "time": "2020-10-26T05:33:50+00:00" }, { - "name": "ocramius/package-versions", - "version": "1.7.0", + "name": "phpunit/php-timer", + "version": "5.0.3", "source": { "type": "git", - "url": "https://github.com/Ocramius/PackageVersions.git", - "reference": "651c372efc914aea8223e049f85afaf65e09ba23" + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/651c372efc914aea8223e049f85afaf65e09ba23", - "reference": "651c372efc914aea8223e049f85afaf65e09ba23", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", "shasum": "" }, "require": { - "composer-plugin-api": "^1.1.0", - "php": "^7.4.0" + "php": ">=7.3" }, "require-dev": { - "composer/composer": "^1.9.3", - "doctrine/coding-standard": "^7.0.2", - "ext-zip": "^1.15.0", - "infection/infection": "^0.15.3", - "phpunit/phpunit": "^9.0.1", - "vimeo/psalm": "^3.9.3" - }, - "type": "composer-plugin", + "phpunit/phpunit": "^9.3" + }, + "type": "library", "extra": { - "class": "PackageVersions\\Installer", "branch-alias": { - "dev-master": "1.99.x-dev" + "dev-master": "5.0-dev" } }, "autoload": { - "psr-4": { - "PackageVersions\\": "src/PackageVersions" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, "funding": [ { - "url": "https://github.com/Ocramius", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/ocramius/package-versions", - "type": "tidelift" } ], - "time": "2020-03-06T11:34:16+00:00" + "time": "2020-10-26T13:16:10+00:00" }, { - "name": "phar-io/manifest", - "version": "1.0.3", + "name": "phpunit/phpunit", + "version": "9.5.25", "source": { "type": "git", - "url": "https://github.com/phar-io/manifest.git", - "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", - "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d", + "reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.3.1", "ext-dom": "*", - "ext-phar": "*", - "phar-io/version": "^2.0", - "php": "^5.6 || ^7.0" + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.10.1", + "phar-io/manifest": "^2.0.3", + "phar-io/version": "^3.0.2", + "php": ">=7.3", + "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.3", + "phpunit/php-timer": "^5.0.2", + "sebastian/cli-parser": "^1.0.1", + "sebastian/code-unit": "^1.0.6", + "sebastian/comparator": "^4.0.8", + "sebastian/diff": "^4.0.3", + "sebastian/environment": "^5.1.3", + "sebastian/exporter": "^4.0.5", + "sebastian/global-state": "^5.0.1", + "sebastian/object-enumerator": "^4.0.3", + "sebastian/resource-operations": "^3.0.3", + "sebastian/type": "^3.2", + "sebastian/version": "^3.0.2" }, + "suggest": { + "ext-soap": "*", + "ext-xdebug": "*" + }, + "bin": [ + "phpunit" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "9.5-dev" } }, "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], "classmap": [ "src/" ] @@ -1082,42 +988,64 @@ ], "authors": [ { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.25" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" }, { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" + "url": "https://github.com/sebastianbergmann", + "type": "github" }, { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" } ], - "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2018-07-08T19:23:20+00:00" + "time": "2022-09-25T03:44:45+00:00" }, { - "name": "phar-io/version", - "version": "2.0.1", + "name": "sebastian/cli-parser", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/phar-io/version.git", - "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", - "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -1128,450 +1056,504 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de", - "role": "Developer" + "role": "lead" } ], - "description": "Library for handling version information and constraints", - "time": "2018-07-08T19:19:57+00:00" + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:08:49+00:00" }, { - "name": "phpdocumentor/reflection-common", - "version": "2.0.0", + "name": "sebastian/code-unit", + "version": "1.0.8", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "~6" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "1.0-dev" } }, "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2018-08-07T13:53:10+00:00" + "time": "2020-10-26T13:08:54+00:00" }, { - "name": "phpdocumentor/reflection-docblock", - "version": "5.1.0", + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e" + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", - "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", "shasum": "" }, "require": { - "ext-filter": "^7.1", - "php": "^7.2", - "phpdocumentor/reflection-common": "^2.0", - "phpdocumentor/type-resolver": "^1.0", - "webmozart/assert": "^1" + "php": ">=7.3" }, "require-dev": { - "doctrine/instantiator": "^1", - "mockery/mockery": "^1" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.x-dev" + "dev-master": "2.0-dev" } }, "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ { - "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" + "url": "https://github.com/sebastianbergmann", + "type": "github" } ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2020-02-22T12:28:44+00:00" + "time": "2020-09-28T05:30:19+00:00" }, { - "name": "phpdocumentor/type-resolver", - "version": "1.1.0", + "name": "sebastian/comparator", + "version": "4.0.8", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "7462d5f123dfc080dfdf26897032a6513644fc95" + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95", - "reference": "7462d5f123dfc080dfdf26897032a6513644fc95", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", "shasum": "" }, "require": { - "php": "^7.2", - "phpdocumentor/reflection-common": "^2.0" + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" }, "require-dev": { - "ext-tokenizer": "^7.2", - "mockery/mockery": "~1" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2020-02-18T18:59:58+00:00" + "time": "2022-09-14T12:41:17+00:00" }, { - "name": "phpspec/prophecy", - "version": "v1.10.3", + "name": "sebastian/complexity", + "version": "2.0.2", "source": { "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "451c3cd1418cf640de218914901e51b064abb093" + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", - "reference": "451c3cd1418cf640de218914901e51b064abb093", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" + "nikic/php-parser": "^4.7", + "php": ">=7.3" }, "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.10.x-dev" + "dev-master": "2.0-dev" } }, "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + }, + "funding": [ { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" + "url": "https://github.com/sebastianbergmann", + "type": "github" } ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2020-03-05T15:02:03+00:00" + "time": "2020-10-26T15:52:27+00:00" }, { - "name": "phpstan/phpdoc-parser", - "version": "0.3.5", + "name": "sebastian/diff", + "version": "4.0.4", "source": { "type": "git", - "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "8c4ef2aefd9788238897b678a985e1d5c8df6db4" + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/8c4ef2aefd9788238897b678a985e1d5c8df6db4", - "reference": "8c4ef2aefd9788238897b678a985e1d5c8df6db4", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", "shasum": "" }, "require": { - "php": "~7.1" + "php": ">=7.3" }, "require-dev": { - "consistence/coding-standard": "^3.5", - "jakub-onderka/php-parallel-lint": "^0.9.2", - "phing/phing": "^2.16.0", - "phpstan/phpstan": "^0.10", - "phpunit/phpunit": "^6.3", - "slevomat/coding-standard": "^4.7.2", - "squizlabs/php_codesniffer": "^3.3.2", - "symfony/process": "^3.4 || ^4.0" + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "0.3-dev" + "dev-master": "4.0-dev" } }, "autoload": { - "psr-4": { - "PHPStan\\PhpDocParser\\": [ - "src/" - ] - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "description": "PHPDoc parser with support for nullable, intersection and generic types", - "time": "2019-06-07T19:13:52+00:00" + "time": "2020-10-26T13:10:38+00:00" }, { - "name": "phpstan/phpstan", - "version": "0.10.9", + "name": "sebastian/environment", + "version": "5.1.4", "source": { "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "61840df60f50e186683ba35ece82efb66bd0ab2c" + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/61840df60f50e186683ba35ece82efb66bd0ab2c", - "reference": "61840df60f50e186683ba35ece82efb66bd0ab2c", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", "shasum": "" }, "require": { - "composer/xdebug-handler": "^1.3.0", - "jean85/pretty-package-versions": "^1.0.3", - "nette/bootstrap": "^2.4 || ^3.0", - "nette/di": "^2.4.7 || ^3.0", - "nette/robot-loader": "^3.0.1", - "nette/utils": "^2.4.5 || ^3.0", - "nikic/php-parser": "4.0.2 - 4.2.5", - "php": "~7.1", - "phpstan/phpdoc-parser": "^0.3", - "symfony/console": "~3.2 || ~4.0", - "symfony/finder": "~3.2 || ~4.0" - }, - "conflict": { - "symfony/console": "3.4.16 || 4.1.5" + "php": ">=7.3" }, "require-dev": { - "brianium/paratest": "^2.0", - "consistence/coding-standard": "^3.5", - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", - "ext-gd": "*", - "ext-intl": "*", - "ext-mysqli": "*", - "ext-zip": "*", - "jakub-onderka/php-parallel-lint": "^1.0", - "localheinz/composer-normalize": "~0.9.0", - "phing/phing": "^2.16.0", - "phpstan/phpstan-deprecation-rules": "^0.10.2", - "phpstan/phpstan-php-parser": "^0.10", - "phpstan/phpstan-phpunit": "^0.10", - "phpstan/phpstan-strict-rules": "^0.10", - "phpunit/phpunit": "^7.0", - "slevomat/coding-standard": "^4.7.2", - "squizlabs/php_codesniffer": "^3.3.2" + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" }, - "bin": [ - "bin/phpstan" - ], "type": "library", "extra": { "branch-alias": { - "dev-master": "0.10-dev" + "dev-master": "5.1-dev" } }, "autoload": { - "psr-4": { - "PHPStan\\": [ - "src/", - "build/PHPStan" - ] - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], - "description": "PHPStan - PHP Static Analysis Tool", - "time": "2020-01-07T15:26:30+00:00" + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2022-04-03T09:37:03+00:00" }, { - "name": "phpstan/phpstan-doctrine", - "version": "0.10", + "name": "sebastian/exporter", + "version": "4.0.5", "source": { "type": "git", - "url": "https://github.com/phpstan/phpstan-doctrine.git", - "reference": "a0314b1fa5b4d76880e4e9542ee01f3df8471630" + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/a0314b1fa5b4d76880e4e9542ee01f3df8471630", - "reference": "a0314b1fa5b4d76880e4e9542ee01f3df8471630", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", "shasum": "" }, "require": { - "nikic/php-parser": "^4.0", - "php": "~7.1", - "phpstan/phpstan": "^0.10" - }, - "conflict": { - "doctrine/collections": "<1.0", - "doctrine/common": "<2.7", - "doctrine/orm": "<2.5" + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" }, "require-dev": { - "consistence/coding-standard": "^3.0.1", - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", - "doctrine/collections": "^1.0", - "doctrine/common": "^2.7", - "doctrine/orm": "^2.5", - "jakub-onderka/php-parallel-lint": "^1.0", - "phing/phing": "^2.16.0", - "phpstan/phpstan-phpunit": "^0.10", - "phpstan/phpstan-strict-rules": "^0.10", - "phpunit/phpunit": "^7.0", - "slevomat/coding-standard": "^4.5.2" + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "0.10-dev" + "dev-master": "4.0-dev" } }, "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "description": "Doctrine extensions for PHPStan", - "time": "2018-05-28T20:08:30+00:00" + "time": "2022-09-14T06:03:37+00:00" }, { - "name": "phpunit/php-code-coverage", - "version": "6.1.4", + "name": "sebastian/global-state", + "version": "5.0.5", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d" + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", "shasum": "" }, "require": { - "ext-dom": "*", - "ext-xmlwriter": "*", - "php": "^7.1", - "phpunit/php-file-iterator": "^2.0", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.0", - "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.1 || ^4.0", - "sebastian/version": "^2.0.1", - "theseer/tokenizer": "^1.1" + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "ext-dom": "*", + "phpunit/phpunit": "^9.3" }, "suggest": { - "ext-xdebug": "^2.6.0" + "ext-uopz": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.1-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -1586,43 +1568,51 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "email": "sebastian@phpunit.de" } ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", "keywords": [ - "coverage", - "testing", - "xunit" + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2018-10-31T16:06:48+00:00" + "time": "2022-02-14T08:28:10+00:00" }, { - "name": "phpunit/php-file-iterator", - "version": "2.0.2", + "name": "sebastian/lines-of-code", + "version": "1.0.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "050bedf145a257b1ff02746c31894800e5122946" + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", - "reference": "050bedf145a257b1ff02746c31894800e5122946", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", "shasum": "" }, "require": { - "php": "^7.1" + "nikic/php-parser": "^4.6", + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^7.1" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -1641,32 +1631,48 @@ "role": "lead" } ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2018-09-13T20:33:42+00:00" + "time": "2020-11-28T06:42:11+00:00" }, { - "name": "phpunit/php-text-template", - "version": "1.2.1", + "name": "sebastian/object-enumerator", + "version": "4.0.4", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -1679,41 +1685,47 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "email": "sebastian@phpunit.de" } ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2015-06-21T13:50:34+00:00" + "time": "2020-10-26T13:12:34+00:00" }, { - "name": "phpunit/php-timer", - "version": "2.1.2", + "name": "sebastian/object-reflector", + "version": "2.0.4", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", "shasum": "" }, "require": { - "php": "^7.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1728,42 +1740,47 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "email": "sebastian@phpunit.de" } ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2019-06-07T04:22:29+00:00" + "time": "2020-10-26T13:14:26+00:00" }, { - "name": "phpunit/php-token-stream", - "version": "3.1.1", + "name": "sebastian/recursion-context", + "version": "4.0.4", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", "shasum": "" }, "require": { - "ext-tokenizer": "*", - "php": "^7.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1779,1159 +1796,269 @@ { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2019-09-17T06:23:10+00:00" - }, - { - "name": "phpunit/phpunit", - "version": "7.5.20", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9467db479d1b0487c99733bb1e7944d32deded2c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9467db479d1b0487c99733bb1e7944d32deded2c", - "reference": "9467db479d1b0487c99733bb1e7944d32deded2c", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.1", - "ext-dom": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "myclabs/deep-copy": "^1.7", - "phar-io/manifest": "^1.0.2", - "phar-io/version": "^2.0", - "php": "^7.1", - "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^6.0.7", - "phpunit/php-file-iterator": "^2.0.1", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.1", - "sebastian/comparator": "^3.0", - "sebastian/diff": "^3.0", - "sebastian/environment": "^4.0", - "sebastian/exporter": "^3.1", - "sebastian/global-state": "^2.0", - "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^2.0", - "sebastian/version": "^2.0.1" - }, - "conflict": { - "phpunit/phpunit-mock-objects": "*" - }, - "require-dev": { - "ext-pdo": "*" - }, - "suggest": { - "ext-soap": "*", - "ext-xdebug": "*", - "phpunit/php-invoker": "^2.0" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "7.5-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2020-01-08T08:45:45+00:00" - }, - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "time": "2017-02-14T16:28:37+00:00" - }, - { - "name": "psr/log", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2019-11-01T11:05:21+00:00" - }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04T06:30:41+00:00" - }, - { - "name": "sebastian/comparator", - "version": "3.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", - "shasum": "" - }, - "require": { - "php": "^7.1", - "sebastian/diff": "^3.0", - "sebastian/exporter": "^3.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "https://github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2018-07-12T15:12:46+00:00" - }, - { - "name": "sebastian/diff", - "version": "3.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.5 || ^8.0", - "symfony/process": "^2 || ^3.3 || ^4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff", - "udiff", - "unidiff", - "unified diff" - ], - "time": "2019-02-04T06:01:07+00:00" - }, - { - "name": "sebastian/environment", - "version": "4.2.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368", - "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.5" - }, - "suggest": { - "ext-posix": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.2-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2019-11-20T08:46:58+00:00" - }, - { - "name": "sebastian/exporter", - "version": "3.1.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", - "shasum": "" - }, - "require": { - "php": "^7.0", - "sebastian/recursion-context": "^3.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2019-09-14T09:02:43+00:00" - }, - { - "name": "sebastian/global-state", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2017-04-27T15:39:26+00:00" - }, - { - "name": "sebastian/object-enumerator", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "shasum": "" - }, - "require": { - "php": "^7.0", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-08-03T12:35:26+00:00" - }, - { - "name": "sebastian/object-reflector", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "773f97c67f28de00d397be301821b06708fca0be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", - "reference": "773f97c67f28de00d397be301821b06708fca0be", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Allows reflection of object attributes, including inherited and non-public ones", - "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "time": "2017-03-29T09:07:27+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2017-03-03T06:23:57+00:00" - }, - { - "name": "sebastian/resource-operations", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2018-10-04T04:07:39+00:00" - }, - { - "name": "sebastian/version", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ + }, { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" } ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-10-03T07:35:21+00:00" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "3.5.4", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "dceec07328401de6211037abbb18bda423677e26" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dceec07328401de6211037abbb18bda423677e26", - "reference": "dceec07328401de6211037abbb18bda423677e26", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" - }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ + "funding": [ { - "name": "Greg Sherwood", - "role": "lead" + "url": "https://github.com/sebastianbergmann", + "type": "github" } ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", - "keywords": [ - "phpcs", - "standards" - ], - "time": "2020-01-30T22:20:29+00:00" + "time": "2020-10-26T13:17:30+00:00" }, { - "name": "symfony/console", - "version": "v4.4.5", + "name": "sebastian/resource-operations", + "version": "3.0.3", "source": { "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "4fa15ae7be74e53f6ec8c83ed403b97e23b665e9" + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/4fa15ae7be74e53f6ec8c83ed403b97e23b665e9", - "reference": "4fa15ae7be74e53f6ec8c83ed403b97e23b665e9", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", "shasum": "" }, "require": { - "php": "^7.1.3", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.8", - "symfony/service-contracts": "^1.1|^2" - }, - "conflict": { - "symfony/dependency-injection": "<3.4", - "symfony/event-dispatcher": "<4.3|>=5", - "symfony/lock": "<4.4", - "symfony/process": "<3.3" - }, - "provide": { - "psr/log-implementation": "1.0" + "php": ">=7.3" }, "require-dev": { - "psr/log": "~1.0", - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/event-dispatcher": "^4.3", - "symfony/lock": "^4.4|^5.0", - "symfony/process": "^3.4|^4.0|^5.0", - "symfony/var-dumper": "^4.3|^5.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" } ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2020-02-24T13:10:00+00:00" + "time": "2020-09-28T06:45:17+00:00" }, { - "name": "symfony/finder", - "version": "v4.4.5", + "name": "sebastian/type", + "version": "3.2.0", "source": { "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "ea69c129aed9fdeca781d4b77eb20b62cf5d5357" + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ea69c129aed9fdeca781d4b77eb20b62cf5d5357", - "reference": "ea69c129aed9fdeca781d4b77eb20b62cf5d5357", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "3.2-dev" } }, "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" + }, "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2020-02-14T07:42:58+00:00" + "time": "2022-09-12T14:47:03+00:00" }, { - "name": "symfony/polyfill-mbstring", - "version": "v1.14.0", + "name": "sebastian/version", + "version": "3.0.2", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2" + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c6c1022351a901512170118436c764e473f6de8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/34094cfa9abe1f0f14f48f490772db7a775559f2", - "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", "shasum": "" }, "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" + "php": ">=7.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.14-dev" + "dev-master": "3.0-dev" } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "time": "2020-01-13T11:15:53+00:00" - }, - { - "name": "symfony/polyfill-php73", - "version": "v1.14.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "5e66a0fa1070bf46bec4bea7962d285108edd675" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/5e66a0fa1070bf46bec4bea7962d285108edd675", - "reference": "5e66a0fa1070bf46bec4bea7962d285108edd675", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.14-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, + "funding": [ { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "url": "https://github.com/sebastianbergmann", + "type": "github" } ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2020-01-13T11:15:53+00:00" + "time": "2020-09-28T06:39:44+00:00" }, { - "name": "symfony/service-contracts", - "version": "v2.0.1", + "name": "squizlabs/php_codesniffer", + "version": "3.7.1", "source": { "type": "git", - "url": "https://github.com/symfony/service-contracts.git", - "reference": "144c5e51266b281231e947b51223ba14acf1a749" + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/144c5e51266b281231e947b51223ba14acf1a749", - "reference": "144c5e51266b281231e947b51223ba14acf1a749", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", "shasum": "" }, "require": { - "php": "^7.2.5", - "psr/container": "^1.0" + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" }, - "suggest": { - "symfony/service-implementation": "" + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\Service\\": "" + "dev-master": "3.x-dev" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Greg Sherwood", + "role": "lead" } ], - "description": "Generic abstractions related to writing services", - "homepage": "https://symfony.com", + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", + "phpcs", "standards" ], - "time": "2019-11-18T17:27:11+00:00" + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2022-06-18T07:21:10+00:00" }, { "name": "theseer/tokenizer", - "version": "1.1.3", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", "shasum": "" }, "require": { "ext-dom": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": "^7.0" + "php": "^7.2 || ^8.0" }, "type": "library", "autoload": { @@ -2951,55 +2078,17 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2019-06-13T22:48:21+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.7.0", - "source": { - "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "aed98a490f9a8f78468232db345ab9cf606cf598" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598", - "reference": "aed98a490f9a8f78468232db345ab9cf606cf598", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "vimeo/psalm": "<3.6.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^7.5.13" + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.1" }, - "type": "library", - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ + "funding": [ { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" + "url": "https://github.com/theseer", + "type": "github" } ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "time": "2020-02-14T12:15:55+00:00" + "time": "2021-07-28T10:34:58+00:00" } ], "aliases": [], @@ -3008,11 +2097,11 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.4" + "php": ">=8" }, "platform-dev": [], "platform-overrides": { - "php": "7.4" + "php": "8" }, - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.3.0" } diff --git a/docker-compose.yml b/docker-compose.yml index 9692b69..0719bd6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,3 +8,4 @@ services: restart: on-failure volumes: - ./:/code + - ./docker/php-cli/php.ini:/usr/local/etc/php/php.ini:ro diff --git a/docker/php-cli/Dockerfile b/docker/php-cli/Dockerfile index f4fb48b..f603d61 100644 --- a/docker/php-cli/Dockerfile +++ b/docker/php-cli/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7-cli-alpine +FROM php:8-cli-alpine RUN apk update \ && apk add git \ diff --git a/docker/php-cli/php.ini b/docker/php-cli/php.ini new file mode 100644 index 0000000..4cc5da2 --- /dev/null +++ b/docker/php-cli/php.ini @@ -0,0 +1,12 @@ +date.timezone = ${TIMEZONE} +short_open_tag = Off +log_errors = On +error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT +display_errors = Off +error_log = /proc/self/fd/2 +memory_limit = -1 + +; Optimizations for Symfony, as documented on http://symfony.com/doc/current/performance.html +opcache.max_accelerated_files = 20000 +realpath_cache_size = 4096K +realpath_cache_ttl = 600 diff --git a/phpstan.neon b/phpstan.neon index e2cec94..c2b7eeb 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,2 +1,6 @@ -includes: - - config.level7.neon +parameters: + level: 7 + excludePaths: + # only because of the refactoring + - src/TicTacToe/Application.php + - src/TicTacToe/Board.php \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml index 3f8192b..868e457 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,18 +1,16 @@ - - - - ./tests/unit - - - - - ./src/TicTacToe/ - - ./vendor/ - - - + + + + ./src/TicTacToe/ + + + ./vendor/ + + + + + ./tests/unit + + diff --git a/src/TicTacToe/Application.php b/src/TicTacToe/Application.php index d6fc1ba..b0829d9 100644 --- a/src/TicTacToe/Application.php +++ b/src/TicTacToe/Application.php @@ -2,10 +2,6 @@ namespace TicTacToe; -use TicTacToe\Board; -use TicTacToe\IO\IOHandler; -use TicTacToe\Player\HumanPlayer; - class Application { /** diff --git a/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameCommand.php b/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameCommand.php index 62dbf49..db80400 100644 --- a/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameCommand.php +++ b/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameCommand.php @@ -4,22 +4,29 @@ namespace TicTacToe\Engine\Application\CreateNewGame; +use TicTacToe\Engine\Domain\Model\Player\PlayerId; use TicTacToe\Shared\Application\Command; final class CreateNewGameCommand implements Command { - /** @var array */ - private $playerIds; + /** @var array */ + private array $playerIds; - /** @var int */ - private $boardSize; + private int $boardSize; + /** + * @param array $playerIds + * @param int $boardSize + */ public function __construct(array $playerIds, int $boardSize) { $this->playerIds = $playerIds; $this->boardSize = $boardSize; } + /** + * @return array + */ public function playerIds(): array { return $this->playerIds; diff --git a/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameHandler.php b/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameHandler.php index bf22c04..015630f 100644 --- a/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameHandler.php +++ b/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameHandler.php @@ -5,6 +5,7 @@ namespace TicTacToe\Engine\Application\CreateNewGame; use TicTacToe\Engine\Domain\Model\Board\Board; +use TicTacToe\Engine\Domain\Model\Board\Exception\SorryBoardSizeIsNotValid; use TicTacToe\Engine\Domain\Model\Game\Game; use TicTacToe\Engine\Domain\Model\Game\GameId; use TicTacToe\Engine\Domain\Model\Game\GameRepository; @@ -16,8 +17,7 @@ final class CreateNewGameHandler implements CommandHandler { - /** @var GameRepository */ - private $gameRepository; + private GameRepository $gameRepository; public function __construct(GameRepository $gameRepository) { @@ -33,7 +33,9 @@ public function handles(): string } /** + * @param CreateNewGameCommand $command * @inheritDoc + * @throws SorryBoardSizeIsNotValid */ public function handle(Command $command): DataTransformer { diff --git a/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameResponseDto.php b/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameResponseDto.php index 268a42c..15938f0 100644 --- a/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameResponseDto.php +++ b/src/TicTacToe/Engine/Application/CreateNewGame/CreateNewGameResponseDto.php @@ -5,21 +5,19 @@ namespace TicTacToe\Engine\Application\CreateNewGame; use TicTacToe\Engine\Domain\Model\Game\Game; +use TicTacToe\Engine\Domain\Model\Player\PlayerId; use TicTacToe\Shared\Application\DataTransformer; final class CreateNewGameResponseDto implements DataTransformer { - /** @var string */ - private $gameId; + private string $gameId; - /** @var int */ - private $boardSize; + private int $boardSize; - /** @var [] */ - private $playerIds; + /** @var PlayerId[] */ + private array $playerIds; - /** @var \DateTimeImmutable */ - private $createdAt; + private \DateTimeImmutable $createdAt; public function __construct(Game $game) { @@ -39,6 +37,9 @@ public function boardSize(): int return $this->boardSize; } + /** + * @return PlayerId[] + */ public function playerIds(): array { return $this->playerIds; @@ -50,7 +51,7 @@ public function createdAt(): \DateTimeImmutable } /** - * @return array + * @return array|int|string> */ public function toArray(): array { diff --git a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerCommand.php b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerCommand.php index ae80af6..a0c80c1 100644 --- a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerCommand.php +++ b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerCommand.php @@ -8,11 +8,9 @@ final class CreateNewPlayerCommand implements Command { - /** @var string */ - private $name; + private string $name; - /** @var string */ - private $token; + private string $token; public function __construct(string $name, string $token) { diff --git a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerResponseDto.php b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerResponseDto.php index 881ecd2..bd35b80 100644 --- a/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerResponseDto.php +++ b/src/TicTacToe/Engine/Application/CreateNewPlayer/CreateNewPlayerResponseDto.php @@ -9,17 +9,13 @@ final class CreateNewPlayerResponseDto implements DataTransformer { - /** @var string */ - private $playerId; + private string $playerId; - /** @var string */ - private $playerToken; + private string $playerToken; - /** @var string */ - private $playerName; + private string $playerName; - /** @var \DateTimeImmutable */ - private $createdAt; + private \DateTimeImmutable $createdAt; public function __construct(Player $player) { @@ -50,7 +46,7 @@ public function createdAt(): \DateTimeImmutable } /** - * @return array + * @return array */ public function toArray(): array { diff --git a/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php b/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php index de477ee..19b59dc 100644 --- a/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php +++ b/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php @@ -17,18 +17,16 @@ use TicTacToe\Shared\Application\Command; use TicTacToe\Shared\Application\CommandHandler; use TicTacToe\Shared\Application\DataTransformer; +use TicTacToe\Shared\Application\EmptyResponseDto; use TicTacToe\Shared\Application\Exception\SorryWrongCommand; final class PlayNewTurnHandler implements CommandHandler { - /** @var TurnRepository */ - private $turnRepository; + private TurnRepository $turnRepository; - /** @var PlayerRepository */ - private $playerRepository; + private PlayerRepository $playerRepository; - /** @var GameRepository */ - private $gameRepository; + private GameRepository $gameRepository; public function __construct( TurnRepository $turnRepository, @@ -70,6 +68,7 @@ public function handle(Command $command): DataTransformer } $turn = new Turn( + $game->id(), new TurnId(), Cell::createFromPlayerToken($player->playingToken()), new Position($command->position()), @@ -81,5 +80,7 @@ public function handle(Command $command): DataTransformer ); $this->turnRepository->add($turn); + + return new EmptyResponseDto(); } } diff --git a/src/TicTacToe/Engine/Domain/Model/Board/Board.php b/src/TicTacToe/Engine/Domain/Model/Board/Board.php index 42cad71..34e0b4f 100644 --- a/src/TicTacToe/Engine/Domain/Model/Board/Board.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Board.php @@ -10,18 +10,21 @@ final class Board { private const BOARD_SIZE_3 = 3; - /** @var CellSet */ - private $cellSet; + /** @var array */ + private array $cells; - /** @var int */ - private $size; + private int $size; + /** + * @throws SorryBoardSizeIsNotValid + */ public function __construct(int $size) { if ($size != self::BOARD_SIZE_3) { throw new SorryBoardSizeIsNotValid("Only allowed size for board is: " . self::BOARD_SIZE_3); } + $this->cells = []; $this->size = $size; $this->initBoard(); } @@ -31,17 +34,18 @@ public function size(): int return $this->size; } - private function initBoard() + private function initBoard(): void { + /** @var int $position */ foreach (Position::positions() as $position) { - $this->cellSet[$position] = Cell::empty(); + $this->cells[$position] = Cell::empty(); } } public function isFull(): bool { /** @var Cell $cell */ - foreach ($this->cellSet as $cell) { + foreach ($this->cells as $cell) { if ($cell->isEmpty()) { return false; } @@ -50,9 +54,9 @@ public function isFull(): bool return true; } - public function setCell(Position $position, Cell $cell): Board + public function setCell(Position $position, Cell $cell): void { - $this->cellSet[$position->position()] = $cell; + $this->cells[$position->position()] = $cell; } public static function create3By3Board(): Board diff --git a/src/TicTacToe/Engine/Domain/Model/Board/Cell.php b/src/TicTacToe/Engine/Domain/Model/Board/Cell.php index 1cf7324..f29db51 100644 --- a/src/TicTacToe/Engine/Domain/Model/Board/Cell.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Cell.php @@ -8,8 +8,7 @@ final class Cell { - /** @var string */ - private $value; + private string $value; public function __construct(string $value = '') { @@ -18,7 +17,7 @@ public function __construct(string $value = '') public function __toString(): string { - return (string) $this->value; + return $this->value; } public function isEmpty(): bool diff --git a/src/TicTacToe/Engine/Domain/Model/Board/CellSet.php b/src/TicTacToe/Engine/Domain/Model/Board/CellSet.php index ea4e1ee..5e20459 100644 --- a/src/TicTacToe/Engine/Domain/Model/Board/CellSet.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/CellSet.php @@ -3,12 +3,15 @@ namespace TicTacToe\Engine\Domain\Model\Board; -use Traversable; +use Iterator; +/** + * @implements \IteratorAggregate + */ final class CellSet implements \Countable, \IteratorAggregate { /** @var Cell[] */ - private $cells; + private array $cells; public function __construct(Cell ...$cells) { @@ -19,17 +22,20 @@ public function __construct(Cell ...$cells) $this->cells = $cells; } + /** + * @return Cell[] + */ public function toArray(): array { return $this->cells; } - public function getIterator() + public function getIterator(): Iterator { return new \ArrayIterator($this->toArray()); } - public function count() + public function count(): int { return count($this->cells); } diff --git a/src/TicTacToe/Engine/Domain/Model/Board/Position.php b/src/TicTacToe/Engine/Domain/Model/Board/Position.php index 0041c2c..dd2a3a0 100644 --- a/src/TicTacToe/Engine/Domain/Model/Board/Position.php +++ b/src/TicTacToe/Engine/Domain/Model/Board/Position.php @@ -11,8 +11,7 @@ final class Position 0, 1, 2, 3, 4, 5, 6, 7, 8 ]; - /** @var int */ - private $position; + private int $position; public function __construct(int $position) { @@ -26,6 +25,9 @@ public function position(): int return $this->position; } + /** + * @return array + */ public static function positions(): array { return self::VALID_POSITIONS; diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php b/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php index 83ea37e..a4ca3b0 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Event/GameCreated.php @@ -9,8 +9,7 @@ final class GameCreated implements Event { - /** @var Game */ - private $game; + private Game $game; public function __construct(Game $game) { diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Event/PlayerTurnPlayed.php b/src/TicTacToe/Engine/Domain/Model/Game/Event/PlayerTurnPlayed.php index 841a525..abdecc0 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/Event/PlayerTurnPlayed.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Event/PlayerTurnPlayed.php @@ -8,8 +8,7 @@ final class PlayerTurnPlayed implements Event { - /** @var Turn */ - private $turn; + private Turn $turn; public function __construct(Turn $turn) { @@ -25,7 +24,7 @@ public function occurredAt(): \DateTimeImmutable } /** - * @inheritDoc + * @return array */ public function toArray(): array { diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Game.php b/src/TicTacToe/Engine/Domain/Model/Game/Game.php index 7953c58..a05783f 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/Game.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Game.php @@ -14,22 +14,23 @@ final class Game extends AggregateRoot { - /** @var GameId */ - private $id; + private GameId $id; - /** @var PlayerIdSet */ - private $playerIds; + private PlayerIdSet $playerIds; - /** @var Board */ - private $board; + private Board $board; - /** @var \DateTimeImmutable */ - private $createdAt; + private \DateTimeImmutable $createdAt; public const MAX_PLAYERS = 2; + /** + * @throws SorryTooManyPlayers + */ private function __construct(GameId $gameId, Board $board, PlayerId ...$playerIds) { + parent::__construct(); + if (count($playerIds) > self::MAX_PLAYERS) { throw new SorryTooManyPlayers("Only " . self::MAX_PLAYERS . " players allowed."); } @@ -40,7 +41,7 @@ private function __construct(GameId $gameId, Board $board, PlayerId ...$playerId $this->createdAt = new \DateTimeImmutable(); } - public static function start(GameId $gameId, Board $board, PlayerId ...$playerIds) + public static function start(GameId $gameId, Board $board, PlayerId ...$playerIds): self { $game = new self($gameId, $board, ...$playerIds); @@ -51,9 +52,9 @@ public static function start(GameId $gameId, Board $board, PlayerId ...$playerId return $game; } - public function playerMakeTurn(Turn $turn) + public function playerMakeTurn(Turn $turn): void { - $this->board = $this->board->setCell($turn->position(), $turn->cell()); + $this->board->setCell($turn->position(), $turn->cell()); $this->record( new PlayerTurnPlayed($turn) diff --git a/src/TicTacToe/Engine/Domain/Model/Game/GameId.php b/src/TicTacToe/Engine/Domain/Model/Game/GameId.php index 9dc3aee..3470948 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/GameId.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/GameId.php @@ -8,15 +8,14 @@ final class GameId { - /** @var string */ - private $id; + private string $id; public function __construct(?string $id = null) { $this->id = null === $id ? Uuid::uuid4()->toString() : $id; } - public function equals(GameId $gameId) + public function equals(GameId $gameId): bool { return $this->id === (string) $gameId; } diff --git a/src/TicTacToe/Engine/Domain/Model/Game/GameRepository.php b/src/TicTacToe/Engine/Domain/Model/Game/GameRepository.php index d86411a..9b352d9 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/GameRepository.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/GameRepository.php @@ -24,7 +24,7 @@ public function ofId(GameId $gameId): ?Game; public function nextIdentity(): GameId; /** - * @return array + * @return array */ public function games(): array; } diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Turn.php b/src/TicTacToe/Engine/Domain/Model/Game/Turn.php index c0ceb7a..8f61149 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/Turn.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Turn.php @@ -9,30 +9,26 @@ final class Turn { + private GameId $gameId; - private $gameId; + private TurnId $moveId; - /** @var TurnId */ - private $moveId; + private Cell $cell; - /** @var Cell */ - private $cell; + private Player $madeBy; - /** @var Player */ - private $madeBy; + private Position $position; - /** @var Position */ - private $position; - - /** @var \DateTimeImmutable */ - private $createdAt; + private \DateTimeImmutable $createdAt; public function __construct( + GameId $gameId, TurnId $moveId, Cell $cell, Position $position, Player $madeBy ) { + $this->gameId = $gameId; $this->moveId = $moveId; $this->cell = $cell; $this->madeBy = $madeBy; @@ -40,6 +36,11 @@ public function __construct( $this->createdAt = new \DateTimeImmutable(); } + public function gameId(): GameId + { + return $this->gameId; + } + public function moveId(): TurnId { return $this->moveId; diff --git a/src/TicTacToe/Engine/Domain/Model/Game/TurnId.php b/src/TicTacToe/Engine/Domain/Model/Game/TurnId.php index fac4fc8..25fe803 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/TurnId.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/TurnId.php @@ -7,15 +7,14 @@ final class TurnId { - /** @var string */ - private $id; + private string $id; public function __construct(?string $id = null) { $this->id = null === $id ? Uuid::uuid4()->toString() : $id; } - public function equals(TurnId $moveId) + public function equals(TurnId $moveId): bool { return $this->id === (string)$moveId; } diff --git a/src/TicTacToe/Engine/Domain/Model/Game/TurnRepository.php b/src/TicTacToe/Engine/Domain/Model/Game/TurnRepository.php index a3dbaaa..94a3efc 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/TurnRepository.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/TurnRepository.php @@ -22,7 +22,7 @@ public function ofId(TurnId $id): ?Turn; public function nextIdentity(): TurnId; /** - * @return array + * @return array */ public function turns(): array; } diff --git a/src/TicTacToe/Engine/Domain/Model/Player/Event/PlayerCreated.php b/src/TicTacToe/Engine/Domain/Model/Player/Event/PlayerCreated.php index b2b806a..adc26d2 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/Event/PlayerCreated.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/Event/PlayerCreated.php @@ -9,8 +9,7 @@ final class PlayerCreated implements Event { - /** @var Player */ - private $player; + private Player $player; public function __construct(Player $player) { @@ -33,7 +32,7 @@ public function toArray(): array return [ 'playerId' => (string) $this->player->id(), 'playerName' => $this->player->name(), - 'playerToken' => $this->player->playingToken(), + 'playerToken' => (string) $this->player->playingToken(), 'createdAt' => $this->player->createdAt()->format(\DateTimeImmutable::ATOM) ]; } diff --git a/src/TicTacToe/Engine/Domain/Model/Player/Player.php b/src/TicTacToe/Engine/Domain/Model/Player/Player.php index 48b8853..ec38a36 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/Player.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/Player.php @@ -5,21 +5,20 @@ namespace TicTacToe\Engine\Domain\Model\Player; use TicTacToe\Engine\Domain\Model\Player\Event\PlayerCreated; +use TicTacToe\Engine\Domain\Model\Player\Exception\SorryInvalidPlayerToken; +use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNameIsTooLong; +use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNameIsTooShort; use TicTacToe\Shared\Domain\Model\AggregateRoot; final class Player extends AggregateRoot { - /** @var PlayerId */ - private $id; + private PlayerId $id; - /** @var PlayerName */ - private $name; + private PlayerName $name; - /** @var PlayerToken */ - private $playingToken; + private PlayerToken $playingToken; - /** @var \DateTimeImmutable */ - private $createdAt; + private \DateTimeImmutable $createdAt; private function __construct(PlayerId $id, PlayerName $name, PlayerToken $token) { @@ -59,6 +58,11 @@ public static function createPlayerWithTokenY(string $name): Player return $player; } + /** + * @throws SorryPlayerNameIsTooLong + * @throws SorryPlayerNameIsTooShort + * @throws SorryInvalidPlayerToken + */ public static function createPlayerWithToken(string $name, string $token): Player { $player = new self( diff --git a/src/TicTacToe/Engine/Domain/Model/Player/PlayerId.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerId.php index 1fb3e12..a88813f 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/PlayerId.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerId.php @@ -8,15 +8,14 @@ final class PlayerId { - /** @var string */ - private $id; + private string $id; public function __construct(?string $id = null) { $this->id = null === $id ? Uuid::uuid4()->toString() : $id; } - public function equals(PlayerId $playerId) + public function equals(PlayerId $playerId): bool { return $this->id === (string) $playerId; } diff --git a/src/TicTacToe/Engine/Domain/Model/Player/PlayerIdSet.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerIdSet.php index 129cef5..1f2eae5 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/PlayerIdSet.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerIdSet.php @@ -4,12 +4,15 @@ namespace TicTacToe\Engine\Domain\Model\Player; -use Traversable; +use Iterator; +/** + * @implements \IteratorAggregate + */ class PlayerIdSet implements \Countable, \IteratorAggregate { /** @var PlayerId[] */ - private $playerIds; + private array $playerIds; public function __construct(PlayerId ...$playerIds) { @@ -21,19 +24,22 @@ public function __construct(PlayerId ...$playerIds) } /** - * @return array|PlayerId[] + * @return array */ public function toArray(): array { return $this->playerIds; } - public function getIterator(): \Traversable + /** + * @return Iterator + */ + public function getIterator(): Iterator { return new \ArrayIterator($this->toArray()); } - public function count() + public function count(): int { return count($this->playerIds); } diff --git a/src/TicTacToe/Engine/Domain/Model/Player/PlayerName.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerName.php index 98ab505..ee6c8e6 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/PlayerName.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerName.php @@ -9,12 +9,15 @@ final class PlayerName { - /** @var string */ - private $name; + private string $name; private const MAX_LENGTH = 15; private const MIN_LENGTH = 3; + /** + * @throws SorryPlayerNameIsTooLong + * @throws SorryPlayerNameIsTooShort + */ public function __construct(string $name) { if (strlen($name) < self::MIN_LENGTH) { diff --git a/src/TicTacToe/Engine/Domain/Model/Player/PlayerRepository.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerRepository.php index 654c64f..8e44f83 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/PlayerRepository.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerRepository.php @@ -10,7 +10,7 @@ interface PlayerRepository * @param Player $player * @return void */ - public function add(Player $player); + public function add(Player $player): void; /** * @param PlayerId $playerId diff --git a/src/TicTacToe/Engine/Domain/Model/Player/PlayerToken.php b/src/TicTacToe/Engine/Domain/Model/Player/PlayerToken.php index c7cd151..e0439d4 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/PlayerToken.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/PlayerToken.php @@ -8,8 +8,7 @@ final class PlayerToken { - /** @var string */ - private $token; + private string $token; private const X_TOKEN = 'x'; private const Y_TOKEN = 'y'; @@ -18,6 +17,9 @@ final class PlayerToken self::Y_TOKEN, ]; + /** + * @throws SorryInvalidPlayerToken + */ public function __construct(string $token) { if (!in_array(strtolower($token), self::ALLOWED_TOKENS)) { diff --git a/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryEventStore.php b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryEventStore.php index e667bf5..1cf6777 100644 --- a/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryEventStore.php +++ b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryEventStore.php @@ -9,10 +9,24 @@ final class InMemoryEventStore implements EventStore { - private $events = []; + /** @var Event[] */ + private array $events; - public function store(Event $event) + public function __construct(Event ...$events) + { + $this->events = $events; + } + + public function store(Event $event): void { $this->events[] = unserialize(serialize($event)); } + + /** + * @return Event[] + */ + public function events(): array + { + return $this->events; + } } diff --git a/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryGameRepository.php b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryGameRepository.php index e37b2a4..3436ac4 100644 --- a/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryGameRepository.php +++ b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryGameRepository.php @@ -11,7 +11,7 @@ class InMemoryGameRepository implements GameRepository { /** @var Game[] */ - private $games = []; + private array $games = []; /** * @param Game $game * @return void @@ -43,7 +43,7 @@ public function nextIdentity(): GameId } /** - * @return array + * @return array */ public function games(): array { diff --git a/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php index 8a6f7a7..1018245 100644 --- a/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php +++ b/src/TicTacToe/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepository.php @@ -10,10 +10,10 @@ class InMemoryPlayerRepository implements PlayerRepository { - /** @var Player[] */ - private $players = []; + /** @var array */ + private array $players = []; - public function add(Player $player) + public function add(Player $player): void { $this->players[(string)$player->id()] = $player; } @@ -33,7 +33,7 @@ public function nextIdentity(): PlayerId } /** - * @return Player[] + * @return array */ public function players(): array { diff --git a/src/TicTacToe/Engine/Presentation/Console/ConsoleInput.php b/src/TicTacToe/Engine/Presentation/Console/ConsoleInput.php index 584b122..17b77af 100644 --- a/src/TicTacToe/Engine/Presentation/Console/ConsoleInput.php +++ b/src/TicTacToe/Engine/Presentation/Console/ConsoleInput.php @@ -8,59 +8,33 @@ final class ConsoleInput implements Input { - /** - * @inheritDoc - */ - public function readString($allowEmpty = false): string + public function readString(bool $allowEmpty = false): string { $input = $this->readStringFromStream(); if (empty($input) && !$allowEmpty) { throw new \InvalidArgumentException("Input cannot be empty."); } - if (!is_string($input)) { - throw new \InvalidArgumentException("Input is not a valid 'string'."); - } return trim($input); } - /** - * @inheritDoc - */ public function readInteger(): int { $input = $this->readIntegerFromStream(); if (!empty($input)) { - if (!is_integer($input)) { - throw new \InvalidArgumentException("Input is not a valid 'integer'."); - } + throw new \InvalidArgumentException("Input cannot be empty."); } - $input = intval($input); return $input; } - /** - * @codeCoverageIgnore - * - * Read string from stream - * - * @return string - */ - protected function readStringFromStream() + protected function readStringFromStream(): string { - $string = trim(fgets(STDIN)); - return $string; + $stream = fgets(STDIN); + return trim($stream !== false ? $stream : ''); } - /** - * @codeCoverageIgnore - * - * Return integer from stream - * - * @return integer - */ - protected function readIntegerFromStream() + protected function readIntegerFromStream(): int { fscanf(STDIN, "%d\n", $number); return $number; diff --git a/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php b/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php index df00dbd..311f365 100644 --- a/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php +++ b/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php @@ -13,22 +13,22 @@ final class ConsoleOutput implements Output private const INFO = "\033[0mINFO: %s\n"; private const WARNING = "\033[33mWarning: %s\n"; - public function error(string $error) + public function error(string $error): void { echo sprintf(self::ERROR, $error); } - public function success(string $message) + public function success(string $message): void { echo sprintf(self::SUCCESS, $message); } - public function warning(string $message) + public function warning(string $message): void { echo sprintf(self::WARNING, $message); } - public function info(string $message) + public function info(string $message): void { echo sprintf(self::INFO, $message); } diff --git a/src/TicTacToe/Engine/Presentation/Input.php b/src/TicTacToe/Engine/Presentation/Input.php index 6b798dd..a28a7fa 100644 --- a/src/TicTacToe/Engine/Presentation/Input.php +++ b/src/TicTacToe/Engine/Presentation/Input.php @@ -6,14 +6,7 @@ interface Input { - /** - * @param bool $allowEmpty - * @return string - */ - public function readString($allowEmpty = false): string; + public function readString(bool $allowEmpty = false): string; - /** - * @return int - */ public function readInteger(): int; } diff --git a/src/TicTacToe/Engine/Presentation/Output.php b/src/TicTacToe/Engine/Presentation/Output.php index 15a4d97..cee7cc6 100644 --- a/src/TicTacToe/Engine/Presentation/Output.php +++ b/src/TicTacToe/Engine/Presentation/Output.php @@ -6,11 +6,11 @@ interface Output { - public function error(string $error); + public function error(string $error): void; - public function success(string $message); + public function success(string $message): void; - public function warning(string $message); + public function warning(string $message): void; - public function info(string $message); + public function info(string $message): void; } diff --git a/src/TicTacToe/Shared/Application/DataTransformer.php b/src/TicTacToe/Shared/Application/DataTransformer.php index 1278ce8..119d64d 100644 --- a/src/TicTacToe/Shared/Application/DataTransformer.php +++ b/src/TicTacToe/Shared/Application/DataTransformer.php @@ -7,7 +7,7 @@ interface DataTransformer { /** - * @return array + * @return array */ public function toArray(): array; } diff --git a/src/TicTacToe/Shared/Application/EmptyResponseDto.php b/src/TicTacToe/Shared/Application/EmptyResponseDto.php new file mode 100644 index 0000000..8983c51 --- /dev/null +++ b/src/TicTacToe/Shared/Application/EmptyResponseDto.php @@ -0,0 +1,13 @@ +events = []; + } /** - * @return array|Event[] + * @return Event[] */ public function getRecordedEvents(): array { return $this->events; } - public function resetRecordedEvents() + public function resetRecordedEvents(): void { $this->events = []; } - protected function record(Event $event) + protected function record(Event $event): void { $this->events[] = $event; } diff --git a/src/TicTacToe/Shared/Domain/Model/Event.php b/src/TicTacToe/Shared/Domain/Model/Event.php index a80f9da..ad45c6a 100644 --- a/src/TicTacToe/Shared/Domain/Model/Event.php +++ b/src/TicTacToe/Shared/Domain/Model/Event.php @@ -16,7 +16,7 @@ public function occurredAt(): \DateTimeImmutable; /** * Return event data as array * - * @return array + * @return array */ public function toArray(): array; diff --git a/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php index 014fbcf..b7c720e 100644 --- a/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php +++ b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php @@ -12,7 +12,8 @@ final class CommandBusFactory implements CommandBus { - private $commandHandlers; + /** @var array */ + private array $commandHandlers; public function __construct() { diff --git a/src/TicTacToe/Shared/Infrastructure/EventStore.php b/src/TicTacToe/Shared/Infrastructure/EventStore.php index 857d330..d388785 100644 --- a/src/TicTacToe/Shared/Infrastructure/EventStore.php +++ b/src/TicTacToe/Shared/Infrastructure/EventStore.php @@ -8,5 +8,5 @@ interface EventStore { - public function store(Event $event); + public function store(Event $event): void; } diff --git a/tests/unit/Engine/Application/CreateNewPlayer/CreateNewPlayerHandlerTest.php b/tests/unit/Engine/Application/CreateNewPlayer/CreateNewPlayerHandlerTest.php index ef9a990..dbb6843 100644 --- a/tests/unit/Engine/Application/CreateNewPlayer/CreateNewPlayerHandlerTest.php +++ b/tests/unit/Engine/Application/CreateNewPlayer/CreateNewPlayerHandlerTest.php @@ -15,13 +15,11 @@ class CreateNewPlayerHandlerTest extends TestCase { - /** @var CreateNewPlayerHandler */ - private $handler; + private CreateNewPlayerHandler $handler; - /** @var InMemoryPlayerRepository */ - private $playerRepository; + private InMemoryPlayerRepository $playerRepository; - protected function setUp() + protected function setUp(): void { $this->playerRepository = new InMemoryPlayerRepository(); $this->handler = new CreateNewPlayerHandler( @@ -29,23 +27,23 @@ protected function setUp() ); } - public function testItHandlesCorrectClass() + public function testItHandlesCorrectClass(): void { self::assertEquals(CreateNewPlayerCommand::class, $this->handler->handles()); } - public function testItCanCreateANewPlayer() + public function testItCanCreateANewPlayer(): void { $command = $this->createCommand(); /** @var CreateNewPlayerResponseDto $playerDto */ $playerDto = $this->handler->handle($command); - $retreivedPlayer = $this->playerRepository->ofId(new PlayerId($playerDto->playerId())); - self::assertEquals($retreivedPlayer->name(), $playerDto->playerName()); - self::assertEquals((string) $retreivedPlayer->playingToken(), $playerDto->playerToken()); + $retrievedPlayer = $this->playerRepository->ofId(new PlayerId($playerDto->playerId())); + self::assertEquals($retrievedPlayer->name(), $playerDto->playerName()); + self::assertEquals((string) $retrievedPlayer->playingToken(), $playerDto->playerToken()); } - public function testItThrowsSorryWrongCommandWhenWrongCommandPassed() + public function testItThrowsSorryWrongCommandWhenWrongCommandPassed(): void { $command = new WrongCommand(); @@ -53,7 +51,7 @@ public function testItThrowsSorryWrongCommandWhenWrongCommandPassed() $this->handler->handle($command); } - private function createCommand(string $name = 'player', string $token = 'x') + private function createCommand(string $name = 'player', string $token = 'x'): CreateNewPlayerCommand { return new CreateNewPlayerCommand($name, $token); } diff --git a/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php b/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php index 8a67dd7..29ac4ff 100644 --- a/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php +++ b/tests/unit/Engine/Infrastructure/Persistence/InMemory/InMemoryPlayerRepositoryTest.php @@ -13,10 +13,9 @@ class InMemoryPlayerRepositoryTest extends TestCase { - /** @var PlayerRepository */ - private $repository; + private PlayerRepository $repository; - protected function setUp() + protected function setUp(): void { $this->repository = new InMemoryPlayerRepository(); } From 3ee370bc604561c49e95ebfb03facca2fcdcf400 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 29 Sep 2022 14:59:38 +0200 Subject: [PATCH 67/75] set php version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b980276..740cfa9 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A php-cli Tic-Tac-Toe simple two players game. ### Requirements -1. `php >= 7.2` +1. `php >= 8` 2. `Docker` ### Installation From 9b2b5ab9cfa14ff02fe2350ff5eff78ae3ec46d7 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Thu, 29 Sep 2022 22:44:56 +0200 Subject: [PATCH 68/75] remove cell set --- .../Engine/Domain/Model/Board/CellSet.php | 42 ------------------- 1 file changed, 42 deletions(-) delete mode 100644 src/TicTacToe/Engine/Domain/Model/Board/CellSet.php diff --git a/src/TicTacToe/Engine/Domain/Model/Board/CellSet.php b/src/TicTacToe/Engine/Domain/Model/Board/CellSet.php deleted file mode 100644 index 5e20459..0000000 --- a/src/TicTacToe/Engine/Domain/Model/Board/CellSet.php +++ /dev/null @@ -1,42 +0,0 @@ - - */ -final class CellSet implements \Countable, \IteratorAggregate -{ - /** @var Cell[] */ - private array $cells; - - public function __construct(Cell ...$cells) - { - if (empty($cells)) { - throw new \InvalidArgumentException('Cell can not be empty.'); - } - - $this->cells = $cells; - } - - /** - * @return Cell[] - */ - public function toArray(): array - { - return $this->cells; - } - - public function getIterator(): Iterator - { - return new \ArrayIterator($this->toArray()); - } - - public function count(): int - { - return count($this->cells); - } -} From ed14a221f8a797d8316ea4f6a8501d3c67101a27 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 4 Oct 2022 14:27:12 +0200 Subject: [PATCH 69/75] refactor player play --- .../PlayNewTurn/PlayNewTurnHandler.php | 10 ++------ .../Engine/Domain/Model/Game/Game.php | 6 +---- .../Engine/Domain/Model/Player/Player.php | 23 +++++++++++++++++++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php b/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php index 19b59dc..562dd09 100644 --- a/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php +++ b/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php @@ -67,15 +67,9 @@ public function handle(Command $command): DataTransformer throw new SorryGameNotFound("Game of Id {$gameId} not found."); } - $turn = new Turn( - $game->id(), - new TurnId(), - Cell::createFromPlayerToken($player->playingToken()), - new Position($command->position()), - $player - ); + $turn = $player->play($game->id(), new Position($command->position())); - $game->playerMakeTurn( + $game->setBoardPiece( $turn ); diff --git a/src/TicTacToe/Engine/Domain/Model/Game/Game.php b/src/TicTacToe/Engine/Domain/Model/Game/Game.php index a05783f..9f6364b 100644 --- a/src/TicTacToe/Engine/Domain/Model/Game/Game.php +++ b/src/TicTacToe/Engine/Domain/Model/Game/Game.php @@ -52,13 +52,9 @@ public static function start(GameId $gameId, Board $board, PlayerId ...$playerId return $game; } - public function playerMakeTurn(Turn $turn): void + public function setBoardPiece(Turn $turn): void { $this->board->setCell($turn->position(), $turn->cell()); - - $this->record( - new PlayerTurnPlayed($turn) - ); } public function id(): GameId diff --git a/src/TicTacToe/Engine/Domain/Model/Player/Player.php b/src/TicTacToe/Engine/Domain/Model/Player/Player.php index ec38a36..01005dd 100644 --- a/src/TicTacToe/Engine/Domain/Model/Player/Player.php +++ b/src/TicTacToe/Engine/Domain/Model/Player/Player.php @@ -4,6 +4,12 @@ namespace TicTacToe\Engine\Domain\Model\Player; +use TicTacToe\Engine\Domain\Model\Board\Cell; +use TicTacToe\Engine\Domain\Model\Board\Position; +use TicTacToe\Engine\Domain\Model\Game\Event\PlayerTurnPlayed; +use TicTacToe\Engine\Domain\Model\Game\GameId; +use TicTacToe\Engine\Domain\Model\Game\Turn; +use TicTacToe\Engine\Domain\Model\Game\TurnId; use TicTacToe\Engine\Domain\Model\Player\Event\PlayerCreated; use TicTacToe\Engine\Domain\Model\Player\Exception\SorryInvalidPlayerToken; use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNameIsTooLong; @@ -97,4 +103,21 @@ public function createdAt(): \DateTimeImmutable { return $this->createdAt; } + + public function play(GameId $gameId, Position $position): Turn + { + $turn = new Turn( + $gameId, + new TurnId(), + Cell::createFromPlayerToken($this->playingToken), + $position, + $this + ); + + $this->record( + new PlayerTurnPlayed($turn) + ); + + return $turn; + } } From 601842d1870bd9d18ff17fde47c5c4b72f8e471d Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 4 Oct 2022 16:38:20 +0200 Subject: [PATCH 70/75] refactor to create application commandbus --- Makefile | 2 + main.php | 3 +- src/TicTacToe/Application.php | 342 ++---------------- .../PlayNewTurn/PlayNewTurnHandler.php | 3 - .../CommandBus/GameCommandHandlerFactory.php | 34 ++ .../Presentation/Console/ConsoleOutput.php | 25 +- .../Shared/Application/CommandHandler.php | 11 +- .../SharedCommandHandlerFactory.php | 38 ++ .../{ => CommandBus}/CommandBus.php | 9 +- .../CommandBus/CommandBusFactory.php | 32 +- .../Shared/Infrastructure/EventStore.php | 5 + 11 files changed, 143 insertions(+), 361 deletions(-) create mode 100644 src/TicTacToe/Engine/Infrastructure/CommandBus/GameCommandHandlerFactory.php create mode 100644 src/TicTacToe/Shared/Application/SharedCommandHandlerFactory.php rename src/TicTacToe/Shared/Infrastructure/{ => CommandBus}/CommandBus.php (55%) diff --git a/Makefile b/Makefile index 9aba4c2..aac01e5 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,8 @@ composer: @echo "\n==> Running composer install, runner $(RUNNER)" $(CMD) $(COMPOSER) install +lint: lint-composer lint-php + clear: $(CMD) rm -rf vendor $(CMD) rm -rf bin/php* diff --git a/main.php b/main.php index cee99de..a6cb138 100644 --- a/main.php +++ b/main.php @@ -3,7 +3,6 @@ require "./vendor/autoload.php"; use TicTacToe\Application; -use TicTacToe\IO\IOHandler; -$game = new Application(new IOHandler()); +$game = new Application(); $game->run(); diff --git a/src/TicTacToe/Application.php b/src/TicTacToe/Application.php index b0829d9..a7aeebc 100644 --- a/src/TicTacToe/Application.php +++ b/src/TicTacToe/Application.php @@ -2,64 +2,34 @@ namespace TicTacToe; +use TicTacToe\Engine\Infrastructure\CommandBus\GameCommandHandlerFactory; +use TicTacToe\Engine\Infrastructure\Persistence\InMemory\InMemoryEventStore; +use TicTacToe\Engine\Presentation\Console\ConsoleInput; +use TicTacToe\Engine\Presentation\Console\ConsoleOutput; +use TicTacToe\Engine\Presentation\Input; +use TicTacToe\Engine\Presentation\Output; +use TicTacToe\Shared\Infrastructure\CommandBus\CommandBusFactory; +use TicTacToe\Shared\Infrastructure\EventStore; + class Application { - /** - * Maximum players for this game - * - * @const integer - */ - const MAX_PLAYERS = 2; - - /** - * String padding lenght used to show - * test in cli - * - * @const integer - */ - const STRING_PADDING_LENGTH = 64; - - /** - * Board instance - * - * @var Board - */ - protected $board = null; - - /** - * IOHandler for handling - * input from STDIN - * and output to STDOUT - * - * @var IOHandler - */ - protected $ioHandler = null; + private CommandBusFactory $commandBusFactory; - /** - * Array of players - * - * @var array - */ - protected $players; + private EventStore $eventStore; - /** - * Boolean if players choose to start game - * - * @var bool - */ - protected $isStarted = false; + private Output $output; - protected $playerTurn = 0; - protected $moves = 0; + private Input $input; /** * Constructor */ - public function __construct(IOHandler $ioHandler) + public function __construct() { - $this->board = new Board(); - $this->players = array(); - $this->ioHandler = $ioHandler; + $this->eventStore = new InMemoryEventStore(); + $this->commandBusFactory = new CommandBusFactory(new GameCommandHandlerFactory(), $this->eventStore); + $this->input = new ConsoleInput(); + $this->output = new ConsoleOutput(); } /** @@ -67,14 +37,14 @@ public function __construct(IOHandler $ioHandler) * * @return void */ - protected function processInput() + protected function processInput(): void { - $keyPressed = $this->ioHandler->readString(true); + $keyPressed = $this->input->readString(); switch ($keyPressed) { case 'd': case 'D': - $this->ioHandler->writeLine($this->board->getBoard()); + $this->output->info("D pressed"); break; case '1': case '2': @@ -85,42 +55,18 @@ protected function processInput() case '7': case '8': case '9': - return $keyPressed; + $this->output->warning('number pressed pressed'); break; case 's': case 'S': - // check in players - if (!$this->isStarted) { - $this->checkInPlayers(); - } + $this->output->success('S pressed'); break; default: - $this->ioHandler->writeLine("Unidentified input.", IOHandler::WARNING); + $this->output->error("Unidentified input."); break; } } - /** - * Is game started - * - * @return bool - */ - public function isGameStarted() - { - return $this->isStarted; - } - - public function getMovesCount() - { - return $this->moves; - } - - - public function getCellValue($location) - { - return $this->board->getCellValue($location); - } - /** * Run the game * @@ -130,244 +76,8 @@ public function getCellValue($location) */ public function run() { - $this->showWelcome(); - - while (($winner = $this->board->checkForWinner()) == null) { - if (!$this->isStarted) { - $this->processInput(); - } else { - try { - $this->nextStep(); - - if ($this->isGameDraw()) { - $this->gameIsDraw(); - break; - } - } catch (\Exception $e) { - $this->ioHandler->writeLine($e->getMessage(), IOHandler::ERROR); - continue; - } - } - } - - if (!empty($winner)) { - $this->gameHasWinner($winner); - } - } - - /** - * Check if game is draw between players - * - * @return void - */ - protected function isGameDraw() - { - return ((true == $this->board->areAllCellsFilled()) && (null == $this->board->checkForWinner())); - } - - /** - * Show winner - * - * @param string $marker Winner marker - * - * @return void - */ - protected function gameHasWinner($marker) - { - $winner = $this->getPlayerByMarker($marker); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#"), IOHandler::SUCCESS); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " "), IOHandler::SUCCESS); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("Hoorrraaayyy !"), IOHandler::SUCCESS); - $this->ioHandler->writeLine( - $this->getBorderedStringWithPadding($winner->getName() . " won!"), - IOHandler::SUCCESS - ); - - foreach ($this->board->getBoard() as $boardRow) { - $this->ioHandler->writeLine($this->getBorderedStringWithPadding($boardRow), IOHandler::SUCCESS); - } - $this->ioHandler->writeLine( - $this->getBorderedStringWithPadding("Thank you for playing Tic-Tac-Toe"), - IOHandler::SUCCESS - ); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " "), IOHandler::SUCCESS); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#"), IOHandler::SUCCESS); - } - - /** - * Game is ended with draw - * - * @return void - */ - protected function gameIsDraw() - { - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("It is a DRAW!")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("Thank you for playing Tic-Tac-Toe.")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#")); - } - - /** - * Play - * - * @return void - */ - private function nextStep() - { - $this->playerTurn = $this->moves % count($this->players); - $player = $this->players[$this->playerTurn]; - - $this->ioHandler->write("{$player->getName()}'s turn, please enter the location: "); - $location = $this->processInput(); - - if ($location) { - $this->board->setBoardCell($location, $player->getMarker()); - $this->moves++; - } - } - - /** - * Show the welcome message - * - * @return void - */ - protected function showWelcome() - { - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("Tic-Tac-Toe Game")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("Welcome to Tic-Tac-Toe")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("This is a two players tic-tac-toe game.")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - foreach ($this->board->demoBoard() as $boardRow) { - $this->ioHandler->writeLine($this->getBorderedStringWithPadding($boardRow)); - } - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine("| To start playing you need to press 's/S', then enter players |"); - $this->ioHandler->writeLine("| details (name and marker). If at anytime you want to draw the |"); - $this->ioHandler->writeLine("| board press 'd/D'. |"); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine("| Enjoy! |"); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("_", "_")); - $this->ioHandler->writeLine(); - $this->ioHandler->write("Press 's/S' to start the game... ", IOHandler::LIGHT_CYAN); - } - - /** - * Prompt to make players enter their name and - * choose their markers. - * - * @return void - */ - public function checkInPlayers() - { - $this->isStarted = true; - $playersCheckedIn = 0; - $player = array( - 'name' => null, - 'marker' => null - ); - while ($playersCheckedIn < self::MAX_PLAYERS) { - try { - if (!isset($player['name'])) { - $this->ioHandler->write("What is the name of Player " . ($playersCheckedIn + 1) . ": "); - $player['name'] = $this->ioHandler->readString(); - } - - if (!isset($player['marker'])) { - $this->ioHandler->write("Please choose your Tic-Tac-Toe marker i.e. 'x', 'o': "); - $marker = $this->ioHandler->readString(true); - if (!$this->isMarkerTaken($marker)) { - $this->players[] = new HumanPlayer($marker, $player['name']); - $player['marker'] = $marker; - } - } - } catch (\Exception $e) { - $this->ioHandler->writeLine($e->getMessage(), IOHandler::ERROR); - continue; - } - - $playersCheckedIn++; - unset($player); - } - } - - /** - * Get players - * - * @return array - */ - public function getPlayers() - { - return $this->players; - } - - /** - * Get Player by marker - * - * @return TicTacToe\Player\HumanPlayer - */ - protected function getPlayerByMarker($marker) - { - foreach ($this->players as $player) { - if ($marker === $player->getMarker()) { - return $player; - } - } - - return null; - } - - /** - * Check if marker is already chosen - * by another player. - * - * @param string $marker marker to check - * - * @throws \RuntimeException in case of marker already taken - * @return true if not taken, false otherwise - */ - private function isMarkerTaken($marker) - { - foreach ($this->players as $player) { - if ($marker === $player->getMarker()) { - throw new \RuntimeException("Sorry! '{$marker}' is already taken."); - } + while (true) { + $this->processInput(); } - - return false; - } - - /** - * Get a RIGHT and LEFT padded string with - * left and right border. - * - * @param string $string String to output - * @param string $padding Optional. Specifies the string to use for padding. Default is whitespace - * - * @return string - */ - private function getBorderedStringWithPadding($string, $padding = " ") - { - return "|" . $this->getPaddedStringForOutput($string, $padding) . "|"; - } - - /** - * Get a RIGHT and LEFT padded string used - * in showing Welcome, Game draw and Game win - * - * @param string $string String to output - * @param string $padding Optional. Specifies the string to use for padding. Default is whitespace - * - * @return string - */ - private function getPaddedStringForOutput($string, $padding = " ") - { - return str_pad($string, self::STRING_PADDING_LENGTH, $padding, STR_PAD_BOTH); } } diff --git a/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php b/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php index 562dd09..9f17559 100644 --- a/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php +++ b/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php @@ -3,13 +3,10 @@ namespace TicTacToe\Engine\Application\PlayNewTurn; -use TicTacToe\Engine\Domain\Model\Board\Cell; use TicTacToe\Engine\Domain\Model\Board\Position; use TicTacToe\Engine\Domain\Model\Game\Exception\SorryGameNotFound; use TicTacToe\Engine\Domain\Model\Game\GameId; use TicTacToe\Engine\Domain\Model\Game\GameRepository; -use TicTacToe\Engine\Domain\Model\Game\Turn; -use TicTacToe\Engine\Domain\Model\Game\TurnId; use TicTacToe\Engine\Domain\Model\Game\TurnRepository; use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNotFound; use TicTacToe\Engine\Domain\Model\Player\PlayerId; diff --git a/src/TicTacToe/Engine/Infrastructure/CommandBus/GameCommandHandlerFactory.php b/src/TicTacToe/Engine/Infrastructure/CommandBus/GameCommandHandlerFactory.php new file mode 100644 index 0000000..132d0ec --- /dev/null +++ b/src/TicTacToe/Engine/Infrastructure/CommandBus/GameCommandHandlerFactory.php @@ -0,0 +1,34 @@ + function () use ($gameRepository) { + return new CreateNewGameHandler($gameRepository); + }, + CreateNewPlayerCommand::class => function () use ($playerRepository) { + return new CreateNewPlayerHandler($playerRepository); + } + ]; + } +} diff --git a/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php b/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php index 311f365..4479c96 100644 --- a/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php +++ b/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php @@ -8,10 +8,12 @@ final class ConsoleOutput implements Output { - private const ERROR = "\033[31mERROR: %s\n"; - private const SUCCESS = "\033[32m%s\n"; - private const INFO = "\033[0mINFO: %s\n"; - private const WARNING = "\033[33mWarning: %s\n"; + private const ERROR = "\033[31mERROR: %s"; + private const SUCCESS = "\033[32m%s"; + private const INFO = "\033[0mINFO: %s"; + private const WARNING = "\033[33mWarning: %s"; + + private const STRING_PADDING_LENGTH = 64; public function error(string $error): void { @@ -32,4 +34,19 @@ public function info(string $message): void { echo sprintf(self::INFO, $message); } + + public function writeLine(string $message): void + { + $this->getBorderedStringWithPadding($message); + } + + private function getBorderedStringWithPadding(string $string, string $padding = " "): string + { + return "|" . $this->getPaddedStringForOutput($string, $padding) . "|"; + } + + private function getPaddedStringForOutput(string $string, string $padding = " "): string + { + return str_pad($string, self::STRING_PADDING_LENGTH, $padding, STR_PAD_BOTH); + } } diff --git a/src/TicTacToe/Shared/Application/CommandHandler.php b/src/TicTacToe/Shared/Application/CommandHandler.php index 62e92be..0727109 100644 --- a/src/TicTacToe/Shared/Application/CommandHandler.php +++ b/src/TicTacToe/Shared/Application/CommandHandler.php @@ -1,21 +1,12 @@ supports($command)) { + throw new SorryCommandHandlerNotFound($commandName); + } + + $callBack = $handlers[$commandName]; + return $callBack(); + } + + public function supports(Command $command): bool + { + $handlers = $this::commandHandlers(); + $commandName = get_class($command); + + return array_key_exists($commandName, $handlers); + } + + /** + * @return \Closure[] + */ + abstract protected static function commandHandlers(): array; +} diff --git a/src/TicTacToe/Shared/Infrastructure/CommandBus.php b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBus.php similarity index 55% rename from src/TicTacToe/Shared/Infrastructure/CommandBus.php rename to src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBus.php index ed3f70f..4ee066c 100644 --- a/src/TicTacToe/Shared/Infrastructure/CommandBus.php +++ b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBus.php @@ -2,11 +2,11 @@ declare(strict_types = 1); -namespace TicTacToe\Shared\Infrastructure; +namespace TicTacToe\Shared\Infrastructure\CommandBus; use TicTacToe\Shared\Application\Command; -use TicTacToe\Shared\Application\CommandHandler; use TicTacToe\Shared\Application\DataTransformer; +use TicTacToe\Shared\Domain\Model\Event; interface CommandBus { @@ -17,8 +17,7 @@ interface CommandBus public function handle(Command $command): DataTransformer; /** - * @param Command $command - * @param CommandHandler $commandHandler + * @return Event[] */ - public function register(Command $command, CommandHandler $commandHandler): void; + public function events(): array; } diff --git a/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php index b7c720e..dd980fb 100644 --- a/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php +++ b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php @@ -5,44 +5,34 @@ namespace TicTacToe\Shared\Infrastructure\CommandBus; use TicTacToe\Shared\Application\Command; -use TicTacToe\Shared\Application\CommandHandler; +use TicTacToe\Shared\Application\CommandHandlerFactory; use TicTacToe\Shared\Application\DataTransformer; -use TicTacToe\Shared\Infrastructure\CommandBus; -use TicTacToe\Shared\Infrastructure\CommandBus\Exception\SorryCommandHandlerNotFound; +use TicTacToe\Shared\Infrastructure\EventStore; final class CommandBusFactory implements CommandBus { - /** @var array */ - private array $commandHandlers; + private CommandHandlerFactory $commandHandlerFactory; - public function __construct() + private EventStore $eventStore; + + public function __construct(CommandHandlerFactory $commandHandlerFactory, EventStore $eventStore) { - $this->commandHandlers = []; + $this->commandHandlerFactory = $commandHandlerFactory; + $this->eventStore = $eventStore; } /** * @param Command $command * @return DataTransformer - * @throws SorryCommandHandlerNotFound */ public function handle(Command $command): DataTransformer { - $class = get_class($command); - if (!isset($this->commandHandlers[$class])) { - throw new SorryCommandHandlerNotFound($class); - } - - $handler = $this->commandHandlers[$class]; + $handler = $this->commandHandlerFactory->create($command); return $handler->handle($command); } - /** - * @param Command $command - * @param CommandHandler $commandHandler - */ - public function register(Command $command, CommandHandler $commandHandler): void + public function events(): array { - $class = get_class($command); - $this->commandHandlers[$class] = $commandHandler; + return $this->eventStore->events(); } } diff --git a/src/TicTacToe/Shared/Infrastructure/EventStore.php b/src/TicTacToe/Shared/Infrastructure/EventStore.php index d388785..8c78105 100644 --- a/src/TicTacToe/Shared/Infrastructure/EventStore.php +++ b/src/TicTacToe/Shared/Infrastructure/EventStore.php @@ -9,4 +9,9 @@ interface EventStore { public function store(Event $event): void; + + /** + * @return Event[] + */ + public function events(): array; } From f56ae5791b6f9906ccea7508fb4cfc91bd8ad543 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 4 Oct 2022 16:38:20 +0200 Subject: [PATCH 71/75] refactor to create application commandbus --- Makefile | 2 + main.php | 3 +- src/TicTacToe/Application.php | 342 ++---------------- .../PlayNewTurn/PlayNewTurnHandler.php | 3 - .../CommandBus/GameCommandHandlerFactory.php | 34 ++ .../Presentation/Console/ConsoleOutput.php | 25 +- .../Shared/Application/CommandHandler.php | 11 +- .../Application/CommandHandlerFactory.php | 20 + .../SharedCommandHandlerFactory.php | 38 ++ .../{ => CommandBus}/CommandBus.php | 9 +- .../CommandBus/CommandBusFactory.php | 32 +- .../Shared/Infrastructure/EventStore.php | 5 + 12 files changed, 163 insertions(+), 361 deletions(-) create mode 100644 src/TicTacToe/Engine/Infrastructure/CommandBus/GameCommandHandlerFactory.php create mode 100644 src/TicTacToe/Shared/Application/CommandHandlerFactory.php create mode 100644 src/TicTacToe/Shared/Application/SharedCommandHandlerFactory.php rename src/TicTacToe/Shared/Infrastructure/{ => CommandBus}/CommandBus.php (55%) diff --git a/Makefile b/Makefile index 9aba4c2..aac01e5 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,8 @@ composer: @echo "\n==> Running composer install, runner $(RUNNER)" $(CMD) $(COMPOSER) install +lint: lint-composer lint-php + clear: $(CMD) rm -rf vendor $(CMD) rm -rf bin/php* diff --git a/main.php b/main.php index cee99de..a6cb138 100644 --- a/main.php +++ b/main.php @@ -3,7 +3,6 @@ require "./vendor/autoload.php"; use TicTacToe\Application; -use TicTacToe\IO\IOHandler; -$game = new Application(new IOHandler()); +$game = new Application(); $game->run(); diff --git a/src/TicTacToe/Application.php b/src/TicTacToe/Application.php index b0829d9..a7aeebc 100644 --- a/src/TicTacToe/Application.php +++ b/src/TicTacToe/Application.php @@ -2,64 +2,34 @@ namespace TicTacToe; +use TicTacToe\Engine\Infrastructure\CommandBus\GameCommandHandlerFactory; +use TicTacToe\Engine\Infrastructure\Persistence\InMemory\InMemoryEventStore; +use TicTacToe\Engine\Presentation\Console\ConsoleInput; +use TicTacToe\Engine\Presentation\Console\ConsoleOutput; +use TicTacToe\Engine\Presentation\Input; +use TicTacToe\Engine\Presentation\Output; +use TicTacToe\Shared\Infrastructure\CommandBus\CommandBusFactory; +use TicTacToe\Shared\Infrastructure\EventStore; + class Application { - /** - * Maximum players for this game - * - * @const integer - */ - const MAX_PLAYERS = 2; - - /** - * String padding lenght used to show - * test in cli - * - * @const integer - */ - const STRING_PADDING_LENGTH = 64; - - /** - * Board instance - * - * @var Board - */ - protected $board = null; - - /** - * IOHandler for handling - * input from STDIN - * and output to STDOUT - * - * @var IOHandler - */ - protected $ioHandler = null; + private CommandBusFactory $commandBusFactory; - /** - * Array of players - * - * @var array - */ - protected $players; + private EventStore $eventStore; - /** - * Boolean if players choose to start game - * - * @var bool - */ - protected $isStarted = false; + private Output $output; - protected $playerTurn = 0; - protected $moves = 0; + private Input $input; /** * Constructor */ - public function __construct(IOHandler $ioHandler) + public function __construct() { - $this->board = new Board(); - $this->players = array(); - $this->ioHandler = $ioHandler; + $this->eventStore = new InMemoryEventStore(); + $this->commandBusFactory = new CommandBusFactory(new GameCommandHandlerFactory(), $this->eventStore); + $this->input = new ConsoleInput(); + $this->output = new ConsoleOutput(); } /** @@ -67,14 +37,14 @@ public function __construct(IOHandler $ioHandler) * * @return void */ - protected function processInput() + protected function processInput(): void { - $keyPressed = $this->ioHandler->readString(true); + $keyPressed = $this->input->readString(); switch ($keyPressed) { case 'd': case 'D': - $this->ioHandler->writeLine($this->board->getBoard()); + $this->output->info("D pressed"); break; case '1': case '2': @@ -85,42 +55,18 @@ protected function processInput() case '7': case '8': case '9': - return $keyPressed; + $this->output->warning('number pressed pressed'); break; case 's': case 'S': - // check in players - if (!$this->isStarted) { - $this->checkInPlayers(); - } + $this->output->success('S pressed'); break; default: - $this->ioHandler->writeLine("Unidentified input.", IOHandler::WARNING); + $this->output->error("Unidentified input."); break; } } - /** - * Is game started - * - * @return bool - */ - public function isGameStarted() - { - return $this->isStarted; - } - - public function getMovesCount() - { - return $this->moves; - } - - - public function getCellValue($location) - { - return $this->board->getCellValue($location); - } - /** * Run the game * @@ -130,244 +76,8 @@ public function getCellValue($location) */ public function run() { - $this->showWelcome(); - - while (($winner = $this->board->checkForWinner()) == null) { - if (!$this->isStarted) { - $this->processInput(); - } else { - try { - $this->nextStep(); - - if ($this->isGameDraw()) { - $this->gameIsDraw(); - break; - } - } catch (\Exception $e) { - $this->ioHandler->writeLine($e->getMessage(), IOHandler::ERROR); - continue; - } - } - } - - if (!empty($winner)) { - $this->gameHasWinner($winner); - } - } - - /** - * Check if game is draw between players - * - * @return void - */ - protected function isGameDraw() - { - return ((true == $this->board->areAllCellsFilled()) && (null == $this->board->checkForWinner())); - } - - /** - * Show winner - * - * @param string $marker Winner marker - * - * @return void - */ - protected function gameHasWinner($marker) - { - $winner = $this->getPlayerByMarker($marker); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#"), IOHandler::SUCCESS); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " "), IOHandler::SUCCESS); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("Hoorrraaayyy !"), IOHandler::SUCCESS); - $this->ioHandler->writeLine( - $this->getBorderedStringWithPadding($winner->getName() . " won!"), - IOHandler::SUCCESS - ); - - foreach ($this->board->getBoard() as $boardRow) { - $this->ioHandler->writeLine($this->getBorderedStringWithPadding($boardRow), IOHandler::SUCCESS); - } - $this->ioHandler->writeLine( - $this->getBorderedStringWithPadding("Thank you for playing Tic-Tac-Toe"), - IOHandler::SUCCESS - ); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " "), IOHandler::SUCCESS); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#"), IOHandler::SUCCESS); - } - - /** - * Game is ended with draw - * - * @return void - */ - protected function gameIsDraw() - { - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("It is a DRAW!")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("Thank you for playing Tic-Tac-Toe.")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#")); - } - - /** - * Play - * - * @return void - */ - private function nextStep() - { - $this->playerTurn = $this->moves % count($this->players); - $player = $this->players[$this->playerTurn]; - - $this->ioHandler->write("{$player->getName()}'s turn, please enter the location: "); - $location = $this->processInput(); - - if ($location) { - $this->board->setBoardCell($location, $player->getMarker()); - $this->moves++; - } - } - - /** - * Show the welcome message - * - * @return void - */ - protected function showWelcome() - { - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("Tic-Tac-Toe Game")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("#", "#")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("Welcome to Tic-Tac-Toe")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("This is a two players tic-tac-toe game.")); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - foreach ($this->board->demoBoard() as $boardRow) { - $this->ioHandler->writeLine($this->getBorderedStringWithPadding($boardRow)); - } - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine("| To start playing you need to press 's/S', then enter players |"); - $this->ioHandler->writeLine("| details (name and marker). If at anytime you want to draw the |"); - $this->ioHandler->writeLine("| board press 'd/D'. |"); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding(" ", " ")); - $this->ioHandler->writeLine("| Enjoy! |"); - $this->ioHandler->writeLine($this->getBorderedStringWithPadding("_", "_")); - $this->ioHandler->writeLine(); - $this->ioHandler->write("Press 's/S' to start the game... ", IOHandler::LIGHT_CYAN); - } - - /** - * Prompt to make players enter their name and - * choose their markers. - * - * @return void - */ - public function checkInPlayers() - { - $this->isStarted = true; - $playersCheckedIn = 0; - $player = array( - 'name' => null, - 'marker' => null - ); - while ($playersCheckedIn < self::MAX_PLAYERS) { - try { - if (!isset($player['name'])) { - $this->ioHandler->write("What is the name of Player " . ($playersCheckedIn + 1) . ": "); - $player['name'] = $this->ioHandler->readString(); - } - - if (!isset($player['marker'])) { - $this->ioHandler->write("Please choose your Tic-Tac-Toe marker i.e. 'x', 'o': "); - $marker = $this->ioHandler->readString(true); - if (!$this->isMarkerTaken($marker)) { - $this->players[] = new HumanPlayer($marker, $player['name']); - $player['marker'] = $marker; - } - } - } catch (\Exception $e) { - $this->ioHandler->writeLine($e->getMessage(), IOHandler::ERROR); - continue; - } - - $playersCheckedIn++; - unset($player); - } - } - - /** - * Get players - * - * @return array - */ - public function getPlayers() - { - return $this->players; - } - - /** - * Get Player by marker - * - * @return TicTacToe\Player\HumanPlayer - */ - protected function getPlayerByMarker($marker) - { - foreach ($this->players as $player) { - if ($marker === $player->getMarker()) { - return $player; - } - } - - return null; - } - - /** - * Check if marker is already chosen - * by another player. - * - * @param string $marker marker to check - * - * @throws \RuntimeException in case of marker already taken - * @return true if not taken, false otherwise - */ - private function isMarkerTaken($marker) - { - foreach ($this->players as $player) { - if ($marker === $player->getMarker()) { - throw new \RuntimeException("Sorry! '{$marker}' is already taken."); - } + while (true) { + $this->processInput(); } - - return false; - } - - /** - * Get a RIGHT and LEFT padded string with - * left and right border. - * - * @param string $string String to output - * @param string $padding Optional. Specifies the string to use for padding. Default is whitespace - * - * @return string - */ - private function getBorderedStringWithPadding($string, $padding = " ") - { - return "|" . $this->getPaddedStringForOutput($string, $padding) . "|"; - } - - /** - * Get a RIGHT and LEFT padded string used - * in showing Welcome, Game draw and Game win - * - * @param string $string String to output - * @param string $padding Optional. Specifies the string to use for padding. Default is whitespace - * - * @return string - */ - private function getPaddedStringForOutput($string, $padding = " ") - { - return str_pad($string, self::STRING_PADDING_LENGTH, $padding, STR_PAD_BOTH); } } diff --git a/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php b/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php index 562dd09..9f17559 100644 --- a/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php +++ b/src/TicTacToe/Engine/Application/PlayNewTurn/PlayNewTurnHandler.php @@ -3,13 +3,10 @@ namespace TicTacToe\Engine\Application\PlayNewTurn; -use TicTacToe\Engine\Domain\Model\Board\Cell; use TicTacToe\Engine\Domain\Model\Board\Position; use TicTacToe\Engine\Domain\Model\Game\Exception\SorryGameNotFound; use TicTacToe\Engine\Domain\Model\Game\GameId; use TicTacToe\Engine\Domain\Model\Game\GameRepository; -use TicTacToe\Engine\Domain\Model\Game\Turn; -use TicTacToe\Engine\Domain\Model\Game\TurnId; use TicTacToe\Engine\Domain\Model\Game\TurnRepository; use TicTacToe\Engine\Domain\Model\Player\Exception\SorryPlayerNotFound; use TicTacToe\Engine\Domain\Model\Player\PlayerId; diff --git a/src/TicTacToe/Engine/Infrastructure/CommandBus/GameCommandHandlerFactory.php b/src/TicTacToe/Engine/Infrastructure/CommandBus/GameCommandHandlerFactory.php new file mode 100644 index 0000000..132d0ec --- /dev/null +++ b/src/TicTacToe/Engine/Infrastructure/CommandBus/GameCommandHandlerFactory.php @@ -0,0 +1,34 @@ + function () use ($gameRepository) { + return new CreateNewGameHandler($gameRepository); + }, + CreateNewPlayerCommand::class => function () use ($playerRepository) { + return new CreateNewPlayerHandler($playerRepository); + } + ]; + } +} diff --git a/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php b/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php index 311f365..4479c96 100644 --- a/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php +++ b/src/TicTacToe/Engine/Presentation/Console/ConsoleOutput.php @@ -8,10 +8,12 @@ final class ConsoleOutput implements Output { - private const ERROR = "\033[31mERROR: %s\n"; - private const SUCCESS = "\033[32m%s\n"; - private const INFO = "\033[0mINFO: %s\n"; - private const WARNING = "\033[33mWarning: %s\n"; + private const ERROR = "\033[31mERROR: %s"; + private const SUCCESS = "\033[32m%s"; + private const INFO = "\033[0mINFO: %s"; + private const WARNING = "\033[33mWarning: %s"; + + private const STRING_PADDING_LENGTH = 64; public function error(string $error): void { @@ -32,4 +34,19 @@ public function info(string $message): void { echo sprintf(self::INFO, $message); } + + public function writeLine(string $message): void + { + $this->getBorderedStringWithPadding($message); + } + + private function getBorderedStringWithPadding(string $string, string $padding = " "): string + { + return "|" . $this->getPaddedStringForOutput($string, $padding) . "|"; + } + + private function getPaddedStringForOutput(string $string, string $padding = " "): string + { + return str_pad($string, self::STRING_PADDING_LENGTH, $padding, STR_PAD_BOTH); + } } diff --git a/src/TicTacToe/Shared/Application/CommandHandler.php b/src/TicTacToe/Shared/Application/CommandHandler.php index 62e92be..0727109 100644 --- a/src/TicTacToe/Shared/Application/CommandHandler.php +++ b/src/TicTacToe/Shared/Application/CommandHandler.php @@ -1,21 +1,12 @@ supports($command)) { + throw new SorryCommandHandlerNotFound($commandName); + } + + $callBack = $handlers[$commandName]; + return $callBack(); + } + + public function supports(Command $command): bool + { + $handlers = $this::commandHandlers(); + $commandName = get_class($command); + + return array_key_exists($commandName, $handlers); + } + + /** + * @return \Closure[] + */ + abstract protected static function commandHandlers(): array; +} diff --git a/src/TicTacToe/Shared/Infrastructure/CommandBus.php b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBus.php similarity index 55% rename from src/TicTacToe/Shared/Infrastructure/CommandBus.php rename to src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBus.php index ed3f70f..4ee066c 100644 --- a/src/TicTacToe/Shared/Infrastructure/CommandBus.php +++ b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBus.php @@ -2,11 +2,11 @@ declare(strict_types = 1); -namespace TicTacToe\Shared\Infrastructure; +namespace TicTacToe\Shared\Infrastructure\CommandBus; use TicTacToe\Shared\Application\Command; -use TicTacToe\Shared\Application\CommandHandler; use TicTacToe\Shared\Application\DataTransformer; +use TicTacToe\Shared\Domain\Model\Event; interface CommandBus { @@ -17,8 +17,7 @@ interface CommandBus public function handle(Command $command): DataTransformer; /** - * @param Command $command - * @param CommandHandler $commandHandler + * @return Event[] */ - public function register(Command $command, CommandHandler $commandHandler): void; + public function events(): array; } diff --git a/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php index b7c720e..dd980fb 100644 --- a/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php +++ b/src/TicTacToe/Shared/Infrastructure/CommandBus/CommandBusFactory.php @@ -5,44 +5,34 @@ namespace TicTacToe\Shared\Infrastructure\CommandBus; use TicTacToe\Shared\Application\Command; -use TicTacToe\Shared\Application\CommandHandler; +use TicTacToe\Shared\Application\CommandHandlerFactory; use TicTacToe\Shared\Application\DataTransformer; -use TicTacToe\Shared\Infrastructure\CommandBus; -use TicTacToe\Shared\Infrastructure\CommandBus\Exception\SorryCommandHandlerNotFound; +use TicTacToe\Shared\Infrastructure\EventStore; final class CommandBusFactory implements CommandBus { - /** @var array */ - private array $commandHandlers; + private CommandHandlerFactory $commandHandlerFactory; - public function __construct() + private EventStore $eventStore; + + public function __construct(CommandHandlerFactory $commandHandlerFactory, EventStore $eventStore) { - $this->commandHandlers = []; + $this->commandHandlerFactory = $commandHandlerFactory; + $this->eventStore = $eventStore; } /** * @param Command $command * @return DataTransformer - * @throws SorryCommandHandlerNotFound */ public function handle(Command $command): DataTransformer { - $class = get_class($command); - if (!isset($this->commandHandlers[$class])) { - throw new SorryCommandHandlerNotFound($class); - } - - $handler = $this->commandHandlers[$class]; + $handler = $this->commandHandlerFactory->create($command); return $handler->handle($command); } - /** - * @param Command $command - * @param CommandHandler $commandHandler - */ - public function register(Command $command, CommandHandler $commandHandler): void + public function events(): array { - $class = get_class($command); - $this->commandHandlers[$class] = $commandHandler; + return $this->eventStore->events(); } } diff --git a/src/TicTacToe/Shared/Infrastructure/EventStore.php b/src/TicTacToe/Shared/Infrastructure/EventStore.php index d388785..8c78105 100644 --- a/src/TicTacToe/Shared/Infrastructure/EventStore.php +++ b/src/TicTacToe/Shared/Infrastructure/EventStore.php @@ -9,4 +9,9 @@ interface EventStore { public function store(Event $event): void; + + /** + * @return Event[] + */ + public function events(): array; } From 65f0e3214247c17c5dbf0b5bf5935ca22d0fff0b Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 4 Oct 2022 17:16:15 +0200 Subject: [PATCH 72/75] remove env --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 738b76b..a0c03d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ -env: - - RUNNER=travis language: php php: - '8' From a56c959a02a91bbfe791d2cbbf8dd6ec7289841a Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Tue, 4 Oct 2022 17:17:20 +0200 Subject: [PATCH 73/75] add it again --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a0c03d4..738b76b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +env: + - RUNNER=travis language: php php: - '8' From 8feceb6a334c119fb16b7d52b90bb64c5fb19b45 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 5 Oct 2022 15:29:00 +0200 Subject: [PATCH 74/75] remove travis --- .travis.yml | 6 ------ README.md | 2 -- 2 files changed, 8 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 738b76b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -env: - - RUNNER=travis -language: php -php: - - '8' -install: make clear lint-composer lint-php composer phpcs tests stan diff --git a/README.md b/README.md index 740cfa9..b9805b2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # tic-tac-toe -[![Build Status](https://travis-ci.org/mnsami/tic-tac-toe.svg?branch=master)](https://travis-ci.org/mnsami/tic-tac-toe) - ### Description A php-cli Tic-Tac-Toe simple two players game. From b6caa800cb715dda3b2dde23b609b25b7376ef62 Mon Sep 17 00:00:00 2001 From: Mina Nabil Sami Date: Wed, 5 Oct 2022 15:42:08 +0200 Subject: [PATCH 75/75] add github actions --- .github/workflows/main.yml | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..797b003 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,70 @@ +name: Testing + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Validate composer.json and composer.lock + run: make lint-composer + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + run: make composer + + - name: Pack and upload the build + uses: actions/upload-artifact@v2 + with: + name: website + path: . + + test: + if: ${{ success() }} + needs: build + runs-on: ubuntu-latest + steps: + - name: Download site build + uses: actions/download-artifact@v2 + with: + name: website + path: . + + - name: Cache Composer packages + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + - name: Lint PHP files + run: make lint-php + + - name: Check PHP styles + run: make phpcs + + - name: Static Analysis + run: make stan + + - name: Unit Tests + run: make tests +