diff --git a/.gitattributes b/.gitattributes index f88eeea1..16d8d293 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,10 @@ -/test export-ignore -/vendor export-ignore -.coveralls.yml export-ignore -.gitattributes export-ignore -.gitignore export-ignore -.travis.yml export-ignore -phpcs.xml.dist export-ignore -phpunit.xml.dist export-ignore +/.coveralls.yml export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/composer.lock export-ignore +/docs/ export-ignore +/mkdocs.yml export-ignore +/phpcs.xml export-ignore +/phpunit.xml.dist export-ignore +/test/ export-ignore diff --git a/.gitignore b/.gitignore index 10650b55..1bcb3fc0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,8 @@ -.buildpath -.DS_Store -.idea -.project -.settings/ -.*.sw* -.*.un~ -nbproject -doc/html/ -tmp/ -zf-mkdoc-theme/ -clover.xml -coveralls-upload.json -phpunit.xml -vendor +/.phpunit.result.cache +/clover.xml +/coveralls-upload.json +/docs/html/ +/phpunit.xml +/vendor/ +/zf-mkdoc-theme.tgz +/zf-mkdoc-theme/ diff --git a/.travis.yml b/.travis.yml index c318a9a0..48c07c52 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,17 @@ -sudo: false - language: php -branches: - except: - - /^release-\d+\.\d+\.\d+.*$/ - - /^ghgfk-.*$/ - cache: directories: - $HOME/.composer/cache - - $HOME/.local - - zf-mkdoc-theme env: global: - COMPOSER_ARGS="--no-interaction" - - COVERAGE_DEPS="satooshi/php-coveralls" + - COVERAGE_DEPS="php-coveralls/php-coveralls" - TESTS_ZEND_CODE_ANNOTATION_DOCTRINE_SUPPORT=true - - SITE_URL="https://zendframework.github.io/zend-code" - - GH_USER_NAME="Matthew Weier O'Phinney" - - GH_USER_EMAIL="matthew@weierophinney.net" - - GH_REF="github.com/zendframework/zend-code.git" - - secure: "qgUppUW+xiQunsc07EvrYK7q9j4ewsYzN2ggxxFGaF694gkZ5V29Tb9W2qCkKEdMo6vE+X65P/lOoJceyavPm39/Ka/0V461qIiYX2ZcBVFI/eeVnpwLmU/E5YHn6fFNbiwFX0o4cJdVyTrSspMTXSuiQy+9bLSevDYmbpknR476nmsF8FRGdG6GMFx0XklF1QkoERSfy+FGlqp3VYOJZ2MH7eLhXQyGBKv471kyfmyyInUMVoDN9R8mjJ4Sxyt2qaQ5661DuWRXLaWEBaNOvfZ4++jJFipPLyqIEcE2GqTl9LH3suIBd0NAfHGgdakMJuBZfW3WA/OQ208qm+++qajnI30cxKiGkFoAR2plK9P5+09JAzbivglpEIEtq9a58/I1ahjy9+4sqJYyfxUC07o+REUleJl/ojO6QQ3JI/UUBbPSa3d78Sw9i8LUmLimiYEYQK9zwO1ZdKwJYCKaiYdYS8H0IwGci9t+MqlrllMG5M6f2HRkF1Ph05sWah8QwsGrJ7yiSiILaDHn7wFNvUiN3uw09W9AotQ0AEBzdM6U6CngDPVWKHI9L1d7+txuOLwGt6j8NKHWlgA1P9rMkeMGn2+46b5AlCkUxg6cVCA8ZLpr3a5WLK2F7qTHACtP9tckEb4G3vQjM79f6Nlpewcuc7p7uHWK5Y4UkojRN+U=" matrix: + fast_finish: true include: - php: 7.1 env: @@ -32,47 +19,57 @@ matrix: - php: 7.1 env: - DEPS=locked - - DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)" - - PATH="$HOME/.local/bin:$PATH" + - LEGACY_DEPS="doctrine/annotations phpunit/phpunit" + - CS_CHECK=true - TEST_COVERAGE=true - - CHECK_CS=true - php: 7.1 env: - DEPS=latest - - php: nightly + - php: 7.2 env: - DEPS=lowest - - php: nightly + - php: 7.2 env: - DEPS=locked - - php: nightly + - php: 7.2 + env: + - DEPS=latest + - php: 7.3 + env: + - DEPS=lowest + - php: 7.3 + env: + - DEPS=locked + - php: 7.3 + env: + - DEPS=latest + - php: 7.4 + env: + - DEPS=lowest + - php: 7.4 + env: + - DEPS=locked + - php: 7.4 env: - DEPS=latest - allow_failures: - - php: nightly - -notifications: - email: false before_install: - - travis_retry composer self-update - - if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || true ; fi + - if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi install: + - travis_retry composer install $COMPOSER_ARGS --ignore-platform-reqs + - if [[ $LEGACY_DEPS != '' ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi - if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi - if [[ $DEPS == 'lowest' ]]; then travis_retry composer update $COMPOSER_ARGS --prefer-lowest --prefer-stable ; fi - if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi - - travis_retry composer install $COMPOSER_ARGS - - stty cols 120 - - COLUMNS=120 composer show + - stty cols 120 && composer show script: - if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi - - if [[ $CHECK_CS == 'true' ]]; then composer cs-check ; fi - - if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then travis_retry curl -sSL https://raw.githubusercontent.com/zendframework/zf-mkdoc-theme/master/theme-installer.sh | bash ; fi + - if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi after_script: - - if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer upload-coverage ; fi + - if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry php vendor/bin/php-coveralls -v ; fi -after_success: - - if [[ $DEPLOY_DOCS == "true" ]]; then ./zf-mkdoc-theme/deploy.sh ; fi +notifications: + email: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 8647b0c2..7c806a76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,104 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. +## 3.4.2 - TBD + +### Added + +- Nothing. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- Nothing. + +## 3.4.1 - 2019-12-10 + +### Added + +- [#180](https://github.com/zendframework/zend-code/pull/180) adds support for PHP 7.4. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- [#179](https://github.com/zendframework/zend-code/pull/179) fixes exception message when invalid value provided in `Zend\Code\Generator\ValueGenerator`. + +- [#180](https://github.com/zendframework/zend-code/pull/180) fixes PHP 7.4 compatibility. + +## 3.4.0 - 2019-10-06 + +### Added + +- [#170](https://github.com/zendframework/zend-code/pull/170) adds class constant visibility modifiers support. + +- [#169](https://github.com/zendframework/zend-code/pull/169) adds the ability to define declare statements. + +- [#167](https://github.com/zendframework/zend-code/pull/167) adds the ability to remove doc block of a member. + +### Changed + +- [#166](https://github.com/zendframework/zend-code/pull/166) changes omitting default property value if it is null. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- [#172](https://github.com/zendframework/zend-code/pull/172) fixes PHP 7.4 compatibility. + +## 3.3.2 - 2019-08-31 + +### Added + +- [#162](https://github.com/zendframework/zend-code/pull/162) adds support for PHP 7.3. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- [#171](https://github.com/zendframework/zend-code/pull/171) changes + curly braces in array and string offset access to square brackets + in order to prevent issues under the upcoming PHP 7.4 release. + +- [#164](https://github.com/zendframework/zend-code/pull/164) fixes indentation in multi-level arrays generated by `ValueGenerator`. + ## 3.3.1 - 2018-08-13 ### Added @@ -283,7 +381,7 @@ All notable changes to this project will be documented in this file, in reverse the non-existent package `Exception` class when an invalid visibility is provided. This section refers to breaking changes: please refer to -[doc/book/migration.md](doc/book/migration.md) for migration instructions. +[docs/book/migration.md](docs/book/migration.md) for migration instructions. - Types `string`, `int`, `float`, `bool` passed to `Zend\Code\Generator\ParameterGenerator#setType()` are no longer ignored in generated code [#30](https://github.com/zendframework/zend-code/pull/30) diff --git a/LICENSE.md b/LICENSE.md index 25501b09..4bc22a4a 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,16 +1,15 @@ -Copyright (c) 2005-2016, Zend Technologies USA, Inc. - +Copyright (c) 2005-2019, Zend Technologies USA, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -- Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. +- Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. +- Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. - Neither the name of Zend Technologies USA, Inc. nor the names of its contributors may be used to endorse or promote products derived from this diff --git a/Makefile b/Makefile deleted file mode 100644 index 4726b079..00000000 --- a/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# zend-expressive Makefile -# -# Primary purpose is for generating the mkdocs.yml from the bookdown.json -# sources. -# -# Configurable variables: -# - BOOKDOWN2MKDOCS - specify the path to the executable; defaults to -# ./vendor/bin/bookdown2mkdocs -# -# Available targets: -# - mkdocs - regenerate mkdocs.yml -# - all - synonym for mkdocs target - -BOOKDOWN2MKDOCS?=$(CURDIR)/vendor/bin/bookdown2mkdocs.php - -.PHONY : all mkdocs bookdown2mkdocs - -all : mkdocs - -mkdocs : - @echo "Generating mkdocs.yml from bookdown.json..." - -$(BOOKDOWN2MKDOCS) convert --site-name=zend-code --repo-url=https://github.com/zendframework/zend-code --copyright-url=http://www.zend.com/ --copyright-author="Zend Technologies USA Inc." - @echo "[DONE] Generating mkdocs.yml from bookdown.json" diff --git a/README.md b/README.md index 795e3b62..f5a37def 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ # zend-code +> ## Repository abandoned 2019-12-31 +> +> This repository has moved to [laminas/laminas-code](https://github.com/laminas/laminas-code). + [![Build Status](https://secure.travis-ci.org/zendframework/zend-code.svg?branch=master)](https://secure.travis-ci.org/zendframework/zend-code) -[![Coverage Status](https://coveralls.io/repos/zendframework/zend-code/badge.svg?branch=master)](https://coveralls.io/r/zendframework/zend-code?branch=master) +[![Coverage Status](https://coveralls.io/repos/github/zendframework/zend-code/badge.svg?branch=master)](https://coveralls.io/github/zendframework/zend-code?branch=master) `Zend\Code\Generator` provides facilities to generate arbitrary code using an object-oriented interface, both to create new code as well as to update existing diff --git a/composer.json b/composer.json index d6d3b389..0d165218 100644 --- a/composer.json +++ b/composer.json @@ -1,16 +1,19 @@ { "name": "zendframework/zend-code", - "description": "provides facilities to generate arbitrary code using an object oriented interface", + "description": "Extensions to the PHP Reflection API, static code scanning, and code generation", "license": "BSD-3-Clause", "keywords": [ - "zf2", + "zf", + "zendframework", "code" ], - "homepage": "https://github.com/zendframework/zend-code", - "autoload": { - "psr-4": { - "Zend\\Code\\": "src/" - } + "support": { + "docs": "https://docs.zendframework.com/zend-code/", + "issues": "https://github.com/zendframework/zend-code/issues", + "source": "https://github.com/zendframework/zend-code", + "rss": "https://github.com/zendframework/zend-code/releases.atom", + "chat": "https://zendframework-slack.herokuapp.com", + "forum": "https://discourse.zendframework.com/c/questions/components" }, "require": { "php": "^7.1", @@ -18,21 +21,21 @@ }, "require-dev": { "ext-phar": "*", - "doctrine/annotations": "~1.0", - "zendframework/zend-stdlib": "^2.7 || ^3.0", - "phpunit/phpunit": "^6.2.3", - "zendframework/zend-coding-standard": "^1.0.0" + "doctrine/annotations": "^1.7", + "phpunit/phpunit": "^7.5.16 || ^8.4", + "zendframework/zend-coding-standard": "^1.0", + "zendframework/zend-stdlib": "^2.7 || ^3.0" + }, + "conflict": { + "phpspec/prophecy": "<1.9.0" }, "suggest": { "doctrine/annotations": "Doctrine\\Common\\Annotations >=1.0 for annotation features", "zendframework/zend-stdlib": "Zend\\Stdlib component" }, - "minimum-stability": "dev", - "prefer-stable": true, - "extra": { - "branch-alias": { - "dev-master": "3.3.x-dev", - "dev-develop": "3.4.x-dev" + "autoload": { + "psr-4": { + "Zend\\Code\\": "src/" } }, "autoload-dev": { @@ -40,12 +43,21 @@ "ZendTest\\Code\\": "test/" } }, + "config": { + "sort-packages": true + }, + "extra": { + "branch-alias": { + "dev-master": "3.4.x-dev", + "dev-develop": "3.5.x-dev", + "dev-dev-4.0": "4.0.x-dev" + } + }, "scripts": { "check": [ "@cs-check", "@test" ], - "upload-coverage": "coveralls -v", "cs-check": "phpcs", "cs-fix": "phpcbf", "test": "phpunit --colors=always", diff --git a/composer.lock b/composer.lock index 99bf3589..27eb34d3 100644 --- a/composer.lock +++ b/composer.lock @@ -1,23 +1,23 @@ { "_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": "9ee05e51bd6b0f8d1d75da29bef50387", + "content-hash": "19b802ccaf8f069c8d62e3e589500bad", "packages": [ { "name": "zendframework/zend-eventmanager", - "version": "3.2.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-eventmanager.git", - "reference": "9d72db10ceb6e42fb92350c0cb54460da61bd79c" + "reference": "a5e2583a211f73604691586b8406ff7296a946dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/9d72db10ceb6e42fb92350c0cb54460da61bd79c", - "reference": "9d72db10ceb6e42fb92350c0cb54460da61bd79c", + "url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/a5e2583a211f73604691586b8406ff7296a946dd", + "reference": "a5e2583a211f73604691586b8406ff7296a946dd", "shasum": "" }, "require": { @@ -26,7 +26,7 @@ "require-dev": { "athletic/athletic": "^0.1", "container-interop/container-interop": "^1.1.0", - "phpunit/phpunit": "^6.0.7 || ^5.7.14", + "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.2", "zendframework/zend-coding-standard": "~1.0.0", "zendframework/zend-stdlib": "^2.7.3 || ^3.0" }, @@ -58,22 +58,22 @@ "events", "zf2" ], - "time": "2017-07-11T19:17:22+00:00" + "time": "2018-04-25T15:33:34+00:00" } ], "packages-dev": [ { "name": "doctrine/annotations", - "version": "v1.5.0", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "5beebb01b025c94e93686b7a0ed3edae81fe3e7f" + "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/5beebb01b025c94e93686b7a0ed3edae81fe3e7f", - "reference": "5beebb01b025c94e93686b7a0ed3edae81fe3e7f", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/904dca4eb10715b92569fbcd79e201d5c349b6bc", + "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc", "shasum": "" }, "require": { @@ -82,12 +82,12 @@ }, "require-dev": { "doctrine/cache": "1.*", - "phpunit/phpunit": "^5.7" + "phpunit/phpunit": "^7.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.5.x-dev" + "dev-master": "1.7.x-dev" } }, "autoload": { @@ -100,6 +100,10 @@ "MIT" ], "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, { "name": "Roman Borschel", "email": "roman@code-factory.org" @@ -108,10 +112,6 @@ "name": "Benjamin Eberlei", "email": "kontakt@beberlei.de" }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, { "name": "Jonathan Wage", "email": "jonwage@gmail.com" @@ -128,31 +128,33 @@ "docblock", "parser" ], - "time": "2017-07-22T10:58:02+00:00" + "time": "2019-10-01T18:55:10+00:00" }, { "name": "doctrine/instantiator", - "version": "1.1.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", "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": { @@ -177,39 +179,44 @@ } ], "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-10-21T16:45:58+00:00" }, { "name": "doctrine/lexer", - "version": "v1.0.1", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" + "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", + "reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6", "shasum": "" }, "require": { - "php": ">=5.3.2" + "php": "^7.2" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpstan/phpstan": "^0.11.8", + "phpunit/phpunit": "^8.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\Lexer\\": "lib/" + "psr-4": { + "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" } }, "notification-url": "https://packagist.org/downloads/", @@ -217,60 +224,69 @@ "MIT" ], "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, { "name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com" }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, { "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com" } ], - "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", - "homepage": "http://www.doctrine-project.org", + "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "https://www.doctrine-project.org/projects/lexer.html", "keywords": [ + "annotations", + "docblock", "lexer", - "parser" + "parser", + "php" ], - "time": "2014-09-09T13:34:57+00:00" + "time": "2019-10-30T14:39:59+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.6.1", + "version": "1.9.3", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102" + "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/8e6e04167378abf1ddb4d3522d8755c5fd90d102", - "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/007c053ae6f31bba39dfa19a7726f56e9763bbea", + "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea", "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", @@ -278,26 +294,26 @@ "object", "object graph" ], - "time": "2017-04-12T18:52:22+00:00" + "time": "2019-08-09T12:45:53+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", @@ -333,20 +349,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": { @@ -380,39 +396,37 @@ } ], "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": "2.0.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "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/", @@ -434,33 +448,39 @@ "reflection", "static analysis" ], - "time": "2015-12-27T11:43:31+00:00" + "time": "2018-08-07T13:53:10+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.2.0", + "version": "4.3.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "46f7e8bb075036c92695b15a1ddb6971c751e585" + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/46f7e8bb075036c92695b15a1ddb6971c751e585", - "reference": "46f7e8bb075036c92695b15a1ddb6971c751e585", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", "shasum": "" }, "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.4.0", + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", + "phpdocumentor/type-resolver": "~0.4 || ^1.0.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\\": [ @@ -479,41 +499,40 @@ } ], "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-07-15T11:38:20+00:00" + "time": "2019-09-12T14:27:41+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.4.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", - "phpdocumentor/reflection-common": "^1.0" + "php": "^7.1", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "ext-tokenizer": "^7.1", + "mockery/mockery": "~1", + "phpunit/phpunit": "^7.0" }, "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/", @@ -526,42 +545,43 @@ "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": "2019-08-22T18:11:29+00:00" }, { "name": "phpspec/prophecy", - "version": "v1.7.0", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", "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|^5.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": { - "psr-0": { - "Prophecy\\": "src/" + "psr-4": { + "Prophecy\\": "src/Prophecy" } }, "notification-url": "https://packagist.org/downloads/", @@ -589,45 +609,44 @@ "spy", "stub" ], - "time": "2017-03-02T20:05:34+00:00" + "time": "2019-10-03T11:07:50+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "5.2.1", + "version": "7.0.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "dc421f9ca5082a0c0cb04afb171c765f79add85b" + "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/dc421f9ca5082a0c0cb04afb171c765f79add85b", - "reference": "dc421f9ca5082a0c0cb04afb171c765f79add85b", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f1884187926fbb755a9aaf0b3836ad3165b478bf", + "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf", "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": "^3.0", - "sebastian/version": "^2.0", - "theseer/tokenizer": "^1.1" + "php": "^7.2", + "phpunit/php-file-iterator": "^2.0.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^3.1.1", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^4.2.2", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1.3" }, "require-dev": { - "ext-xdebug": "^2.5", - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^8.2.2" }, "suggest": { - "ext-xdebug": "^2.5.3" + "ext-xdebug": "^2.7.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.2.x-dev" + "dev-master": "7.0-dev" } }, "autoload": { @@ -642,7 +661,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -653,29 +672,32 @@ "testing", "xunit" ], - "time": "2017-04-21T08:03:57+00:00" + "time": "2019-11-20T13:55:58+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": { @@ -690,7 +712,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -700,7 +722,7 @@ "filesystem", "iterator" ], - "time": "2016-10-03T07:40:28+00:00" + "time": "2018-09-13T20:33:42+00:00" }, { "name": "phpunit/php-text-template", @@ -745,28 +767,28 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.9", + "version": "2.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" }, "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/1038454804406b0b5f5f520358e78c1c2f71501e", + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", "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.1-dev" } }, "autoload": { @@ -781,7 +803,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -790,33 +812,33 @@ "keywords": [ "timer" ], - "time": "2017-02-26T11:10:40+00:00" + "time": "2019-06-07T04:22:29+00:00" }, { "name": "phpunit/php-token-stream", - "version": "1.4.11", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" }, "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/995192df77f63a59e47f025390d2d1fdf8f425ff", + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", "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.1-dev" } }, "autoload": { @@ -839,57 +861,56 @@ "keywords": [ "tokenizer" ], - "time": "2017-02-27T10:12:30+00:00" + "time": "2019-09-17T06:23:10+00:00" }, { "name": "phpunit/phpunit", - "version": "6.2.3", + "version": "8.5.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "fa5711d0559fc4b64deba0702be52d41434cbcb7" + "reference": "3ee1c1fd6fc264480c25b6fb8285edefe1702dab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fa5711d0559fc4b64deba0702be52d41434cbcb7", - "reference": "fa5711d0559fc4b64deba0702be52d41434cbcb7", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3ee1c1fd6fc264480c25b6fb8285edefe1702dab", + "reference": "3ee1c1fd6fc264480c25b6fb8285edefe1702dab", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.2.0", "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", - "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^5.2", - "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.4.3 || ^2.0", - "sebastian/environment": "^3.0.2", - "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" - }, - "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2", - "phpunit/dbunit": "<3.0" + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.9.1", + "phar-io/manifest": "^1.0.3", + "phar-io/version": "^2.0.1", + "php": "^7.2", + "phpspec/prophecy": "^1.8.1", + "phpunit/php-code-coverage": "^7.0.7", + "phpunit/php-file-iterator": "^2.0.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^2.1.2", + "sebastian/comparator": "^3.0.2", + "sebastian/diff": "^3.0.2", + "sebastian/environment": "^4.2.2", + "sebastian/exporter": "^3.1.1", + "sebastian/global-state": "^3.0.0", + "sebastian/object-enumerator": "^3.0.3", + "sebastian/resource-operations": "^2.0.1", + "sebastian/type": "^1.1.3", + "sebastian/version": "^2.0.1" }, "require-dev": { "ext-pdo": "*" }, "suggest": { + "ext-soap": "*", "ext-xdebug": "*", - "phpunit/php-invoker": "^1.1" + "phpunit/php-invoker": "^2.0.0" }, "bin": [ "phpunit" @@ -897,7 +918,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.2.x-dev" + "dev-master": "8.5-dev" } }, "autoload": { @@ -923,66 +944,7 @@ "testing", "xunit" ], - "time": "2017-07-03T15:54:24+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "4.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "d8833b396dce9162bb2eb5d59aee5a3ab3cfa5b4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/d8833b396dce9162bb2eb5d59aee5a3ab3cfa5b4", - "reference": "d8833b396dce9162bb2eb5d59aee5a3ab3cfa5b4", - "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-06-30T08:15:21+00:00" + "time": "2019-12-06T05:41:38+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -1031,30 +993,30 @@ }, { "name": "sebastian/comparator", - "version": "2.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "875bd7cdcb5f49e9bcea732538767937abbed51d" + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/875bd7cdcb5f49e9bcea732538767937abbed51d", - "reference": "875bd7cdcb5f49e9bcea732538767937abbed51d", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", "shasum": "" }, "require": { - "php": "^7.0", - "sebastian/diff": "^2.0", - "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": { @@ -1085,38 +1047,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-07-11T16:29:53+00:00" + "time": "2018-07-12T15:12:46+00:00" }, { "name": "sebastian/diff", - "version": "2.0.x-dev", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "abcc70409ddfb310a8cb41ef0c2e857425438cf4" + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/abcc70409ddfb310a8cb41ef0c2e857425438cf4", - "reference": "abcc70409ddfb310a8cb41ef0c2e857425438cf4", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^6.2" + "phpunit/phpunit": "^7.5 || ^8.0", + "symfony/process": "^2 || ^3.3 || ^4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1141,34 +1104,40 @@ "description": "Diff implementation", "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ - "diff" + "diff", + "udiff", + "unidiff", + "unified diff" ], - "time": "2017-12-14T11:32:19+00:00" + "time": "2019-02-04T06:01:07+00:00" }, { "name": "sebastian/environment", - "version": "3.1.0", + "version": "4.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368", + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368", "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": { @@ -1193,20 +1162,20 @@ "environment", "hhvm" ], - "time": "2017-07-01T08:51:00+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": { @@ -1233,6 +1202,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -1241,17 +1214,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", @@ -1260,27 +1229,30 @@ "export", "exporter" ], - "time": "2017-04-03T13:19:02+00:00" + "time": "2019-09-14T09:02:43+00:00" }, { "name": "sebastian/global-state", - "version": "2.0.0", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.2", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "ext-dom": "*", + "phpunit/phpunit": "^8.0" }, "suggest": { "ext-uopz": "*" @@ -1288,7 +1260,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1311,25 +1283,25 @@ "keywords": [ "global state" ], - "time": "2017-04-27T15:39:26+00:00" + "time": "2019-02-01T05:30:01+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": { @@ -1358,7 +1330,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", @@ -1460,25 +1432,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": { @@ -1498,7 +1470,53 @@ ], "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/type", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/3aaaa15fa71d27650d62a948be022fe3b48541a3", + "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3", + "shasum": "" + }, + "require": { + "php": "^7.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.2" + }, + "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", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "time": "2019-07-02T08:10:15+00:00" }, { "name": "sebastian/version", @@ -1545,16 +1563,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "2.9.1", + "version": "2.9.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62" + "reference": "2acf168de78487db620ab4bc524135a13cfe6745" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dcbed1074f8244661eecddfc2a675430d8d33f62", - "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745", + "reference": "2acf168de78487db620ab4bc524135a13cfe6745", "shasum": "" }, "require": { @@ -1619,20 +1637,78 @@ "phpcs", "standards" ], - "time": "2017-05-22T02:43:20+00:00" + "time": "2018-11-07T22:31:41+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.13.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.13-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2019-11-27T13:56:44+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": { @@ -1659,35 +1735,33 @@ } ], "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.2.0", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + "reference": "573381c0a64f155a0d9a23f4b0c797194805b925" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "url": "https://api.github.com/repos/webmozart/assert/zipball/573381c0a64f155a0d9a23f4b0c797194805b925", + "reference": "573381c0a64f155a0d9a23f4b0c797194805b925", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "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/" @@ -1709,7 +1783,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2019-11-24T13:36:37+00:00" }, { "name": "zendframework/zend-coding-standard", @@ -1742,31 +1816,31 @@ }, { "name": "zendframework/zend-stdlib", - "version": "3.1.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-stdlib.git", - "reference": "debedcfc373a293f9250cc9aa03cf121428c8e78" + "reference": "66536006722aff9e62d1b331025089b7ec71c065" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/debedcfc373a293f9250cc9aa03cf121428c8e78", - "reference": "debedcfc373a293f9250cc9aa03cf121428c8e78", + "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/66536006722aff9e62d1b331025089b7ec71c065", + "reference": "66536006722aff9e62d1b331025089b7ec71c065", "shasum": "" }, "require": { "php": "^5.6 || ^7.0" }, "require-dev": { - "athletic/athletic": "~0.1", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "^2.6.2" + "phpbench/phpbench": "^0.13", + "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.2", + "zendframework/zend-coding-standard": "~1.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev", - "dev-develop": "3.2-dev" + "dev-master": "3.2.x-dev", + "dev-develop": "3.3.x-dev" } }, "autoload": { @@ -1778,18 +1852,19 @@ "license": [ "BSD-3-Clause" ], - "homepage": "https://github.com/zendframework/zend-stdlib", + "description": "SPL extensions, array utilities, error handlers, and more", "keywords": [ + "ZendFramework", "stdlib", - "zf2" + "zf" ], - "time": "2016-09-13T14:38:50+00:00" + "time": "2018-08-28T21:34:05+00:00" } ], "aliases": [], - "minimum-stability": "dev", + "minimum-stability": "stable", "stability-flags": [], - "prefer-stable": true, + "prefer-stable": false, "prefer-lowest": false, "platform": { "php": "^7.1" diff --git a/doc/book/index.html b/doc/book/index.html deleted file mode 100644 index d19038a8..00000000 --- a/doc/book/index.html +++ /dev/null @@ -1,10 +0,0 @@ -
-
-

