Skip to content

Commit

Permalink
[application] SnippetNode, SnippetAreaNode: name can be class constant [
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Oct 2, 2023
1 parent 191789b commit 1917989
Show file tree
Hide file tree
Showing 163 changed files with 4,337 additions and 1,807 deletions.
19 changes: 19 additions & 0 deletions application/.github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
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
9 changes: 9 additions & 0 deletions application/.github/ISSUE_TEMPLATE/Feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
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.
12 changes: 12 additions & 0 deletions application/.github/ISSUE_TEMPLATE/Support_question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
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
21 changes: 21 additions & 0 deletions application/.github/ISSUE_TEMPLATE/Support_us.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
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!
2 changes: 2 additions & 0 deletions application/.github/funding.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: dg
custom: "https://nette.org/donate"
11 changes: 11 additions & 0 deletions application/.github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- bug fix / new feature? <!-- #issue numbers, if any -->
- BC break? yes/no
- doc PR: nette/docs#??? <!-- highly welcome, see https://nette.org/en/writing -->

<!--
Describe your changes here to communicate to the maintainers why we should accept this pull request.
Please add new tests to show the fix or feature works. And take a moment to read the contributing guide https://nette.org/en/contributing
Thanks for contributing to Nette!
-->
2 changes: 1 addition & 1 deletion application/.github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 7.4
coverage: none

- run: composer install --no-progress --prefer-dist
Expand Down
4 changes: 2 additions & 2 deletions application/.github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.0', '8.1', '8.2', '8.3']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']

fail-fast: false

Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 7.2
coverage: none

- run: composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable
Expand Down
75 changes: 39 additions & 36 deletions application/.phpstorm.meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,48 @@

namespace PHPSTORM_META;

expectedArguments(\Nette\Application\Routers\Route::__construct(), 2, \Nette\Routing\Router::ONE_WAY);
expectedArguments(\Nette\Application\Routers\SimpleRouter::__construct(), 1, \Nette\Routing\Router::ONE_WAY);

