From 1ec7c30266365a48658953ebc031261d1bafa219 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 1 Mar 2021 15:27:32 +0100 Subject: [PATCH 01/10] opened 4.0-dev --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 05027c7..83b4884 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ }, "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "4.0-dev" } } } From f4a41f8c7864edccfd9f043a9169233acdeca0fd Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 1 Mar 2021 15:47:26 +0100 Subject: [PATCH 02/10] requires PHP 8.0 --- .github/workflows/coding-style.yml | 4 ++-- .github/workflows/static-analysis.yml | 2 +- .github/workflows/tests.yml | 6 +++--- composer.json | 2 +- readme.md | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/coding-style.yml b/.github/workflows/coding-style.yml index 558ebe9..50d857d 100644 --- a/.github/workflows/coding-style.yml +++ b/.github/workflows/coding-style.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: - php-version: 7.2 + php-version: 8.0 coverage: none - run: composer create-project nette/code-checker temp/code-checker ^3 --no-progress @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.0 coverage: none - run: composer create-project nette/coding-standard temp/coding-standard ^3 --no-progress diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index b0692d7..f985b05 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.0 coverage: none - run: composer install --no-progress --prefer-dist diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 266902d..82b6f18 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1'] + php: ['8.0', '8.1'] fail-fast: false @@ -35,7 +35,7 @@ jobs: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: - php-version: 7.2 + php-version: 8.0 coverage: none - run: composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable @@ -49,7 +49,7 @@ jobs: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.0 coverage: none - run: composer install --no-progress --prefer-dist diff --git a/composer.json b/composer.json index 83b4884..10dcb74 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": ">=7.2 <8.2", + "php": ">=8.0 <8.2", "nette/di": "^3.0.5", "nette/utils": "^3.2.1" }, diff --git a/readme.md b/readme.md index 7a94165..303f5b4 100644 --- a/readme.md +++ b/readme.md @@ -27,4 +27,4 @@ The recommended way to install is via Composer: composer require nette/bootstrap ``` -It requires PHP version 7.2 and supports PHP up to 8.1. +It requires PHP version 8.0 and supports PHP up to 8.1. From 1aa7327ecd0fabdfa80dfec0232773affb57fbd7 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 1 Mar 2021 15:55:08 +0100 Subject: [PATCH 03/10] composer: updated dependencies --- composer.json | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 10dcb74..e83820e 100644 --- a/composer.json +++ b/composer.json @@ -16,27 +16,27 @@ ], "require": { "php": ">=8.0 <8.2", - "nette/di": "^3.0.5", - "nette/utils": "^3.2.1" + "nette/di": "^4.0", + "nette/utils": "^3.2.1 || ^4.0" }, "suggest": { "nette/robot-loader": "to use Configurator::createRobotLoader()", "tracy/tracy": "to use Configurator::enableTracy()" }, "require-dev": { - "nette/application": "^3.1", - "nette/caching": "^3.0", - "nette/database": "^3.0", - "nette/forms": "^3.0", - "nette/http": "^3.0", - "nette/mail": "^3.0", - "nette/robot-loader": "^3.0", - "nette/safe-stream": "^2.2", - "nette/security": "^3.0", - "nette/tester": "^2.0", - "latte/latte": "^2.8", - "tracy/tracy": "^2.6", - "phpstan/phpstan-nette": "^0.12" + "nette/application": "^4.0", + "nette/caching": "^4.0", + "nette/database": "^4.0", + "nette/forms": "^4.0", + "nette/http": "^4.0", + "nette/mail": "^4.0", + "nette/robot-loader": "^4.0", + "nette/safe-stream": "^3.0", + "nette/security": "^4.0", + "nette/tester": "^2.4", + "latte/latte": "^2.10", + "tracy/tracy": "^2.8", + "phpstan/phpstan-nette": "^1.0" }, "conflict": { "tracy/tracy": "<2.6" From 148a9fc51644c2158b0638faa0d825562de69f21 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 1 Mar 2021 17:52:14 +0100 Subject: [PATCH 04/10] coding style --- src/Bootstrap/Configurator.php | 4 ++-- tests/Bootstrap/Configurator.developmentContainer.phpt | 2 +- tests/Bootstrap/Configurator.minimalContainer.phpt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bootstrap/Configurator.php b/src/Bootstrap/Configurator.php index c3ff8da..ce91fdb 100644 --- a/src/Bootstrap/Configurator.php +++ b/src/Bootstrap/Configurator.php @@ -269,7 +269,7 @@ public function loadContainer(): string { $loader = new DI\ContainerLoader( $this->getCacheDirectory() . '/nette.configurator', - $this->staticParameters['debugMode'] + $this->staticParameters['debugMode'], ); return $loader->load( [$this, 'generateContainer'], @@ -279,7 +279,7 @@ public function loadContainer(): string $this->configs, PHP_VERSION_ID - PHP_RELEASE_VERSION, // minor PHP version class_exists(ClassLoader::class) ? filemtime((new \ReflectionClass(ClassLoader::class))->getFilename()) : null, // composer update - ] + ], ); } diff --git a/tests/Bootstrap/Configurator.developmentContainer.phpt b/tests/Bootstrap/Configurator.developmentContainer.phpt index bfe878e..0b0168d 100644 --- a/tests/Bootstrap/Configurator.developmentContainer.phpt +++ b/tests/Bootstrap/Configurator.developmentContainer.phpt @@ -51,7 +51,7 @@ Assert::type(Nette\Http\Session::class, $container->getService('session')); Assert::type(Nette\Security\User::class, $container->getService('user')); Assert::type( class_exists(Nette\Bridges\SecurityHttp\SessionStorage::class) ? Nette\Bridges\SecurityHttp\SessionStorage::class : Nette\Http\UserStorage::class, - $container->getService('nette.userStorage') + $container->getService('nette.userStorage'), ); Assert::type(Nette\Application\Application::class, $container->getService('application')); Assert::type(Nette\Routing\SimpleRouter::class, $container->getService('router')); diff --git a/tests/Bootstrap/Configurator.minimalContainer.phpt b/tests/Bootstrap/Configurator.minimalContainer.phpt index 1b328e2..86b7a77 100644 --- a/tests/Bootstrap/Configurator.minimalContainer.phpt +++ b/tests/Bootstrap/Configurator.minimalContainer.phpt @@ -41,7 +41,7 @@ Assert::type(Nette\Http\Session::class, $container->getService('session')); Assert::type(Nette\Security\User::class, $container->getService('user')); Assert::type( class_exists(Nette\Bridges\SecurityHttp\SessionStorage::class) ? Nette\Bridges\SecurityHttp\SessionStorage::class : Nette\Http\UserStorage::class, - $container->getService('nette.userStorage') + $container->getService('nette.userStorage'), ); Assert::type(Nette\Application\Application::class, $container->getService('application')); Assert::type(Nette\Routing\SimpleRouter::class, $container->getService('router')); From 9d49422766f014912f49f33106f7cc6c00dbe71b Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 2 Mar 2021 00:10:12 +0100 Subject: [PATCH 05/10] fixed test --- tests/Bootstrap/Configurator.inheritance2.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Bootstrap/Configurator.inheritance2.phpt b/tests/Bootstrap/Configurator.inheritance2.phpt index ab4008c..9d93275 100644 --- a/tests/Bootstrap/Configurator.inheritance2.phpt +++ b/tests/Bootstrap/Configurator.inheritance2.phpt @@ -31,5 +31,5 @@ services: $container = @$configurator->createContainer(); // @ triggers notice in nette/di < 2.4.6 Assert::type(MyApp::class, $container->getService('application')); -Assert::null($container->getService('application')->catchExceptions); +Assert::false($container->getService('application')->catchExceptions); Assert::same('Error', $container->getService('application')->errorPresenter); From 95ed9c7d17b51b0a5cf26dfcbc6e212e916e0566 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 1 Mar 2021 19:10:59 +0100 Subject: [PATCH 06/10] added property typehints --- src/Bootstrap/Configurator.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/Bootstrap/Configurator.php b/src/Bootstrap/Configurator.php index ce91fdb..d9e455b 100644 --- a/src/Bootstrap/Configurator.php +++ b/src/Bootstrap/Configurator.php @@ -26,10 +26,9 @@ class Configurator public const COOKIE_SECRET = 'nette-debug'; /** @var callable[] function (Configurator $sender, DI\Compiler $compiler); Occurs after the compiler is created */ - public $onCompile = []; + public iterable $onCompile = []; - /** @var array */ - public $defaultExtensions = [ + public array $defaultExtensions = [ 'application' => [Nette\Bridges\ApplicationDI\ApplicationExtension::class, ['%debugMode%', ['%appDir%'], '%tempDir%/cache/nette.application']], 'cache' => [Nette\Bridges\CacheDI\CacheExtension::class, ['%tempDir%']], 'constants' => Extensions\ConstantsExtension::class, @@ -51,7 +50,7 @@ class Configurator ]; /** @var string[] of classes which shouldn't be autowired */ - public $autowireExcludedClasses = [ + public array $autowireExcludedClasses = [ \ArrayAccess::class, \Countable::class, \IteratorAggregate::class, @@ -59,17 +58,14 @@ class Configurator \Traversable::class, ]; - /** @var array */ - protected $staticParameters; + protected array $staticParameters; - /** @var array */ - protected $dynamicParameters = []; + protected array $dynamicParameters = []; - /** @var array */ - protected $services = []; + protected array $services = []; - /** @var array of string|array */ - protected $configs = []; + /** @var array */ + protected array $configs = []; public function __construct() From 538bb859df2c707bb2fd146e8cf02b364a4a92e3 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 1 Mar 2021 19:52:21 +0100 Subject: [PATCH 07/10] added PHP 8 typehints --- src/Bootstrap/Configurator.php | 31 ++++++--------------- tests/Bootstrap/Configurator.debugMode.phpt | 6 ---- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/Bootstrap/Configurator.php b/src/Bootstrap/Configurator.php index d9e455b..1b2e3c6 100644 --- a/src/Bootstrap/Configurator.php +++ b/src/Bootstrap/Configurator.php @@ -76,15 +76,11 @@ public function __construct() /** * Set parameter %debugMode%. - * @param bool|string|array $value - * @return static */ - public function setDebugMode($value) + public function setDebugMode(bool|string|array $value): static { if (is_string($value) || is_array($value)) { $value = static::detectDebugMode($value); - } elseif (!is_bool($value)) { - throw new Nette\InvalidArgumentException(sprintf('Value must be either a string, array, or boolean, %s given.', gettype($value))); } $this->staticParameters['debugMode'] = $value; @@ -101,9 +97,8 @@ public function isDebugMode(): bool /** * Sets path to temporary directory. - * @return static */ - public function setTempDirectory(string $path) + public function setTempDirectory(string $path): static { $this->staticParameters['tempDir'] = $path; return $this; @@ -112,9 +107,8 @@ public function setTempDirectory(string $path) /** * Sets the default timezone. - * @return static */ - public function setTimeZone(string $timezone) + public function setTimeZone(string $timezone): static { date_default_timezone_set($timezone); @ini_set('date.timezone', $timezone); // @ - function may be disabled @@ -124,9 +118,8 @@ public function setTimeZone(string $timezone) /** * Alias for addStaticParameters() - * @return static */ - public function addParameters(array $params) + public function addParameters(array $params): static { return $this->addStaticParameters($params); } @@ -134,9 +127,8 @@ public function addParameters(array $params) /** * Adds new static parameters. - * @return static */ - public function addStaticParameters(array $params) + public function addStaticParameters(array $params): static { $this->staticParameters = DI\Config\Helpers::merge($params, $this->staticParameters); return $this; @@ -145,9 +137,8 @@ public function addStaticParameters(array $params) /** * Adds new dynamic parameters. - * @return static */ - public function addDynamicParameters(array $params) + public function addDynamicParameters(array $params): static { $this->dynamicParameters = $params + $this->dynamicParameters; return $this; @@ -156,9 +147,8 @@ public function addDynamicParameters(array $params) /** * Add instances of services. - * @return static */ - public function addServices(array $services) + public function addServices(array $services): static { $this->services = $services + $this->services; return $this; @@ -232,10 +222,8 @@ public function createRobotLoader(): Nette\Loaders\RobotLoader /** * Adds configuration file. - * @param string|array $config - * @return static */ - public function addConfig($config) + public function addConfig(string|array $config): static { $this->configs[] = $config; return $this; @@ -339,9 +327,8 @@ protected function getCacheDirectory(): string /** * Detects debug mode by IP addresses or computer names whitelist detection. - * @param string|array $list */ - public static function detectDebugMode($list = null): bool + public static function detectDebugMode(string|array $list = null): bool { $addr = $_SERVER['REMOTE_ADDR'] ?? php_uname('n'); $secret = is_string($_COOKIE[self::COOKIE_SECRET] ?? null) diff --git a/tests/Bootstrap/Configurator.debugMode.phpt b/tests/Bootstrap/Configurator.debugMode.phpt index 6be097a..f943176 100644 --- a/tests/Bootstrap/Configurator.debugMode.phpt +++ b/tests/Bootstrap/Configurator.debugMode.phpt @@ -32,12 +32,6 @@ test('', function () { }); -Assert::exception(function () { - $configurator = new Configurator; - $configurator->setDebugMode(1); -}, Nette\InvalidArgumentException::class); - - test('localhost', function () { unset($_SERVER['HTTP_X_FORWARDED_FOR']); From bc69069d19b922235c5c223dc318efb4fabbac7d Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 11 Mar 2021 21:51:56 +0100 Subject: [PATCH 08/10] removed community health files --- .github/ISSUE_TEMPLATE/Bug_report.md | 19 ------------- .github/ISSUE_TEMPLATE/Feature_request.md | 9 ------ .github/ISSUE_TEMPLATE/Support_question.md | 12 -------- .github/ISSUE_TEMPLATE/Support_us.md | 21 -------------- .github/funding.yml | 2 -- .github/pull_request_template.md | 11 -------- contributing.md | 33 ---------------------- 7 files changed, 107 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/Bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/Feature_request.md delete mode 100644 .github/ISSUE_TEMPLATE/Support_question.md delete mode 100644 .github/ISSUE_TEMPLATE/Support_us.md delete mode 100644 .github/funding.yml delete mode 100644 .github/pull_request_template.md delete mode 100644 contributing.md diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md deleted file mode 100644 index a4cd126..0000000 --- a/.github/ISSUE_TEMPLATE/Bug_report.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -name: "🐛 Bug Report" -about: "If something isn't working as expected 🤔" - ---- - -Version: ?.?.? - -### Bug Description -... A clear and concise description of what the bug is. A good bug report shouldn't leave others needing to chase you up for more information. - -### Steps To Reproduce -... If possible a minimal demo of the problem ... - -### Expected Behavior -... A clear and concise description of what you expected to happen. - -### Possible Solution -... Only if you have suggestions on a fix for the bug diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md deleted file mode 100644 index d2e2194..0000000 --- a/.github/ISSUE_TEMPLATE/Feature_request.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -name: "🚀 Feature Request" -about: "I have a suggestion (and may want to implement it) 🙂" - ---- - -- Is your feature request related to a problem? Please describe. -- Explain your intentions. -- It's up to you to make a strong case to convince the project's developers of the merits of this feature. diff --git a/.github/ISSUE_TEMPLATE/Support_question.md b/.github/ISSUE_TEMPLATE/Support_question.md deleted file mode 100644 index 75c48b6..0000000 --- a/.github/ISSUE_TEMPLATE/Support_question.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -name: "🤗 Support Question" -about: "If you have a question 💬, please check out our forum!" - ---- - ---------------^ Click "Preview" for a nicer view! -We primarily use GitHub as an issue tracker; for usage and support questions, please check out these resources below. Thanks! 😁. - -* Nette Forum: https://forum.nette.org -* Nette Gitter: https://gitter.im/nette/nette -* Slack (czech): https://pehapkari.slack.com/messages/C2R30BLKA diff --git a/.github/ISSUE_TEMPLATE/Support_us.md b/.github/ISSUE_TEMPLATE/Support_us.md deleted file mode 100644 index 92d8a4c..0000000 --- a/.github/ISSUE_TEMPLATE/Support_us.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -name: "❤️ Support us" -about: "If you would like to support our efforts in maintaining this project 🙌" - ---- - ---------------^ Click "Preview" for a nicer view! - -> https://nette.org/donate - -Help support Nette! - -We develop Nette Framework for more than 14 years. In order to make your life more comfortable. Nette cares about the safety of your sites. Nette saves you time. And gives job opportunities. - -Nette earns you money. And is absolutely free. - -To ensure future development and improving the documentation, we need your donation. - -Whether you are chief of IT company which benefits from Nette, or developer who goes for advice on our forum, if you like Nette, [please make a donation now](https://nette.org/donate). - -Thank you! diff --git a/.github/funding.yml b/.github/funding.yml deleted file mode 100644 index 25adc95..0000000 --- a/.github/funding.yml +++ /dev/null @@ -1,2 +0,0 @@ -github: dg -custom: "https://nette.org/donate" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index f8aa3f4..0000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,11 +0,0 @@ -- bug fix / new feature? -- BC break? yes/no -- doc PR: nette/docs#??? - - diff --git a/contributing.md b/contributing.md deleted file mode 100644 index 184152c..0000000 --- a/contributing.md +++ /dev/null @@ -1,33 +0,0 @@ -How to contribute & use the issue tracker -========================================= - -Nette welcomes your contributions. There are several ways to help out: - -* Create an issue on GitHub, if you have found a bug -* Write test cases for open bug issues -* Write fixes for open bug/feature issues, preferably with test cases included -* Contribute to the [documentation](https://nette.org/en/writing) - -Issues ------- - -Please **do not use the issue tracker to ask questions**. We will be happy to help you -on [Nette forum](https://forum.nette.org) or chat with us on [Gitter](https://gitter.im/nette/nette). - -A good bug report shouldn't leave others needing to chase you up for more -information. Please try to be as detailed as possible in your report. - -**Feature requests** are welcome. But take a moment to find out whether your idea -fits with the scope and aims of the project. It's up to *you* to make a strong -case to convince the project's developers of the merits of this feature. - -Contributing ------------- - -If you'd like to contribute, please take a moment to read [the contributing guide](https://nette.org/en/contributing). - -The best way to propose a feature is to discuss your ideas on [Nette forum](https://forum.nette.org) before implementing them. - -Please do not fix whitespace, format code, or make a purely cosmetic patch. - -Thanks! :heart: From c1ec2b5116b77ea6b57804a2c2c784ea0bcc6147 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 13 Jan 2022 11:59:21 +0100 Subject: [PATCH 09/10] Configurator: added getContainerKey() --- src/Bootstrap/Configurator.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Bootstrap/Configurator.php b/src/Bootstrap/Configurator.php index 1b2e3c6..f5a26ed 100644 --- a/src/Bootstrap/Configurator.php +++ b/src/Bootstrap/Configurator.php @@ -257,13 +257,7 @@ public function loadContainer(): string ); return $loader->load( [$this, 'generateContainer'], - [ - $this->staticParameters, - array_keys($this->dynamicParameters), - $this->configs, - PHP_VERSION_ID - PHP_RELEASE_VERSION, // minor PHP version - class_exists(ClassLoader::class) ? filemtime((new \ReflectionClass(ClassLoader::class))->getFilename()) : null, // composer update - ], + $this->getContainerKey(), ); } @@ -310,6 +304,20 @@ protected function createLoader(): DI\Config\Loader } + protected function getContainerKey(): array + { + return [ + $this->staticParameters, + array_keys($this->dynamicParameters), + $this->configs, + PHP_VERSION_ID - PHP_RELEASE_VERSION, // minor PHP version + class_exists(ClassLoader::class) // composer update + ? filemtime((new \ReflectionClass(ClassLoader::class))->getFilename()) + : null, + ]; + } + + protected function getCacheDirectory(): string { if (empty($this->staticParameters['tempDir'])) { From 5fa755ca0920749749eeb85634fa1d2768770df6 Mon Sep 17 00:00:00 2001 From: Daniel Kurowski Date: Tue, 29 Mar 2022 12:34:30 +0200 Subject: [PATCH 10/10] add static params stub --- src/Bootstrap/container.stub.neon | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/Bootstrap/container.stub.neon diff --git a/src/Bootstrap/container.stub.neon b/src/Bootstrap/container.stub.neon new file mode 100644 index 0000000..d0dd76d --- /dev/null +++ b/src/Bootstrap/container.stub.neon @@ -0,0 +1,13 @@ +# Stub file for IDE neon support +parameters: + + # Configurator parameters + # for real values, see Tracy bar or Nette\Bootstrap\Configurator + + appDir: # codebase – typically app/ + wwwDir: # public entrypoint – typically www/ + vendorDir: # dependencies – typically vendor/ + tempDir: # cache – typically temp/ + debugMode: # auto resolved from IP address (if not set manually) + productionMode: # opposite of debugMode + consoleMode: # run from CLI?