zend-code

- -

Extensions to the PHP Reflection API, static code scanning, and code generation.

- -
$ composer require zendframework/zend-code
-
-
- diff --git a/CONDUCT.md b/docs/CODE_OF_CONDUCT.md similarity index 96% rename from CONDUCT.md rename to docs/CODE_OF_CONDUCT.md index c663d2be..02fafcd1 100644 --- a/CONDUCT.md +++ b/docs/CODE_OF_CONDUCT.md @@ -1,6 +1,6 @@ # Contributor Code of Conduct -The Zend Framework project adheres to [The Code Manifesto](http://codemanifesto.com) +This project adheres to [The Code Manifesto](http://codemanifesto.com) as its guidelines for contributor interactions. ## The Code Manifesto diff --git a/CONTRIBUTING.md b/docs/CONTRIBUTING.md similarity index 70% rename from CONTRIBUTING.md rename to docs/CONTRIBUTING.md index 97abf69c..da62d507 100644 --- a/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -2,37 +2,16 @@ ## RESOURCES -If you wish to contribute to Zend Framework, please be sure to +If you wish to contribute to this project, please be sure to read/subscribe to the following resources: - - [Coding Standards](https://github.com/zendframework/zf2/wiki/Coding-Standards) - - [Contributor's Guide](http://framework.zend.com/participate/contributor-guide) - - ZF Contributor's mailing list: - Archives: http://zend-framework-community.634137.n4.nabble.com/ZF-Contributor-f680267.html - Subscribe: zf-contributors-subscribe@lists.zend.com - - ZF Contributor's IRC channel: - #zftalk.dev on Freenode.net + - [Coding Standards](https://github.com/zendframework/zend-coding-standard) + - [Forums](https://discourse.zendframework.com/c/contributors) + - [Chat](https://zendframework-slack.herokuapp.com) + - [Code of Conduct](CODE_OF_CONDUCT.md) -If you are working on new features or refactoring [create a proposal](https://github.com/zendframework/zend-code/issues/new). - -## Reporting Potential Security Issues - -If you have encountered a potential security vulnerability, please **DO NOT** report it on the public -issue tracker: send it to us at [zf-security@zend.com](mailto:zf-security@zend.com) instead. -We will work with you to verify the vulnerability and patch it as soon as possible. - -When reporting issues, please provide the following information: - -- Component(s) affected -- A description indicating how to reproduce the issue -- A summary of the security vulnerability and impact - -We request that you contact us via the email address above and give the project -contributors a chance to resolve the vulnerability and issue a new release prior -to any public exposure; this helps protect users and provides them with a chance -to upgrade and/or update in order to protect their applications. - -For sensitive email communications, please use [our PGP key](http://framework.zend.com/zf-security-pgp-key.asc). +If you are working on new features or refactoring +[create a proposal](https://github.com/zendframework/zend-code/issues/new). ## RUNNING TESTS @@ -177,15 +156,7 @@ To send a pull request, you have two options. If using GitHub, you can do the pull request from there. Navigate to your repository, select the branch you just created, and then select the "Pull Request" button in the upper right. Select the user/organization -"zendframework" as the recipient. - -If using your own repository - or even if using GitHub - you can use `git -format-patch` to create a patchset for us to apply; in fact, this is -**recommended** for security-related patches. If you use `format-patch`, please -send the patches as attachments to: - -- zf-devteam@zend.com for patches without security implications -- zf-security@zend.com for security patches +"zendframework" (or whatever the upstream organization is) as the recipient. #### What branch to issue the pull request against? @@ -216,8 +187,3 @@ repository, we suggest doing some cleanup of these branches. ```console $ git push {username} : ``` - - -## Conduct - -Please see our [CONDUCT.md](CONDUCT.md) to understand expected behavior when interacting with others in the project. diff --git a/docs/ISSUE_TEMPLATE.md b/docs/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..6d87b4a6 --- /dev/null +++ b/docs/ISSUE_TEMPLATE.md @@ -0,0 +1,19 @@ + - [ ] I was not able to find an [open](https://github.com/zendframework/zend-code/issues?q=is%3Aopen) or [closed](https://github.com/zendframework/zend-code/issues?q=is%3Aclosed) issue matching what I'm seeing. + - [ ] This is not a question. (Questions should be asked on [chat](https://zendframework.slack.com/) ([Signup here](https://zendframework-slack.herokuapp.com/)) or our [forums](https://discourse.zendframework.com/).) + +Provide a narrative description of what you are trying to accomplish. + +### Code to reproduce the issue + + + +```php +``` + +### Expected results + + + +### Actual results + + diff --git a/docs/PULL_REQUEST_TEMPLATE.md b/docs/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..f00d90c0 --- /dev/null +++ b/docs/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,25 @@ +Provide a narrative description of what you are trying to accomplish: + +- [ ] Are you fixing a bug? + - [ ] Detail how the bug is invoked currently. + - [ ] Detail the original, incorrect behavior. + - [ ] Detail the new, expected behavior. + - [ ] Base your feature on the `master` branch, and submit against that branch. + - [ ] Add a regression test that demonstrates the bug, and proves the fix. + - [ ] Add a `CHANGELOG.md` entry for the fix. + +- [ ] Are you creating a new feature? + - [ ] Why is the new feature needed? What purpose does it serve? + - [ ] How will users use the new feature? + - [ ] Base your feature on the `develop` branch, and submit against that branch. + - [ ] Add only one feature per pull request; split multiple features over multiple pull requests + - [ ] Add tests for the new feature. + - [ ] Add documentation for the new feature. + - [ ] Add a `CHANGELOG.md` entry for the new feature. + +- [ ] Is this related to quality assurance? + + +- [ ] Is this related to documentation? + + diff --git a/docs/SUPPORT.md b/docs/SUPPORT.md new file mode 100644 index 00000000..807ec595 --- /dev/null +++ b/docs/SUPPORT.md @@ -0,0 +1,25 @@ +# Getting Support + +Zend Framework offers three support channels: + +- For real-time questions, use our + [chat](https://zendframework-slack.herokuapp.com) +- For detailed questions (e.g., those requiring examples) use our + [forums](https://discourse.zendframework.com/c/questions/components) +- To report issues, use this repository's + [issue tracker](https://github.com/zendframework/zend-code/issues/new) + +**DO NOT** use the issue tracker to ask questions; use chat or the forums for +that. Questions posed to the issue tracker will be closed. + +When reporting an issue, please include the following details: + +- A narrative description of what you are trying to accomplish. +- The minimum code necessary to reproduce the issue. +- The expected results of exercising that code. +- The actual results received. + +We may ask for additional details: what version of the library you are using, +and what PHP version was used to reproduce the issue. + +You may also submit a failing test case as a pull request. diff --git a/doc/book/generator/bookdown.json b/docs/book/generator/bookdown.json similarity index 100% rename from doc/book/generator/bookdown.json rename to docs/book/generator/bookdown.json diff --git a/doc/book/generator/examples.md b/docs/book/generator/examples.md similarity index 99% rename from doc/book/generator/examples.md rename to docs/book/generator/examples.md index 8b8451ef..8ca11131 100644 --- a/doc/book/generator/examples.md +++ b/docs/book/generator/examples.md @@ -328,7 +328,7 @@ You can add *PHP* code to an existing *PHP* file using the code generator. To do first do reflection on it. The static method `fromReflectedFileName()` allows you to do this. ```php -$generator = Zend\Code\Generator\FileGenerator::fromReflectedFileName($path); +$generator = Zend\Code\Generator\FileGenerator::fromReflectedFileName($path); $generator->setBody("\$foo->bar();"); file_put_contents($path, $generator->generate()); ``` diff --git a/doc/book/generator/intro.md b/docs/book/generator/intro.md similarity index 100% rename from doc/book/generator/intro.md rename to docs/book/generator/intro.md diff --git a/doc/book/generator/reference.md b/docs/book/generator/reference.md similarity index 99% rename from doc/book/generator/reference.md rename to docs/book/generator/reference.md index c5a81718..17509445 100644 --- a/doc/book/generator/reference.md +++ b/docs/book/generator/reference.md @@ -103,8 +103,8 @@ class Zend\Code\Generator\ClassGenerator extends Zend\Code\Generator\AbstractGen public function addConstants(Array $properties) public function addConstant($property) public function getConstants() - public function getConstant($propertyName) - public function removeConstant($constantName) + public function getConstant($propertyName) + public function removeConstant($constantName) public function setDocblock(Zend\Code\Generator\DocBlockGenerator $docblock) public function getDocblock() public function setName($name) diff --git a/doc/book/index.md b/docs/book/index.md similarity index 100% rename from doc/book/index.md rename to docs/book/index.md diff --git a/doc/book/migration.md b/docs/book/migration.md similarity index 97% rename from doc/book/migration.md rename to docs/book/migration.md index 7f4b12c7..d73ee037 100644 --- a/doc/book/migration.md +++ b/docs/book/migration.md @@ -2,7 +2,7 @@ ## `string`, `int`, `float`, `bool` are no longer ignored -In 2.x, a `Zend\Code\Generator\ParameterGenerator` with name `foo` and type +In 2.x, a `Zend\Code\Generator\ParameterGenerator` with name `foo` and type `string`, `int`, `float` or `bool` simply generated code `"$foo"`: ```php @@ -16,7 +16,7 @@ echo $generator->generate(); // "$foo" In 3.x, this code will instead produce `"string $foo"`. If you generate code that should run in PHP 5.x, it is advisable to strip `string`, `int`, `float` and `bool` from type definitions passed to -`Zend\Code\ParameterGenerator` instances. The quickest way is to set the +`Zend\Code\ParameterGenerator` instances. The quickest way is to set the type to `null`, if it matches any of these scalar types: ```php @@ -36,10 +36,10 @@ was renamed to `Zend\Code\Reflection\ParameterReflection#detectType()`. If you relied on `Zend\Code\Reflection\ParameterReflection#getType()`, you can simply replace the method calls in your code. - + ## DocBlock types ignored by `ParameterGenerator::fromReflection()` -As a direct consequence of the previous change, calls to +As a direct consequence of the previous change, calls to `Zend\Code\Generator\ParameterGenerator::fromReflection()` will not mirror the type hints read from a method's DocBlock. @@ -63,7 +63,7 @@ $methodGenerator = \Zend\Code\Generator\MethodGenerator::fromReflection( var_dump($methodGenerator->getParameters()[0]->getType()); ``` -In version 2.x, this code produces `"string"`, in version 3.x it returns `null`. If you +In version 2.x, this code produces `"string"`, in version 3.x it returns `null`. If you need to rely on the types in the annotations, please use `Zend\Code\Reflection\ParameterReflection#detectType()` instead, and build a `MethodGenerator` instance manually. diff --git a/mkdocs.yml b/mkdocs.yml index 143a7530..3e9ec7f6 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,13 +1,12 @@ -docs_dir: doc/book -site_dir: doc/html +docs_dir: docs/book +site_dir: docs/html pages: - - index.md + - Home: index.md - "Code Generation": - - Intro: generator/intro.md + - Introduction: generator/intro.md - Examples: generator/examples.md - Reference: generator/reference.md - Migration: migration.md site_name: zend-code -site_description: 'zend-code: Tools for reflecting, scanning, and generating PHP code' +site_description: 'Extensions to the PHP Reflection API, static code scanning, and code generation' repo_url: 'https://github.com/zendframework/zend-code' -copyright: 'Copyright (c) 2016 Zend Technologies USA Inc.' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f21d91f1..8c3363ab 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,21 @@ - + ./test + - - ./src + + ./src - - diff --git a/src/DeclareStatement.php b/src/DeclareStatement.php new file mode 100644 index 00000000..1d8e21c2 --- /dev/null +++ b/src/DeclareStatement.php @@ -0,0 +1,116 @@ + 'integer', + self::STRICT_TYPES => 'integer', + self::ENCODING => 'string', + ]; + + /** + * @var string + */ + protected $directive; + + /** + * @var int|string + */ + protected $value; + + private function __construct(string $directive, $value) + { + $this->directive = $directive; + $this->value = $value; + } + + /** + * @return string + */ + public function getDirective(): string + { + return $this->directive; + } + + /** + * @return int|string + */ + public function getValue() + { + return $this->value; + } + + /** + * @param int $value + * @return self + */ + public static function ticks(int $value): self + { + return new self(self::TICKS, $value); + } + + /** + * @param int $value + * @return self + */ + public static function strictTypes(int $value): self + { + return new self(self::STRICT_TYPES, $value); + } + + /** + * @param string $value + * @return self + */ + public static function encoding(string $value): self + { + return new self(self::ENCODING, $value); + } + + public static function fromArray(array $config): self + { + $directive = key($config); + $value = $config[$directive]; + + if (! isset(self::ALLOWED[$directive])) { + throw new InvalidArgumentException( + sprintf( + 'Declare directive must be one of: %s.', + implode(', ', array_keys(self::ALLOWED)) + ) + ); + } + + if (gettype($value) !== self::ALLOWED[$directive]) { + throw new InvalidArgumentException( + sprintf( + 'Declare value invalid. Expected %s, got %s.', + self::ALLOWED[$directive], + gettype($value) + ) + ); + } + + $method = str_replace('_', '', lcfirst(ucwords($directive, '_'))); + + return self::{$method}($value); + } + + /** + * @return string + */ + public function getStatement(): string + { + $value = is_string($this->value) ? '\'' . $this->value . '\'' : $this->value; + + return sprintf('declare(%s=%s);', $this->directive, $value); + } +} diff --git a/src/Generator/AbstractMemberGenerator.php b/src/Generator/AbstractMemberGenerator.php index b332da9b..afcbefea 100644 --- a/src/Generator/AbstractMemberGenerator.php +++ b/src/Generator/AbstractMemberGenerator.php @@ -36,7 +36,7 @@ abstract class AbstractMemberGenerator extends AbstractGenerator /**#@-*/ /** - * @var DocBlockGenerator + * @var DocBlockGenerator|null */ protected $docBlock; @@ -236,8 +236,13 @@ public function setDocBlock($docBlock) return $this; } + public function removeDocBlock(): void + { + $this->docBlock = null; + } + /** - * @return DocBlockGenerator + * @return DocBlockGenerator|null */ public function getDocBlock() { diff --git a/src/Generator/FileGenerator.php b/src/Generator/FileGenerator.php index 8253b603..73af4cab 100644 --- a/src/Generator/FileGenerator.php +++ b/src/Generator/FileGenerator.php @@ -9,6 +9,8 @@ namespace Zend\Code\Generator; +use Zend\Code\DeclareStatement; +use Zend\Code\Exception\InvalidArgumentException; use Zend\Code\Reflection\Exception as ReflectionException; use Zend\Code\Reflection\FileReflection; @@ -72,6 +74,11 @@ class FileGenerator extends AbstractGenerator */ protected $body; + /** + * @var DeclareStatement[] + */ + protected $declares = []; + /** * Passes $options to {@link setOptions()}. * @@ -166,6 +173,11 @@ public static function fromArray(array $values) case 'requiredfiles': $fileGenerator->setRequiredFiles($value); break; + case 'declares': + $fileGenerator->setDeclares(array_map(static function ($directive, $value) { + return DeclareStatement::fromArray([$directive => $value]); + }, array_keys($value), $value)); + break; default: if (property_exists($fileGenerator, $name)) { $fileGenerator->{$name} = $value; @@ -408,6 +420,25 @@ public function getBody() return $this->body; } + public function setDeclares(array $declares) + { + foreach ($declares as $declare) { + if (! $declare instanceof DeclareStatement) { + throw new InvalidArgumentException(sprintf( + '%s is expecting an array of %s objects', + __METHOD__, + DeclareStatement::class + )); + } + + if (! array_key_exists($declare->getDirective(), $this->declares)) { + $this->declares[$declare->getDirective()] = $declare; + } + } + + return $this; + } + /** * @return bool */ @@ -491,6 +522,28 @@ public function generate() } } + // declares, if any + if ($this->declares) { + $declareStatements = ''; + + foreach ($this->declares as $declare) { + $declareStatements .= $declare->getStatement() . self::LINE_FEED; + } + + if (preg_match('#/\* Zend_Code_Generator_FileGenerator-DeclaresMarker \*/#m', $output)) { + $output = preg_replace( + '#/\* Zend_Code_Generator_FileGenerator-DeclaresMarker \*/#m', + $declareStatements, + $output, + 1 + ); + } else { + $output .= $declareStatements; + } + + $output .= self::LINE_FEED; + } + // process required files // @todo marker replacement for required files $requiredFiles = $this->getRequiredFiles(); diff --git a/src/Generator/PropertyGenerator.php b/src/Generator/PropertyGenerator.php index 6259efc0..35901ef5 100644 --- a/src/Generator/PropertyGenerator.php +++ b/src/Generator/PropertyGenerator.php @@ -46,7 +46,11 @@ public static function fromReflection(PropertyReflection $reflectionProperty) $allDefaultProperties = $reflectionProperty->getDeclaringClass()->getDefaultProperties(); - $property->setDefaultValue($allDefaultProperties[$reflectionProperty->getName()]); + $defaultValue = $allDefaultProperties[$reflectionProperty->getName()]; + $property->setDefaultValue($defaultValue); + if ($defaultValue === null) { + $property->omitDefaultValue = true; + } if ($reflectionProperty->getDocComment() != '') { $property->setDocBlock(DocBlockGenerator::fromReflection($reflectionProperty->getDocBlock())); @@ -157,7 +161,6 @@ public function __construct($name = null, $defaultValue = null, $flags = self::F public function setConst($const) { if ($const) { - $this->removeFlag(self::FLAG_PUBLIC | self::FLAG_PRIVATE | self::FLAG_PROTECTED); $this->setFlags(self::FLAG_CONSTANT); } else { $this->removeFlag(self::FLAG_CONSTANT); @@ -227,7 +230,7 @@ public function generate() $this->name )); } - $output .= $this->indentation . 'const ' . $name . ' = ' + $output .= $this->indentation . $this->getVisibility() . ' const ' . $name . ' = ' . ($defaultValue !== null ? $defaultValue->generate() : 'null;'); return $output; diff --git a/src/Generator/ValueGenerator.php b/src/Generator/ValueGenerator.php index 3c7b4c3b..28d1fa42 100644 --- a/src/Generator/ValueGenerator.php +++ b/src/Generator/ValueGenerator.php @@ -25,6 +25,7 @@ use function in_array; use function is_array; use function is_int; +use function is_object; use function max; use function sprintf; use function str_repeat; @@ -361,6 +362,7 @@ public function generate() } $curValue = new self($curValue, $newType, self::OUTPUT_MULTIPLE_LINE, $this->getConstants()); + $curValue->setIndentation($this->indentation); } } @@ -436,9 +438,10 @@ public function generate() break; case self::TYPE_OTHER: default: - throw new Exception\RuntimeException( - sprintf('Type "%s" is unknown or cannot be used as property default value.', get_class($value)) - ); + throw new Exception\RuntimeException(sprintf( + 'Type "%s" is unknown or cannot be used as property default value.', + is_object($value) ? get_class($value) : gettype($value) + )); } return $output; diff --git a/src/NameInformation.php b/src/NameInformation.php index 8c096642..bea84ac6 100644 --- a/src/NameInformation.php +++ b/src/NameInformation.php @@ -141,11 +141,11 @@ public function getUses() */ public function resolveName($name) { - if ($this->namespace && ! $this->uses && strlen($name) > 0 && $name{0} != '\\') { + if ($this->namespace && ! $this->uses && strlen($name) > 0 && $name[0] != '\\') { return $this->namespace . '\\' . $name; } - if (! $this->uses || strlen($name) <= 0 || $name{0} == '\\') { + if (! $this->uses || strlen($name) <= 0 || $name[0] == '\\') { return ltrim($name, '\\'); } diff --git a/src/Reflection/ParameterReflection.php b/src/Reflection/ParameterReflection.php index 5c953e35..7a53bbf2 100644 --- a/src/Reflection/ParameterReflection.php +++ b/src/Reflection/ParameterReflection.php @@ -81,7 +81,7 @@ public function detectType() && ($type = $this->getType()) && $type->isBuiltin() ) { - return (string) $type; + return $type->getName(); } // can be dropped when dropping PHP7 support: diff --git a/src/Scanner/ClassScanner.php b/src/Scanner/ClassScanner.php index ba734e30..af4da112 100644 --- a/src/Scanner/ClassScanner.php +++ b/src/Scanner/ClassScanner.php @@ -912,13 +912,13 @@ protected function scan() if (is_string($token)) { $tokenType = null; $tokenContent = $token; - $tokenLine = $tokenLine + substr_count( - $lastTokenArray[1], + $tokenLine += substr_count( + $lastTokenArray[1] ?? '', "\n" ); // adjust token line by last known newline count } else { $lastTokenArray = $token; - list($tokenType, $tokenContent, $tokenLine) = $token; + [$tokenType, $tokenContent, $tokenLine] = $token; } return $tokenIndex; diff --git a/src/Scanner/MethodScanner.php b/src/Scanner/MethodScanner.php index 36542028..e0796666 100644 --- a/src/Scanner/MethodScanner.php +++ b/src/Scanner/MethodScanner.php @@ -451,12 +451,13 @@ protected function scan() if (is_string($token)) { $tokenType = null; $tokenContent = $token; - $tokenLine = $tokenLine + substr_count( - $lastTokenArray[1], + $tokenLine += substr_count( + $lastTokenArray[1] ?? '', "\n" ); // adjust token line by last known newline count } else { - list($tokenType, $tokenContent, $tokenLine) = $token; + $lastTokenArray = $token; + [$tokenType, $tokenContent, $tokenLine] = $token; } return $tokenIndex; diff --git a/src/Scanner/Util.php b/src/Scanner/Util.php index 764060c2..b1d4ad39 100644 --- a/src/Scanner/Util.php +++ b/src/Scanner/Util.php @@ -48,13 +48,13 @@ public static function resolveImports(&$value, $key = null, stdClass $data = nul )); } - if ($data->namespace && ! $data->uses && strlen($value) > 0 && $value{0} != '\\') { + if ($data->namespace && ! $data->uses && strlen($value) > 0 && $value[0] != '\\') { $value = $data->namespace . '\\' . $value; return; } - if (! $data->uses || strlen($value) <= 0 || $value{0} == '\\') { + if (! $data->uses || strlen($value) <= 0 || $value[0] == '\\') { $value = ltrim($value, '\\'); return; diff --git a/test/Annotation/AnnotationManagerTest.php b/test/Annotation/AnnotationManagerTest.php index ae2f5937..7ef24232 100644 --- a/test/Annotation/AnnotationManagerTest.php +++ b/test/Annotation/AnnotationManagerTest.php @@ -18,7 +18,7 @@ class AnnotationManagerTest extends TestCase { - public function setUp() + protected function setUp() : void { if (! getenv('TESTS_ZEND_CODE_ANNOTATION_DOCTRINE_SUPPORT')) { $this->markTestSkipped( diff --git a/test/Annotation/DoctrineAnnotationParserTest.php b/test/Annotation/DoctrineAnnotationParserTest.php index 1f5ab2c4..147629a9 100644 --- a/test/Annotation/DoctrineAnnotationParserTest.php +++ b/test/Annotation/DoctrineAnnotationParserTest.php @@ -23,7 +23,7 @@ class DoctrineAnnotationParserTest extends TestCase */ private $parser; - public function setUp() + protected function setUp() : void { if (! getenv('TESTS_ZEND_CODE_ANNOTATION_DOCTRINE_SUPPORT')) { $this->markTestSkipped( diff --git a/test/Annotation/GenericAnnotationParserTest.php b/test/Annotation/GenericAnnotationParserTest.php index 22d7c551..ba7bf601 100644 --- a/test/Annotation/GenericAnnotationParserTest.php +++ b/test/Annotation/GenericAnnotationParserTest.php @@ -23,7 +23,7 @@ class GenericAnnotationParserTest extends TestCase */ private $parser; - public function setUp() + protected function setUp() : void { $this->parser = new Annotation\Parser\GenericAnnotationParser(); } diff --git a/test/Generator/AbstractMemberGeneratorTest.php b/test/Generator/AbstractMemberGeneratorTest.php index e1c5829d..e662ff17 100644 --- a/test/Generator/AbstractMemberGeneratorTest.php +++ b/test/Generator/AbstractMemberGeneratorTest.php @@ -11,6 +11,7 @@ use PHPUnit\Framework\TestCase; use Zend\Code\Generator\AbstractMemberGenerator; +use Zend\Code\Generator\DocBlockGenerator; use Zend\Code\Generator\Exception\InvalidArgumentException; class AbstractMemberGeneratorTest extends TestCase @@ -20,7 +21,7 @@ class AbstractMemberGeneratorTest extends TestCase */ private $fixture; - protected function setUp() + protected function setUp() : void { $this->fixture = $this->getMockForAbstractClass(AbstractMemberGenerator::class); } @@ -43,4 +44,21 @@ public function testSetDocBlockThrowsExceptionWithInvalidType() $this->expectException(InvalidArgumentException::class); $this->fixture->setDocBlock(new \stdClass()); } + + public function testRemoveDocBlock(): void + { + $this->fixture->setDocBlock(new DocBlockGenerator()); + + $this->fixture->removeDocBlock(); + + $this->assertNull($this->fixture->getDocBlock()); + } + + public function testRemoveDocBlockIsIdempotent(): void + { + $this->fixture->removeDocBlock(); + $this->fixture->removeDocBlock(); + + $this->assertNull($this->fixture->getDocBlock()); + } } diff --git a/test/Generator/ClassGeneratorTest.php b/test/Generator/ClassGeneratorTest.php index 1363aa58..ea0ff6c6 100644 --- a/test/Generator/ClassGeneratorTest.php +++ b/test/Generator/ClassGeneratorTest.php @@ -295,7 +295,7 @@ public function testClassFromReflectionThatImplementsInterfaces() $expectedClassDef = 'class ClassWithInterface' . ' implements OneInterface' . ', TwoInterface'; - self::assertContains($expectedClassDef, $code); + self::assertStringContainsString($expectedClassDef, $code); } /** @@ -313,7 +313,7 @@ public function testClassFromReflectionDiscardParentImplementedInterfaces() $expectedClassDef = 'class NewClassWithInterface' . ' extends ClassWithInterface' . ' implements ThreeInterface'; - self::assertContains($expectedClassDef, $code); + self::assertStringContainsString($expectedClassDef, $code); } /** @@ -411,7 +411,7 @@ public function testPassingANamespacedClassnameShouldGenerateANamespaceDeclarati $classGeneratorClass = new ClassGenerator(); $classGeneratorClass->setName('My\Namespaced\FunClass'); $received = $classGeneratorClass->generate(); - self::assertContains('namespace My\Namespaced;', $received, $received); + self::assertStringContainsString('namespace My\Namespaced;', $received, $received); } /** @@ -422,7 +422,7 @@ public function testPassingANamespacedClassnameShouldGenerateAClassnameWithoutIt $classGeneratorClass = new ClassGenerator(); $classGeneratorClass->setName('My\Namespaced\FunClass'); $received = $classGeneratorClass->generate(); - self::assertContains('class FunClass', $received, $received); + self::assertStringContainsString('class FunClass', $received, $received); } public function testHasUse() @@ -478,8 +478,8 @@ public function testAddUses() $classGenerator->addUse('My\Second\Use\Class', 'MyAlias'); $generated = $classGenerator->generate(); - self::assertContains('use My\First\Use\Class;', $generated); - self::assertContains('use My\Second\Use\Class as MyAlias;', $generated); + self::assertStringContainsString('use My\First\Use\Class;', $generated); + self::assertStringContainsString('use My\Second\Use\Class as MyAlias;', $generated); } /** @@ -495,7 +495,7 @@ public function testAddOneUseTwiceOnlyAddsOne() self::assertCount(1, $classGenerator->getUses()); - self::assertContains('use My\First\Use\Class;', $generated); + self::assertStringContainsString('use My\First\Use\Class;', $generated); } /** @@ -511,7 +511,7 @@ public function testAddOneUseWithAliasTwiceOnlyAddsOne() self::assertCount(1, $classGenerator->getUses()); - self::assertContains('use My\First\Use\Class as MyAlias;', $generated); + self::assertStringContainsString('use My\First\Use\Class as MyAlias;', $generated); } public function testCreateFromArrayWithDocBlockFromArray() @@ -543,12 +543,12 @@ public function testExtendedClassProperies() $reflClass = new ClassReflection(TestAsset\ExtendedClassWithProperties::class); $classGenerator = ClassGenerator::fromReflection($reflClass); $code = $classGenerator->generate(); - self::assertContains('publicExtendedClassProperty', $code); - self::assertContains('protectedExtendedClassProperty', $code); - self::assertContains('privateExtendedClassProperty', $code); - self::assertNotContains('publicClassProperty', $code); - self::assertNotContains('protectedClassProperty', $code); - self::assertNotContains('privateClassProperty', $code); + self::assertStringContainsString('publicExtendedClassProperty', $code); + self::assertStringContainsString('protectedExtendedClassProperty', $code); + self::assertStringContainsString('privateExtendedClassProperty', $code); + self::assertStringNotContainsString('publicClassProperty', $code); + self::assertStringNotContainsString('protectedClassProperty', $code); + self::assertStringNotContainsString('privateClassProperty', $code); } public function testHasMethodInsensitive() @@ -802,7 +802,7 @@ public function testClassCanBeGeneratedWithConstantAndPropertyWithSameName() class TestSampleSingleClass { - const fooProperty = 'duplicate'; + public const fooProperty = 'duplicate'; public $fooProperty = true; @@ -1185,7 +1185,7 @@ public function testCorrectExtendNames() $classGenerator->setNamespaceName('SomeNamespace'); $classGenerator->addUse(NameInformation::class); $classGenerator->setExtendedClass(NameInformation::class); - self::assertContains('class ClassName extends NameInformation', $classGenerator->generate()); + self::assertStringContainsString('class ClassName extends NameInformation', $classGenerator->generate()); } /** @@ -1197,7 +1197,7 @@ public function testCorrectlyExtendsFullyQualifiedParentClass() $classGenerator->setName('ClassName'); $classGenerator->setNamespaceName('SomeNamespace'); $classGenerator->setExtendedClass('DateTime'); - self::assertContains('class ClassName extends \DateTime', $classGenerator->generate()); + self::assertStringContainsString('class ClassName extends \DateTime', $classGenerator->generate()); } /** @@ -1208,7 +1208,7 @@ public function testCorrectlyExtendsRelativeParentClass() $classGenerator = new ClassGenerator(); $classGenerator->setName('ClassName'); $classGenerator->setExtendedClass('DateTime'); - self::assertContains('class ClassName extends DateTime', $classGenerator->generate()); + self::assertStringContainsString('class ClassName extends DateTime', $classGenerator->generate()); } /** @@ -1220,12 +1220,12 @@ public function testCorrectExtendNamesFromGlobalNamespace() $classGenerator->setName('ClassName'); $classGenerator->setNamespaceName('SomeNamespace'); $classGenerator->setExtendedClass(DateTime::class); - self::assertContains('class ClassName extends \DateTime', $classGenerator->generate()); + self::assertStringContainsString('class ClassName extends \DateTime', $classGenerator->generate()); $classGenerator = new ClassGenerator(); $classGenerator->setName('ClassName'); $classGenerator->setExtendedClass(DateTime::class); - self::assertContains('class ClassName extends DateTime', $classGenerator->generate()); + self::assertStringContainsString('class ClassName extends DateTime', $classGenerator->generate()); } public function testCorrectlyExtendsProvidedAliasIfUseAliasExists() @@ -1236,7 +1236,7 @@ public function testCorrectlyExtendsProvidedAliasIfUseAliasExists() $classGenerator->addUse('Foo\\Bar', 'BarAlias'); $classGenerator->setExtendedClass('BarAlias'); $generated = $classGenerator->generate(); - self::assertContains('class ClassName extends BarAlias', $generated); + self::assertStringContainsString('class ClassName extends BarAlias', $generated); } public function testCorrectlyExtendsProvidedNamespaceAliasIfUseAliasExistsForNamespace() @@ -1247,7 +1247,7 @@ public function testCorrectlyExtendsProvidedNamespaceAliasIfUseAliasExistsForNam $classGenerator->addUse('Foo\\Bar', 'BarAlias'); $classGenerator->setExtendedClass('BarAlias\\FooBar'); $generated = $classGenerator->generate(); - self::assertContains('class ClassName extends BarAlias\\FooBar', $generated); + self::assertStringContainsString('class ClassName extends BarAlias\\FooBar', $generated); } public function testCorrectlyExtendsAliasOfProvidedFQCNIfUseAliasExists() @@ -1258,7 +1258,7 @@ public function testCorrectlyExtendsAliasOfProvidedFQCNIfUseAliasExists() $classGenerator->addUse('Foo\\Bar', 'BarAlias'); $classGenerator->setExtendedClass('Foo\\Bar'); $generated = $classGenerator->generate(); - self::assertContains('class ClassName extends BarAlias', $generated); + self::assertStringContainsString('class ClassName extends BarAlias', $generated); } public function testCorrectlyExtendsWithNamespaceAliasOfProvidedFQCNIfUseAliasExistsForNamespace() @@ -1269,7 +1269,7 @@ public function testCorrectlyExtendsWithNamespaceAliasOfProvidedFQCNIfUseAliasEx $classGenerator->addUse('Foo\\Bar', 'BarAlias'); $classGenerator->setExtendedClass('Foo\\Bar\\FooBar'); $generated = $classGenerator->generate(); - self::assertContains('class ClassName extends BarAlias\\FooBar', $generated); + self::assertStringContainsString('class ClassName extends BarAlias\\FooBar', $generated); } public function testCorrectImplementNames() @@ -1285,6 +1285,6 @@ public function testCorrectImplementNames() ]); $expected = 'class ClassName implements ClassInterface, GeneratorInterface, \Iteratable'; - self::assertContains($expected, $classGenerator->generate()); + self::assertStringContainsString($expected, $classGenerator->generate()); } } diff --git a/test/Generator/DocBlock/Tag/AuthorTagTest.php b/test/Generator/DocBlock/Tag/AuthorTagTest.php index d1ad2f33..e020fe0b 100644 --- a/test/Generator/DocBlock/Tag/AuthorTagTest.php +++ b/test/Generator/DocBlock/Tag/AuthorTagTest.php @@ -30,14 +30,14 @@ class AuthorTagTest extends TestCase */ protected $tagmanager; - public function setUp() + protected function setUp() : void { $this->tag = new AuthorTag(); $this->tagmanager = new TagManager(); $this->tagmanager->initializeDefaultTags(); } - public function tearDown() + protected function tearDown() : void { $this->tag = null; $this->tagmanager = null; diff --git a/test/Generator/DocBlock/Tag/GenericTagTest.php b/test/Generator/DocBlock/Tag/GenericTagTest.php index 35dc06ba..6b18241c 100644 --- a/test/Generator/DocBlock/Tag/GenericTagTest.php +++ b/test/Generator/DocBlock/Tag/GenericTagTest.php @@ -30,14 +30,14 @@ class GenericTagTest extends TestCase */ protected $tagmanager; - public function setUp() + protected function setUp() : void { $this->tag = new GenericTag(); $this->tagmanager = new TagManager(); $this->tagmanager->initializeDefaultTags(); } - public function tearDown() + protected function tearDown() : void { $this->tag = null; $this->tagmanager = null; diff --git a/test/Generator/DocBlock/Tag/LicenseTagTest.php b/test/Generator/DocBlock/Tag/LicenseTagTest.php index bca09b07..fabe90b5 100644 --- a/test/Generator/DocBlock/Tag/LicenseTagTest.php +++ b/test/Generator/DocBlock/Tag/LicenseTagTest.php @@ -30,14 +30,14 @@ class LicenseTagTest extends TestCase */ protected $tagmanager; - public function setUp() + protected function setUp() : void { $this->tag = new LicenseTag(); $this->tagmanager = new TagManager(); $this->tagmanager->initializeDefaultTags(); } - public function tearDown() + protected function tearDown() : void { $this->tag = null; $this->tagmanager = null; diff --git a/test/Generator/DocBlock/Tag/MethodTagTest.php b/test/Generator/DocBlock/Tag/MethodTagTest.php index d22f7545..5d4d5a4a 100644 --- a/test/Generator/DocBlock/Tag/MethodTagTest.php +++ b/test/Generator/DocBlock/Tag/MethodTagTest.php @@ -30,14 +30,14 @@ class MethodTagTest extends TestCase */ protected $tagmanager; - public function setUp() + protected function setUp() : void { $this->tag = new MethodTag(); $this->tagmanager = new TagManager(); $this->tagmanager->initializeDefaultTags(); } - public function tearDown() + protected function tearDown() : void { $this->tag = null; $this->tagmanager = null; diff --git a/test/Generator/DocBlock/Tag/ParamTagTest.php b/test/Generator/DocBlock/Tag/ParamTagTest.php index 324e59dd..d4e730bf 100644 --- a/test/Generator/DocBlock/Tag/ParamTagTest.php +++ b/test/Generator/DocBlock/Tag/ParamTagTest.php @@ -30,14 +30,14 @@ class ParamTagTest extends TestCase */ protected $tagmanager; - public function setUp() + protected function setUp() : void { $this->tag = new ParamTag(); $this->tagmanager = new TagManager(); $this->tagmanager->initializeDefaultTags(); } - public function tearDown() + protected function tearDown() : void { $this->tag = null; $this->tagmanager = null; diff --git a/test/Generator/DocBlock/Tag/PropertyTagTest.php b/test/Generator/DocBlock/Tag/PropertyTagTest.php index df2f0286..709159ed 100644 --- a/test/Generator/DocBlock/Tag/PropertyTagTest.php +++ b/test/Generator/DocBlock/Tag/PropertyTagTest.php @@ -30,14 +30,14 @@ class PropertyTagTest extends TestCase */ protected $tagmanager; - public function setUp() + protected function setUp() : void { $this->tag = new PropertyTag(); $this->tagmanager = new TagManager(); $this->tagmanager->initializeDefaultTags(); } - public function tearDown() + protected function tearDown() : void { $this->tag = null; $this->tagmanager = null; diff --git a/test/Generator/DocBlock/Tag/ReturnTagTest.php b/test/Generator/DocBlock/Tag/ReturnTagTest.php index 30ce6c28..a03fea9d 100644 --- a/test/Generator/DocBlock/Tag/ReturnTagTest.php +++ b/test/Generator/DocBlock/Tag/ReturnTagTest.php @@ -30,14 +30,14 @@ class ReturnTagTest extends TestCase */ protected $tagmanager; - public function setUp() + protected function setUp() : void { $this->tag = new ReturnTag(); $this->tagmanager = new TagManager(); $this->tagmanager->initializeDefaultTags(); } - public function tearDown() + protected function tearDown() : void { $this->tag = null; $this->tagmanager = null; diff --git a/test/Generator/DocBlock/Tag/ThrowsTagTest.php b/test/Generator/DocBlock/Tag/ThrowsTagTest.php index ec145e47..8674ef2e 100644 --- a/test/Generator/DocBlock/Tag/ThrowsTagTest.php +++ b/test/Generator/DocBlock/Tag/ThrowsTagTest.php @@ -30,14 +30,14 @@ class ThrowsTagTest extends TestCase */ protected $tagmanager; - public function setUp() + protected function setUp() : void { $this->tag = new ThrowsTag(); $this->tagmanager = new TagManager(); $this->tagmanager->initializeDefaultTags(); } - public function tearDown() + protected function tearDown() : void { $this->tag = null; $this->tagmanager = null; diff --git a/test/Generator/DocBlock/Tag/TypableTagTest.php b/test/Generator/DocBlock/Tag/TypableTagTest.php index a3224e3b..5f8f06ed 100644 --- a/test/Generator/DocBlock/Tag/TypableTagTest.php +++ b/test/Generator/DocBlock/Tag/TypableTagTest.php @@ -23,12 +23,12 @@ class TypableTagTest extends TestCase */ protected $tag; - public function setUp() + protected function setUp() : void { $this->tag = new TypeableTag(); } - public function tearDown() + protected function tearDown() : void { $this->tag = null; } diff --git a/test/Generator/DocBlockGeneratorTest.php b/test/Generator/DocBlockGeneratorTest.php index c89053b7..ec15d054 100644 --- a/test/Generator/DocBlockGeneratorTest.php +++ b/test/Generator/DocBlockGeneratorTest.php @@ -34,7 +34,7 @@ class DocBlockGeneratorTest extends TestCase */ protected $reflectionDocBlockGenerator; - protected function setUp() + protected function setUp() : void { $this->docBlockGenerator = $this->docBlockGenerator = new DocBlockGenerator(); $reflectionDocBlock = new DocBlockReflection( diff --git a/test/Generator/FileGeneratorTest.php b/test/Generator/FileGeneratorTest.php index f2ec0bc9..a83cc5b4 100644 --- a/test/Generator/FileGeneratorTest.php +++ b/test/Generator/FileGeneratorTest.php @@ -10,6 +10,8 @@ namespace ZendTest\Code\Generator; use PHPUnit\Framework\TestCase; +use Zend\Code\DeclareStatement; +use Zend\Code\Exception\InvalidArgumentException; use Zend\Code\Generator\ClassGenerator; use Zend\Code\Generator\FileGenerator; use Zend\Code\Reflection\FileReflection; @@ -184,7 +186,7 @@ public function testFileLineEndingsAreAlwaysLineFeed() $targetLength = strlen('require_once \'SampleClass.php\';'); self::assertEquals($targetLength, strlen($lines[2])); - self::assertEquals(';', $lines[2]{$targetLength - 1}); + self::assertEquals(';', $lines[2][$targetLength - 1]); } /** @@ -198,8 +200,8 @@ public function testGeneratesUseStatements() ['use' => 'Your\Bar', 'as' => 'bar'], ]); $generated = $file->generate(); - self::assertContains('use My\\Baz;', $generated); - self::assertContains('use Your\\Bar as bar;', $generated); + self::assertStringContainsString('use My\\Baz;', $generated); + self::assertStringContainsString('use Your\\Bar as bar;', $generated); } public function testGeneratesNamespaceStatements() @@ -207,7 +209,7 @@ public function testGeneratesNamespaceStatements() $file = new FileGenerator(); $file->setNamespace('Foo\Bar'); $generated = $file->generate(); - self::assertContains('namespace Foo\\Bar', $generated, $generated); + self::assertStringContainsString('namespace Foo\\Bar', $generated, $generated); } public function testSetUseDoesntGenerateMultipleIdenticalUseStatements() @@ -238,8 +240,8 @@ public function testSetUseAllowsMultipleAliasedUseStatements() ['use' => 'Your\Bar', 'as' => 'bar2'], ]); $generated = $file->generate(); - self::assertContains('use Your\\Bar as bar;', $generated); - self::assertContains('use Your\\Bar as bar2;', $generated); + self::assertStringContainsString('use Your\\Bar as bar;', $generated); + self::assertStringContainsString('use Your\\Bar as bar2;', $generated); } public function testSetUsesWithArrays() @@ -250,8 +252,8 @@ public function testSetUsesWithArrays() ['use' => 'My\\Baz', 'as' => 'FooBaz'], ]); $generated = $file->generate(); - self::assertContains('use My\\Baz as FooBaz;', $generated); - self::assertContains('use Your\\Bar as bar;', $generated); + self::assertStringContainsString('use My\\Baz as FooBaz;', $generated); + self::assertStringContainsString('use Your\\Bar as bar;', $generated); } public function testSetUsesWithString() @@ -263,9 +265,9 @@ public function testSetUsesWithString() ['use' => 'Another\\Baz', 'as' => 'Baz2'], ]); $generated = $file->generate(); - self::assertContains('use My\\Baz;', $generated); - self::assertContains('use Your\\Bar;', $generated); - self::assertContains('use Another\\Baz as Baz2;', $generated); + self::assertStringContainsString('use My\\Baz;', $generated); + self::assertStringContainsString('use Your\\Bar;', $generated); + self::assertStringContainsString('use Another\\Baz as Baz2;', $generated); } public function testSetUsesWithGetUses() @@ -279,9 +281,9 @@ public function testSetUsesWithGetUses() $file->setUses($uses); $file->setUses($file->getUses()); $generated = $file->generate(); - self::assertContains('use My\\Baz;', $generated); - self::assertContains('use Your\\Bar;', $generated); - self::assertContains('use Another\\Baz as Baz2;', $generated); + self::assertStringContainsString('use My\\Baz;', $generated); + self::assertStringContainsString('use Your\\Bar;', $generated); + self::assertStringContainsString('use Another\\Baz as Baz2;', $generated); } public function testCreateFromArrayWithClassInstance() @@ -413,4 +415,139 @@ public function added() $actual = file_get_contents(sys_get_temp_dir() . '/result_class.php'); self::assertEquals($expected, $actual); } + + public function testSingleDeclareStatement(): void + { + $generator = FileGenerator::fromArray([ + 'declares' => [ + 'strict_types' => 1, + ], + 'class' => [ + 'name' => 'SampleClass', + ], + ]); + $generator->setFilename(sys_get_temp_dir() . '/result_file.php'); + $generator->write(); + + $expected = <<assertEquals($expected, $actual); + } + + public function testMultiDeclareStatements(): void + { + $generator = FileGenerator::fromArray([ + 'declares' => [ + 'strict_types' => 1, + 'ticks' => 2, + ], + 'class' => [ + 'name' => 'SampleClass', + ], + ]); + $generator->setFilename(sys_get_temp_dir() . '/result_file.php'); + $generator->write(); + + $expected = <<assertEquals($expected, $actual); + } + + public function testDeclareUnknownDirectiveShouldRaiseException(): void + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Declare directive must be one of: ticks, strict_types, encoding.'); + + FileGenerator::fromArray([ + 'declares' => [ + 'fubar' => 1, + ], + 'class' => [ + 'name' => 'SampleClass', + ], + ]); + } + + public function testDeclareWrongTypeShouldRaiseException(): void + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Declare value invalid. Expected integer, got string.'); + + FileGenerator::fromArray([ + 'declares' => [ + 'strict_types' => 'wrong type', + ], + 'class' => [ + 'name' => 'SampleClass', + ], + ]); + } + + public function testDeclareDuplicatesShouldOnlyGenerateOne(): void + { + $generator = FileGenerator::fromArray([ + 'class' => [ + 'name' => 'SampleClass', + ], + ]); + $generator->setFilename(sys_get_temp_dir() . '/result_file.php'); + $generator->setDeclares([ + DeclareStatement::strictTypes(1), + DeclareStatement::strictTypes(2) + ]); + $generator->write(); + + $expected = <<assertEquals($expected, $actual); + } + + public function testWrongDeclareTypeShouldRaiseException(): void + { + $generator = new FileGenerator(); + + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('setDeclares is expecting an array of Zend\\Code\\DeclareStatement objects'); + $generator->setDeclares([new \stdClass()]); + } } diff --git a/test/Generator/InterfaceGeneratorTest.php b/test/Generator/InterfaceGeneratorTest.php index 15c57fb9..0b9c3eea 100644 --- a/test/Generator/InterfaceGeneratorTest.php +++ b/test/Generator/InterfaceGeneratorTest.php @@ -152,9 +152,9 @@ public function testCodeGenerationShouldTakeIntoAccountNamespacesFromReflection( interface FooInterface { - const BAR = 5; + public const BAR = 5; - const FOO = 5; + public const FOO = 5; public function fooBarBaz(); @@ -183,7 +183,7 @@ public function testPassingANamespacedClassnameShouldGenerateANamespaceDeclarati $classGeneratorClass = new InterfaceGenerator(); $classGeneratorClass->setName('My\Namespaced\FunClass'); $received = $classGeneratorClass->generate(); - self::assertContains('namespace My\Namespaced;', $received, $received); + self::assertStringContainsString('namespace My\Namespaced;', $received, $received); } /** @@ -194,7 +194,7 @@ public function testPassingANamespacedClassnameShouldGenerateAClassnameWithoutIt $classGeneratorClass = new InterfaceGenerator(); $classGeneratorClass->setName('My\Namespaced\FunClass'); $received = $classGeneratorClass->generate(); - self::assertContains('interface FunClass', $received, $received); + self::assertStringContainsString('interface FunClass', $received, $received); } public function testCreateFromArrayWithDocBlockFromArray() diff --git a/test/Generator/MethodGeneratorTest.php b/test/Generator/MethodGeneratorTest.php index 0411a49f..2c5d16f6 100644 --- a/test/Generator/MethodGeneratorTest.php +++ b/test/Generator/MethodGeneratorTest.php @@ -247,7 +247,7 @@ public function testDefaultValueGenerationDoesNotIncludeTrailingSemicolon() $method->setParameter($param); $generated = $method->generate(); - self::assertContains('array $options = [])', $generated); + self::assertStringContainsString('array $options = [])', $generated); } public function testCreateFromArray() diff --git a/test/Generator/PropertyGeneratorTest.php b/test/Generator/PropertyGeneratorTest.php index 685c72e8..ad3db5ce 100644 --- a/test/Generator/PropertyGeneratorTest.php +++ b/test/Generator/PropertyGeneratorTest.php @@ -9,6 +9,7 @@ namespace ZendTest\Code\Generator; +use Generator; use PHPUnit\Framework\TestCase; use Zend\Code\Generator\DocBlock\Tag\VarTag; use Zend\Code\Generator\DocBlockGenerator; @@ -126,10 +127,26 @@ public function testPropertyMultilineValue() : void self::assertEquals($expectedSource, $targetSource); } + public function visibility() : Generator + { + yield 'public' => [PropertyGenerator::FLAG_PUBLIC, 'public']; + yield 'protected' => [PropertyGenerator::FLAG_PROTECTED, 'protected']; + yield 'private' => [PropertyGenerator::FLAG_PRIVATE, 'private']; + } + + /** + * @dataProvider visibility + */ + public function testPropertyCanProduceConstatWithVisibility(int $flag, string $visibility) : void + { + $codeGenProperty = new PropertyGenerator('FOO', 'bar', [PropertyGenerator::FLAG_CONSTANT, $flag]); + self::assertSame(' ' . $visibility . ' const FOO = \'bar\';', $codeGenProperty->generate()); + } + public function testPropertyCanProduceContstantModifier() : void { $codeGenProperty = new PropertyGenerator('someVal', 'some string value', PropertyGenerator::FLAG_CONSTANT); - self::assertEquals(' const someVal = \'some string value\';', $codeGenProperty->generate()); + self::assertEquals(' public const someVal = \'some string value\';', $codeGenProperty->generate()); } /** @@ -139,7 +156,7 @@ public function testPropertyCanProduceContstantModifierWithSetter() : void { $codeGenProperty = new PropertyGenerator('someVal', 'some string value'); $codeGenProperty->setConst(true); - self::assertEquals(' const someVal = \'some string value\';', $codeGenProperty->generate()); + self::assertEquals(' public const someVal = \'some string value\';', $codeGenProperty->generate()); } public function testPropertyCanProduceStaticModifier() : void @@ -262,7 +279,7 @@ public function testPropertyDocBlockWillLoadFromReflection() : void $docBlock = $cgProp->getDocBlock(); self::assertInstanceOf(DocBlockGenerator::class, $docBlock); $tags = $docBlock->getTags(); - self::assertInternalType('array', $tags); + self::assertIsArray($tags); self::assertCount(1, $tags); $tag = array_shift($tags); self::assertInstanceOf(VarTag::class, $tag); @@ -291,4 +308,15 @@ public function testOmitType() self::assertEquals(' public $foo;', $property->generate()); } + + public function testFromReflectionOmitsDefaultValueIfItIsNull() : void + { + $reflectionClass = new ClassReflection(TestAsset\TestClassWithManyProperties::class); + $propertyReflection = $reflectionClass->getProperty('fooStaticProperty'); + + $generator = PropertyGenerator::fromReflection($propertyReflection); + $code = $generator->generate(); + + $this->assertEquals(' public static $fooStaticProperty;', $code); + } } diff --git a/test/Generator/TraitGeneratorTest.php b/test/Generator/TraitGeneratorTest.php index a838585f..c73c7a38 100644 --- a/test/Generator/TraitGeneratorTest.php +++ b/test/Generator/TraitGeneratorTest.php @@ -26,7 +26,7 @@ */ class TraitGeneratorTest extends TestCase { - public function setUp() + protected function setUp() : void { } @@ -236,7 +236,7 @@ public function testClassFromReflectionThatImplementsInterfaces() $code = $classGenerator->generate(); $expectedClassDef = 'trait ClassWithInterface'; - self::assertContains($expectedClassDef, $code); + self::assertStringContainsString($expectedClassDef, $code); } /** @@ -252,7 +252,7 @@ public function testClassFromReflectionDiscardParentImplementedInterfaces() $code = $classGenerator->generate(); $expectedClassDef = 'trait NewClassWithInterface'; - self::assertContains($expectedClassDef, $code); + self::assertStringContainsString($expectedClassDef, $code); } /** @@ -350,7 +350,7 @@ public function testPassingANamespacedClassnameShouldGenerateANamespaceDeclarati $classGeneratorClass = new TraitGenerator(); $classGeneratorClass->setName('My\Namespaced\FunClass'); $received = $classGeneratorClass->generate(); - self::assertContains('namespace My\Namespaced;', $received, $received); + self::assertStringContainsString('namespace My\Namespaced;', $received, $received); } /** @@ -361,7 +361,7 @@ public function testPassingANamespacedClassnameShouldGenerateAClassnameWithoutIt $classGeneratorClass = new TraitGenerator(); $classGeneratorClass->setName('My\Namespaced\FunClass'); $received = $classGeneratorClass->generate(); - self::assertContains('trait FunClass', $received, $received); + self::assertStringContainsString('trait FunClass', $received, $received); } /** @@ -375,8 +375,8 @@ public function testAddUses() $classGenerator->addUse('My\Second\Use\Class', 'MyAlias'); $generated = $classGenerator->generate(); - self::assertContains('use My\First\Use\Class;', $generated); - self::assertContains('use My\Second\Use\Class as MyAlias;', $generated); + self::assertStringContainsString('use My\First\Use\Class;', $generated); + self::assertStringContainsString('use My\Second\Use\Class as MyAlias;', $generated); } /** @@ -392,7 +392,7 @@ public function testAddOneUseTwiceOnlyAddsOne() self::assertCount(1, $classGenerator->getUses()); - self::assertContains('use My\First\Use\Class;', $generated); + self::assertStringContainsString('use My\First\Use\Class;', $generated); } /** @@ -408,7 +408,7 @@ public function testAddOneUseWithAliasTwiceOnlyAddsOne() self::assertCount(1, $classGenerator->getUses()); - self::assertContains('use My\First\Use\Class as MyAlias;', $generated); + self::assertStringContainsString('use My\First\Use\Class as MyAlias;', $generated); } public function testCreateFromArrayWithDocBlockFromArray() @@ -440,12 +440,12 @@ public function testExtendedClassProperies() $reflClass = new ClassReflection(TestAsset\ExtendedClassWithProperties::class); $classGenerator = TraitGenerator::fromReflection($reflClass); $code = $classGenerator->generate(); - self::assertContains('publicExtendedClassProperty', $code); - self::assertContains('protectedExtendedClassProperty', $code); - self::assertContains('privateExtendedClassProperty', $code); - self::assertNotContains('publicClassProperty', $code); - self::assertNotContains('protectedClassProperty', $code); - self::assertNotContains('privateClassProperty', $code); + self::assertStringContainsString('publicExtendedClassProperty', $code); + self::assertStringContainsString('protectedExtendedClassProperty', $code); + self::assertStringContainsString('privateExtendedClassProperty', $code); + self::assertStringNotContainsString('publicClassProperty', $code); + self::assertStringNotContainsString('protectedClassProperty', $code); + self::assertStringNotContainsString('privateClassProperty', $code); } public function testHasMethodInsensitive() diff --git a/test/Generator/ValueGeneratorTest.php b/test/Generator/ValueGeneratorTest.php index c9e04c90..c33d521d 100644 --- a/test/Generator/ValueGeneratorTest.php +++ b/test/Generator/ValueGeneratorTest.php @@ -11,8 +11,11 @@ use ArrayAccess; use ArrayObject as SplArrayObject; +use DateTime; +use Generator; use PHPUnit\Framework\TestCase; use Zend\Code\Exception\InvalidArgumentException; +use Zend\Code\Exception\RuntimeException; use Zend\Code\Generator\PropertyGenerator; use Zend\Code\Generator\PropertyValueGenerator; use Zend\Code\Generator\ValueGenerator; @@ -92,7 +95,7 @@ public function validConstantTypes() return [ [ new PropertyValueGenerator([], PropertyValueGenerator::TYPE_ARRAY, ValueGenerator::OUTPUT_SINGLE_LINE), - ' const FOO = [];', + ' public const FOO = [];', ], [ new PropertyValueGenerator( @@ -100,7 +103,7 @@ public function validConstantTypes() PropertyValueGenerator::TYPE_ARRAY_LONG, ValueGenerator::OUTPUT_SINGLE_LINE ), - ' const FOO = array();', + ' public const FOO = array();', ], [ new PropertyValueGenerator( @@ -108,17 +111,20 @@ public function validConstantTypes() PropertyValueGenerator::TYPE_ARRAY_SHORT, ValueGenerator::OUTPUT_SINGLE_LINE ), - ' const FOO = [];', + ' public const FOO = [];', + ], + [new PropertyValueGenerator(true, PropertyValueGenerator::TYPE_BOOL), ' public const FOO = true;'], + [new PropertyValueGenerator(true, PropertyValueGenerator::TYPE_BOOLEAN), ' public const FOO = true;'], + [new PropertyValueGenerator(1, PropertyValueGenerator::TYPE_INT), ' public const FOO = 1;'], + [new PropertyValueGenerator(1, PropertyValueGenerator::TYPE_INTEGER), ' public const FOO = 1;'], + [new PropertyValueGenerator(0.1, PropertyValueGenerator::TYPE_DOUBLE), ' public const FOO = 0.1;'], + [new PropertyValueGenerator(0.1, PropertyValueGenerator::TYPE_FLOAT), ' public const FOO = 0.1;'], + [new PropertyValueGenerator('bar', PropertyValueGenerator::TYPE_STRING), " public const FOO = 'bar';"], + [new PropertyValueGenerator(null, PropertyValueGenerator::TYPE_NULL), ' public const FOO = null;'], + [ + new PropertyValueGenerator('PHP_EOL', PropertyValueGenerator::TYPE_CONSTANT), + ' public const FOO = PHP_EOL;', ], - [new PropertyValueGenerator(true, PropertyValueGenerator::TYPE_BOOL), ' const FOO = true;'], - [new PropertyValueGenerator(true, PropertyValueGenerator::TYPE_BOOLEAN), ' const FOO = true;'], - [new PropertyValueGenerator(1, PropertyValueGenerator::TYPE_INT), ' const FOO = 1;'], - [new PropertyValueGenerator(1, PropertyValueGenerator::TYPE_INTEGER), ' const FOO = 1;'], - [new PropertyValueGenerator(0.1, PropertyValueGenerator::TYPE_DOUBLE), ' const FOO = 0.1;'], - [new PropertyValueGenerator(0.1, PropertyValueGenerator::TYPE_FLOAT), ' const FOO = 0.1;'], - [new PropertyValueGenerator('bar', PropertyValueGenerator::TYPE_STRING), " const FOO = 'bar';"], - [new PropertyValueGenerator(null, PropertyValueGenerator::TYPE_NULL), ' const FOO = null;'], - [new PropertyValueGenerator('PHP_EOL', PropertyValueGenerator::TYPE_CONSTANT), ' const FOO = PHP_EOL;'], ]; } @@ -225,6 +231,85 @@ public function complexArray() return $this->generateArrayData($longOutput, $value); } + /** + * Data provider for testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes test + */ + public function complexArrayWCustomIndent(): array + { + $value = [ + '5bcf08a0a5d20' => [ + '5bcf08a0a5d65' => [ + '5bcf08a0a5d9f' => [ + '5bcf08a0a5dd8' => [ + '5bcf08a0a5e11' => [ + '5bcf08a0a5e4f' => '5bcf08a0a5e8c', + '5bcf08a0a5eca' => '5bcf08a0a5f05', + '5bcf08a0a5f43' => '5bcf08a0a5f7f', + '5bcf08a0a5fbd' => '5bcf08a0a5ff8', + ], + ], + '5bcf08a0a603a' => [], + '5bcf08a0a6062' => '5bcf08a0a609f', + '5bcf08a0a60dc' => [ + '5bcf08a0a611b' => '5bcf08a0a6158', + '5bcf08a0a6197' => [ + '5bcf08a0a61d7' => '5bcf08a0a6212', + '5bcf08a0a6250' => '5bcf08a0a628c', + '5bcf08a0a62cb' => '5bcf08a0a6306', + ], + '5bcf08a0a6345' => [ + '5bcf08a0a637e' => '5bcf08a0a63b4', + '5bcf08a0a63ee' => '5bcf08a0a642a', + ], + '5bcf08a0a6449' => '5bcf08a0a6485', + ], + ], + ], '5bcf08a0a64c8' => '5bcf08a0a6540', + '5bcf08a0a657f' => '5bcf08a0a65bf', + ], + ]; + + $longOutput = << array( + '5bcf08a0a5d65' => array( + '5bcf08a0a5d9f' => array( + '5bcf08a0a5dd8' => array( + '5bcf08a0a5e11' => array( + '5bcf08a0a5e4f' => '5bcf08a0a5e8c', + '5bcf08a0a5eca' => '5bcf08a0a5f05', + '5bcf08a0a5f43' => '5bcf08a0a5f7f', + '5bcf08a0a5fbd' => '5bcf08a0a5ff8', + ), + ), + '5bcf08a0a603a' => array( + + ), + '5bcf08a0a6062' => '5bcf08a0a609f', + '5bcf08a0a60dc' => array( + '5bcf08a0a611b' => '5bcf08a0a6158', + '5bcf08a0a6197' => array( + '5bcf08a0a61d7' => '5bcf08a0a6212', + '5bcf08a0a6250' => '5bcf08a0a628c', + '5bcf08a0a62cb' => '5bcf08a0a6306', + ), + '5bcf08a0a6345' => array( + '5bcf08a0a637e' => '5bcf08a0a63b4', + '5bcf08a0a63ee' => '5bcf08a0a642a', + ), + '5bcf08a0a6449' => '5bcf08a0a6485', + ), + ), + ), + '5bcf08a0a64c8' => '5bcf08a0a6540', + '5bcf08a0a657f' => '5bcf08a0a65bf', + ), +) +EOS; + + return $this->generateArrayData($longOutput, $value); + } + /** * Data provider for testPropertyDefaultValueCanHandleArrayWithUnsortedKeys test * @@ -338,6 +423,22 @@ public function testPropertyDefaultValueCanHandleComplexArrayOfTypes($type, arra self::assertEquals($expected, $valueGenerator->generate()); } + /** + * @dataProvider complexArrayWCustomIndent + */ + public function testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes( + string $type, + array $value, + string $expected + ) : void { + $valueGenerator = new ValueGenerator(); + $valueGenerator->setType($type); + $valueGenerator->setValue($value); + $valueGenerator->setIndentation("\t"); + + self::assertEquals($expected, $valueGenerator->generate()); + } + /** * @group 6023 * @@ -364,4 +465,24 @@ public function getEscapedParameters() ["\\'", "\\\\\\'"], ]; } + + public function invalidValue() : Generator + { + yield 'object' => [new DateTime(), DateTime::class]; + yield 'resource' => [fopen('php://input', 'r'), 'resource']; + } + + /** + * @dataProvider invalidValue + * + * @param mixed $value + */ + public function testExceptionInvalidValue($value, string $type) : void + { + $valueGenerator = new ValueGenerator($value); + + $this->expectException(RuntimeException::class); + $this->expectExceptionMessage('Type "'.$type.'" is unknown or cannot be used'); + $valueGenerator->generate(); + } } diff --git a/test/Generic/Prototype/PrototypeClassFactoryTest.php b/test/Generic/Prototype/PrototypeClassFactoryTest.php index 19fb3039..90bc3e15 100644 --- a/test/Generic/Prototype/PrototypeClassFactoryTest.php +++ b/test/Generic/Prototype/PrototypeClassFactoryTest.php @@ -25,12 +25,12 @@ class PrototypeClassFactoryTest extends TestCase */ protected $prototypeFactory; - public function setUp() + protected function setUp() : void { $this->prototypeFactory = new PrototypeClassFactory(); } - public function tearDown() + protected function tearDown() : void { $this->prototypeFactory = null; } @@ -56,7 +56,7 @@ public function testSetNameOnGenericIsCalledOnce() $mockProto = $this->getMockBuilder(PrototypeGenericClass::class) ->setMethods(['setName']) ->getMock(); - $mockProto->expects($this->once())->method('setName')->will($this->returnValue('notexist')); + $mockProto->expects($this->once())->method('setName')->willReturn('notexist'); $this->prototypeFactory->setGenericPrototype($mockProto); $this->prototypeFactory->getClonedPrototype('notexist'); } diff --git a/test/Reflection/ClassReflectionTest.php b/test/Reflection/ClassReflectionTest.php index 0f084487..1964953b 100644 --- a/test/Reflection/ClassReflectionTest.php +++ b/test/Reflection/ClassReflectionTest.php @@ -153,7 +153,7 @@ public function testStartLine() public function testGetDeclaringFileReturnsFilename() { $reflectionClass = new ClassReflection(TestAsset\TestSampleClass2::class); - self::assertContains('TestSampleClass2.php', $reflectionClass->getDeclaringFile()->getFileName()); + self::assertStringContainsString('TestSampleClass2.php', $reflectionClass->getDeclaringFile()->getFileName()); } public function testGetAnnotationsWithNoNameInformations() @@ -172,9 +172,8 @@ public function testGetAnnotationsWithNoNameInformations() $reflectionClass->setFileScanner($fileScanner); - $fileScanner->expects($this->any()) - ->method('getClassNameInformation') - ->will($this->returnValue(false)); + $fileScanner->method('getClassNameInformation') + ->willReturn(false); self::assertFalse($reflectionClass->getAnnotations($annotationManager)); } @@ -203,13 +202,13 @@ public function testGetTraits() $reflectionClass = new ClassReflection(TestAsset\TestTraitClass4::class); $traitsArray = $reflectionClass->getTraits(); - self::assertInternalType('array', $traitsArray); + self::assertIsArray($traitsArray); self::assertCount(1, $traitsArray); self::assertInstanceOf(ClassReflection::class, $traitsArray[0]); $reflectionClass = new ClassReflection(TestAsset\TestSampleClass::class); $traitsArray = $reflectionClass->getTraits(); - self::assertInternalType('array', $traitsArray); + self::assertIsArray($traitsArray); self::assertCount(0, $traitsArray); } } diff --git a/test/Reflection/DocBlock/Tag/AuthorTagTest.php b/test/Reflection/DocBlock/Tag/AuthorTagTest.php index 4f60e6ed..35ede89f 100644 --- a/test/Reflection/DocBlock/Tag/AuthorTagTest.php +++ b/test/Reflection/DocBlock/Tag/AuthorTagTest.php @@ -23,7 +23,7 @@ class AuthorTagTest extends TestCase */ protected $tag; - public function setUp() + protected function setUp() : void { $this->tag = new AuthorTag(); } diff --git a/test/Reflection/DocBlock/Tag/LicenseTagTest.php b/test/Reflection/DocBlock/Tag/LicenseTagTest.php index de37b543..2cd93acb 100644 --- a/test/Reflection/DocBlock/Tag/LicenseTagTest.php +++ b/test/Reflection/DocBlock/Tag/LicenseTagTest.php @@ -23,7 +23,7 @@ class LicenseTagTest extends TestCase */ protected $tag; - public function setUp() + protected function setUp() : void { $this->tag = new LicenseTag(); } diff --git a/test/Reflection/FileReflectionTest.php b/test/Reflection/FileReflectionTest.php index 66907f1e..87ad4af5 100644 --- a/test/Reflection/FileReflectionTest.php +++ b/test/Reflection/FileReflectionTest.php @@ -194,7 +194,7 @@ public function testFileReflectionShouldNotRaiseNoticesWhenReflectingClosures() { require_once __DIR__ . '/TestAsset/issue-70.php'; $r = new FileReflection(__DIR__ . '/TestAsset/issue-70.php'); - self::assertContains('spl_autoload_register', $r->getContents()); - self::assertContains('function ()', $r->getContents()); + self::assertStringContainsString('spl_autoload_register', $r->getContents()); + self::assertStringContainsString('function ()', $r->getContents()); } } diff --git a/test/Reflection/MethodReflectionTest.php b/test/Reflection/MethodReflectionTest.php index 3b47032a..ddfb7834 100644 --- a/test/Reflection/MethodReflectionTest.php +++ b/test/Reflection/MethodReflectionTest.php @@ -312,9 +312,8 @@ public function testGetAnnotationsWithNoNameInformations() $reflectionMethod->setFileScanner($fileScanner); - $fileScanner->expects($this->any()) - ->method('getClassNameInformation') - ->will($this->returnValue(false)); + $fileScanner->method('getClassNameInformation') + ->willReturn(false); self::assertFalse($reflectionMethod->getAnnotations($annotationManager)); } diff --git a/test/Reflection/ParameterReflectionTest.php b/test/Reflection/ParameterReflectionTest.php index 064490a3..0aa59062 100644 --- a/test/Reflection/ParameterReflectionTest.php +++ b/test/Reflection/ParameterReflectionTest.php @@ -104,7 +104,7 @@ public function testGetType($className, $methodName, $parameterName, $expectedTy $type = $reflection->getType(); self::assertInstanceOf(\ReflectionType::class, $type); - self::assertSame($expectedType, (string) $type); + self::assertSame($expectedType, $type->getName()); } /** diff --git a/test/Reflection/PropertyReflectionTest.php b/test/Reflection/PropertyReflectionTest.php index 912b8477..707cf7f2 100644 --- a/test/Reflection/PropertyReflectionTest.php +++ b/test/Reflection/PropertyReflectionTest.php @@ -73,9 +73,8 @@ public function testGetAnnotationsWithNoNameInformations() $reflectionProperty->setFileScanner($fileScanner); - $fileScanner->expects($this->any()) - ->method('getClassNameInformation') - ->will($this->returnValue(false)); + $fileScanner->method('getClassNameInformation') + ->willReturn(false); self::assertFalse($reflectionProperty->getAnnotations($annotationManager)); } diff --git a/test/Scanner/CachingFileScannerTest.php b/test/Scanner/CachingFileScannerTest.php index 33abc9bc..701c6de0 100644 --- a/test/Scanner/CachingFileScannerTest.php +++ b/test/Scanner/CachingFileScannerTest.php @@ -18,7 +18,7 @@ class CachingFileScannerTest extends TestCase { - protected function setUp() + protected function setUp() : void { CachingFileScanner::clearCache(); } diff --git a/test/Scanner/ClassScannerTest.php b/test/Scanner/ClassScannerTest.php index bb255c0d..5d1876e9 100644 --- a/test/Scanner/ClassScannerTest.php +++ b/test/Scanner/ClassScannerTest.php @@ -38,7 +38,7 @@ class ClassScannerTest extends TestCase { protected $manager; - public function setUp() + protected function setUp() : void { $this->manager = new Annotation\AnnotationManager(); @@ -63,7 +63,7 @@ public function testClassScannerHasClassInformation() self::assertContains('A\B\C\D\Blarg', $interfaces); self::assertContains('ZendTest\Code\TestAsset\Local\SubClass', $interfaces); $methods = $class->getMethodNames(); - self::assertInternalType('array', $methods); + self::assertIsArray($methods); self::assertContains('fooBarBaz', $methods); } @@ -71,7 +71,7 @@ public function testClassScannerHasConstant() { $file = new FileScanner(__DIR__ . '/../TestAsset/FooClass.php'); $class = $file->getClass(FooClass::class); - self::assertInternalType('array', $class->getConstantNames()); + self::assertIsArray($class->getConstantNames()); self::assertContains('FOO', $class->getConstantNames()); } diff --git a/test/Scanner/MethodScannerTest.php b/test/Scanner/MethodScannerTest.php index 07c4ddab..0efba5b0 100644 --- a/test/Scanner/MethodScannerTest.php +++ b/test/Scanner/MethodScannerTest.php @@ -39,7 +39,7 @@ public function testMethodScannerReturnsParameters() $class = $file->getClass(BarClass::class); $method = $class->getMethod('three'); $parameters = $method->getParameters(); - self::assertInternalType('array', $parameters); + self::assertIsArray($parameters); } public function testMethodScannerReturnsParameterScanner() diff --git a/test/Scanner/TokenArrayScannerTest.php b/test/Scanner/TokenArrayScannerTest.php index d92a198d..f013b692 100644 --- a/test/Scanner/TokenArrayScannerTest.php +++ b/test/Scanner/TokenArrayScannerTest.php @@ -28,7 +28,7 @@ public function testScannerReturnsNamespaces() )); self::assertTrue($tokenScanner->hasNamespace('ZendTest\Code\TestAsset')); $namespaces = $tokenScanner->getNamespaces(); - self::assertInternalType('array', $namespaces); + self::assertIsArray($namespaces); self::assertContains('ZendTest\Code\TestAsset', $namespaces); } @@ -38,7 +38,7 @@ public function testScannerReturnsNamespacesInNotNamespacedClasses() file_get_contents(__DIR__ . '/../TestAsset/FooBarClass.php') )); $uses = $tokenScanner->getUses(); - self::assertInternalType('array', $uses); + self::assertIsArray($uses); $foundUses = []; foreach ($uses as $use) { $foundUses[] = $use['use']; @@ -52,7 +52,7 @@ public function testScannerReturnsClassNames() file_get_contents(__DIR__ . '/../TestAsset/FooClass.php') )); $classes = $tokenScanner->getClassNames(); - self::assertInternalType('array', $classes); + self::assertIsArray($classes); self::assertContains(FooClass::class, $classes); } @@ -65,7 +65,7 @@ public function testScannerReturnsClassNamesForTraits() file_get_contents(__DIR__ . '/../TestAsset/FooTrait.php') )); $classes = $tokenScanner->getClassNames(); - self::assertInternalType('array', $classes); + self::assertIsArray($classes); self::assertContains(FooTrait::class, $classes); } @@ -75,7 +75,7 @@ public function testScannerReturnsFunctions() file_get_contents(__DIR__ . '/../TestAsset/functions.php') )); $functions = $tokenScanner->getFunctionNames(); - self::assertInternalType('array', $functions); + self::assertIsArray($functions); self::assertContains('ZendTest\Code\TestAsset\foo_bar', $functions); } @@ -85,7 +85,7 @@ public function testScannerReturnsClassScanner() file_get_contents(__DIR__ . '/../TestAsset/FooClass.php') )); $classes = $tokenScanner->getClasses(); - self::assertInternalType('array', $classes); + self::assertIsArray($classes); foreach ($classes as $class) { self::assertInstanceOf(ClassScanner::class, $class); } diff --git a/test/TestAsset/BarClass.php b/test/TestAsset/BarClass.php index c56d8deb..92a17693 100644 --- a/test/TestAsset/BarClass.php +++ b/test/TestAsset/BarClass.php @@ -9,8 +9,8 @@ abstract class BarClass { - const BAR = 5; - const FOO = self::BAR; + public const BAR = 5; + public const FOO = self::BAR; protected static $bar = 'value'; diff --git a/test/TestAsset/FooClass.php b/test/TestAsset/FooClass.php index ae9ef826..723f5700 100644 --- a/test/TestAsset/FooClass.php +++ b/test/TestAsset/FooClass.php @@ -10,8 +10,8 @@ abstract class FooClass implements \ArrayAccess, E\Blarg, Local\SubClass { - const BAR = 5; - const FOO = self::BAR; + public const BAR = 5; + public const FOO = self::BAR; /** * Constant comment diff --git a/test/TestAsset/FooInterface.php b/test/TestAsset/FooInterface.php index 10f081b9..c9e52c31 100644 --- a/test/TestAsset/FooInterface.php +++ b/test/TestAsset/FooInterface.php @@ -11,8 +11,8 @@ interface FooInterface extends \ArrayAccess { - const BAR = 5; - const FOO = self::BAR; + public const BAR = 5; + public const FOO = self::BAR; public function fooBarBaz();