registerArgumentsSet('nette_http_codes_3xx',
\Nette\Http\IResponse::S300_MultipleChoices,
\Nette\Http\IResponse::S301_MovedPermanently,
\Nette\Http\IResponse::S302_Found,
\Nette\Http\IResponse::S303_SeeOther,
\Nette\Http\IResponse::S303_PostGet,
\Nette\Http\IResponse::S304_NotModified,
\Nette\Http\IResponse::S305_UseProxy,
\Nette\Http\IResponse::S307_TemporaryRedirect,
\Nette\Http\IResponse::S308_PermanentRedirect,
\Nette\Http\IResponse::S300_MULTIPLE_CHOICES,
\Nette\Http\IResponse::S301_MOVED_PERMANENTLY,
\Nette\Http\IResponse::S302_FOUND,
\Nette\Http\IResponse::S303_SEE_OTHER,
\Nette\Http\IResponse::S303_POST_GET,
\Nette\Http\IResponse::S304_NOT_MODIFIED,
\Nette\Http\IResponse::S305_USE_PROXY,
\Nette\Http\IResponse::S307_TEMPORARY_REDIRECT,
\Nette\Http\IResponse::S308_PERMANENT_REDIRECT
);
registerArgumentsSet('nette_http_codes_4xx',
\Nette\Http\IResponse::S400_BadRequest,
\Nette\Http\IResponse::S401_Unauthorized,
\Nette\Http\IResponse::S402_PaymentRequired,
\Nette\Http\IResponse::S403_Forbidden,
\Nette\Http\IResponse::S404_NotFound,
\Nette\Http\IResponse::S405_MethodNotAllowed,
\Nette\Http\IResponse::S406_NotAcceptable,
\Nette\Http\IResponse::S407_ProxyAuthenticationRequired,
\Nette\Http\IResponse::S408_RequestTimeout,
\Nette\Http\IResponse::S409_Conflict,
\Nette\Http\IResponse::S410_Gone,
\Nette\Http\IResponse::S411_LengthRequired,
\Nette\Http\IResponse::S412_PreconditionFailed,
\Nette\Http\IResponse::S413_RequestEntityTooLarge,
\Nette\Http\IResponse::S414_RequestUriTooLong,
\Nette\Http\IResponse::S415_UnsupportedMediaType,
\Nette\Http\IResponse::S416_RequestedRangeNotSatisfiable,
\Nette\Http\IResponse::S417_ExpectationFailed,
\Nette\Http\IResponse::S421_MisdirectedRequest,
\Nette\Http\IResponse::S422_UnprocessableEntity,
\Nette\Http\IResponse::S423_Locked,
\Nette\Http\IResponse::S424_FailedDependency,
\Nette\Http\IResponse::S426_UpgradeRequired,
\Nette\Http\IResponse::S428_PreconditionRequired,
\Nette\Http\IResponse::S429_TooManyRequests,
\Nette\Http\IResponse::S431_RequestHeaderFieldsTooLarge,
\Nette\Http\IResponse::S451_UnavailableForLegalReasons,
\Nette\Http\IResponse::S400_BAD_REQUEST,
\Nette\Http\IResponse::S401_UNAUTHORIZED,
\Nette\Http\IResponse::S402_PAYMENT_REQUIRED,
\Nette\Http\IResponse::S403_FORBIDDEN,
\Nette\Http\IResponse::S404_NOT_FOUND,
\Nette\Http\IResponse::S405_METHOD_NOT_ALLOWED,
\Nette\Http\IResponse::S406_NOT_ACCEPTABLE,
\Nette\Http\IResponse::S407_PROXY_AUTHENTICATION_REQUIRED,
\Nette\Http\IResponse::S408_REQUEST_TIMEOUT,
\Nette\Http\IResponse::S409_CONFLICT,
\Nette\Http\IResponse::S410_GONE,
\Nette\Http\IResponse::S411_LENGTH_REQUIRED,
\Nette\Http\IResponse::S412_PRECONDITION_FAILED,
\Nette\Http\IResponse::S413_REQUEST_ENTITY_TOO_LARGE,
\Nette\Http\IResponse::S414_REQUEST_URI_TOO_LONG,
\Nette\Http\IResponse::S415_UNSUPPORTED_MEDIA_TYPE,
\Nette\Http\IResponse::S416_REQUESTED_RANGE_NOT_SATISFIABLE,
\Nette\Http\IResponse::S417_EXPECTATION_FAILED,
\Nette\Http\IResponse::S421_MISDIRECTED_REQUEST,
\Nette\Http\IResponse::S422_UNPROCESSABLE_ENTITY,
\Nette\Http\IResponse::S423_LOCKED,
\Nette\Http\IResponse::S424_FAILED_DEPENDENCY,
\Nette\Http\IResponse::S426_UPGRADE_REQUIRED,
\Nette\Http\IResponse::S428_PRECONDITION_REQUIRED,
\Nette\Http\IResponse::S429_TOO_MANY_REQUESTS,
\Nette\Http\IResponse::S431_REQUEST_HEADER_FIELDS_TOO_LARGE,
\Nette\Http\IResponse::S451_UNAVAILABLE_FOR_LEGAL_REASONS
);

expectedArguments(\Nette\Application\UI\Presenter::redirectUrl(), 1, argumentsSet('nette_http_codes_3xx'));
Expand Down
31 changes: 16 additions & 15 deletions application/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,34 @@
}
],
"require": {
"php": "8.0 - 8.3",
"nette/component-model": "^4.0",
"nette/http": "^4.0",
"nette/routing": "^4.0",
"nette/utils": "^4.0"
"php": ">=7.2",
"nette/component-model": "^3.0",
"nette/http": "^3.0.2",
"nette/routing": "^3.0.2",
"nette/utils": "^3.2.1 || ~4.0.0"
},
"suggest": {
"nette/forms": "Allows to use Nette\\Application\\UI\\Form",
"latte/latte": "Allows using Latte in templates"
},
"require-dev": {
"nette/tester": "^2.4",
"nette/di": "^3.1 || ^4.0",
"nette/forms": "^4.0",
"nette/robot-loader": "^3.2 || ^4.0",
"nette/security": "^4.0",
"latte/latte": "^3.0.8",
"tracy/tracy": "^2.8",
"mockery/mockery": "^1.4",
"phpstan/phpstan-nette": "^1.0",
"nette/tester": "^2.3.1",
"nette/di": "^v3.0",
"nette/forms": "^3.0",
"nette/robot-loader": "^3.2",
"nette/security": "^3.0",
"latte/latte": "^2.10.2 || ^3.0.3",
"tracy/tracy": "^2.6",
"mockery/mockery": "^1.0",
"phpstan/phpstan-nette": "^0.12",
"jetbrains/phpstorm-attributes": "dev-master"
},
"conflict": {
"nette/caching": "<3.1",
"nette/di": "<3.0.7",
"nette/forms": "<3.0",
"nette/schema": "<1.2",
"latte/latte": "<2.7.1 || >=3.0.0 <3.0.8 || >=3.1",
"tracy/tracy": "<2.5"
},
"autoload": {
Expand All @@ -54,7 +55,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
"dev-master": "3.1-dev"
}
}
}
33 changes: 33 additions & 0 deletions application/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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:
9 changes: 9 additions & 0 deletions application/ncs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<ruleset name="Custom" namespace="Nette">
<rule ref="$presets/php72.xml"/>

<rule ref="Squiz.Commenting.FunctionComment.ExtraParamComment">
<exclude-pattern>./src/Application/UI/Control.php</exclude-pattern>
<exclude-pattern>./src/Application/UI/Presenter.php</exclude-pattern>
</rule>
</ruleset>
54 changes: 35 additions & 19 deletions application/src/Application/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,59 @@
*/
class Application
{
public int $maxLoop = 20;
use Nette\SmartObject;

/** enable fault barrier? */
public bool $catchExceptions = false;
public ?string $errorPresenter = null;
/** @var int */
public $maxLoop = 20;

/** @var bool enable fault barrier? */
public $catchExceptions;

/** @var string|null */
public $errorPresenter;

/** @var array<callable(self): void> Occurs before the application loads presenter */
public array $onStartup = [];
public $onStartup = [];

/** @var array<callable(self, ?\Throwable): void> Occurs before the application shuts down */
public array $onShutdown = [];
public $onShutdown = [];

/** @var array<callable(self, Request): void> Occurs when a new request is received */
public array $onRequest = [];
public $onRequest = [];

/** @var array<callable(self, IPresenter): void> Occurs when a presenter is created */
public array $onPresenter = [];
public $onPresenter = [];

/** @var array<callable(self, Response): void> Occurs when a new response is ready for dispatch */
public array $onResponse = [];
public $onResponse = [];

/** @var array<callable(self, \Throwable): void> Occurs when an unhandled exception occurs in the application */
public array $onError = [];
public $onError = [];

/** @var Request[] */
private array $requests = [];
private ?IPresenter $presenter = null;
private Nette\Http\IRequest $httpRequest;
private Nette\Http\IResponse $httpResponse;
private IPresenterFactory $presenterFactory;
private Router $router;
private $requests = [];

/** @var IPresenter|null */
private $presenter;

/** @var Nette\Http\IRequest */
private $httpRequest;

/** @var Nette\Http\IResponse */
private $httpResponse;

/** @var IPresenterFactory */
private $presenterFactory;

/** @var Router */
private $router;


public function __construct(
IPresenterFactory $presenterFactory,
Router $router,
Nette\Http\IRequest $httpRequest,
Nette\Http\IResponse $httpResponse,
Nette\Http\IResponse $httpResponse
) {
$this->httpRequest = $httpRequest;
$this->httpResponse = $httpResponse;
Expand Down Expand Up @@ -103,7 +118,7 @@ public function createInitialRequest(): Request
throw new BadRequestException('No route for HTTP request.');
} elseif (!is_string($presenter)) {
throw new Nette\InvalidStateException('Missing presenter in route definition.');
} elseif (str_starts_with($presenter, 'Nette:') && $presenter !== 'Nette:Micro') {
} elseif (Nette\Utils\Strings::startsWith($presenter, 'Nette:') && $presenter !== 'Nette:Micro') {
throw new BadRequestException('Invalid request. Presenter is not achievable.');
}

Expand All @@ -114,6 +129,7 @@ public function createInitialRequest(): Request
$params,
$this->httpRequest->getPost(),
$this->httpRequest->getFiles(),
[Request::SECURED => $this->httpRequest->isSecured()]
);
}

Expand Down Expand Up @@ -166,7 +182,7 @@ public function processException(\Throwable $e): void
$this->httpResponse->setCode($e instanceof BadRequestException ? ($e->getHttpCode() ?: 404) : 500);
}

$args = ['exception' => $e, 'previousPresenter' => $this->presenter, 'request' => Arrays::last($this->requests) ?: null];
$args = ['exception' => $e, 'request' => Arrays::last($this->requests) ?: null];
if ($this->presenter instanceof UI\Presenter) {
try {
$this->presenter->forward(":$this->errorPresenter:", $args);
Expand Down
Loading

0 comments on commit 1917989

Please sign in to comment.