File tree Expand file tree Collapse file tree 7 files changed +25
-55
lines changed
Expand file tree Collapse file tree 7 files changed +25
-55
lines changed Original file line number Diff line number Diff line change @@ -48,22 +48,14 @@ class Application
4848 /** @var Request[] */
4949 private array $ requests = [];
5050 private ?IPresenter $ presenter = null ;
51- private Nette \Http \IRequest $ httpRequest ;
52- private Nette \Http \IResponse $ httpResponse ;
53- private IPresenterFactory $ presenterFactory ;
54- private Router $ router ;
5551
5652
5753 public function __construct (
58- IPresenterFactory $ presenterFactory ,
59- Router $ router ,
60- Nette \Http \IRequest $ httpRequest ,
61- Nette \Http \IResponse $ httpResponse ,
54+ private readonly IPresenterFactory $ presenterFactory ,
55+ private readonly Router $ router ,
56+ private readonly Nette \Http \IRequest $ httpRequest ,
57+ private readonly Nette \Http \IResponse $ httpResponse ,
6258 ) {
63- $ this ->httpRequest = $ httpRequest ;
64- $ this ->httpResponse = $ httpResponse ;
65- $ this ->presenterFactory = $ presenterFactory ;
66- $ this ->router = $ router ;
6759 }
6860
6961
Original file line number Diff line number Diff line change 1919final class FileResponse implements Nette \Application \Response
2020{
2121 public bool $ resuming = true ;
22- private string $ file ;
23- private string $ contentType ;
24- private string $ name ;
25- private bool $ forceDownload ;
22+ private readonly string $ name ;
2623
2724
2825 public function __construct (
29- string $ file ,
26+ private readonly string $ file ,
3027 ?string $ name = null ,
31- ? string $ contentType = null ,
32- bool $ forceDownload = true ,
28+ private readonly string $ contentType = ' application/octet-stream ' ,
29+ private readonly bool $ forceDownload = true ,
3330 ) {
3431 if (!is_file ($ file ) || !is_readable ($ file )) {
3532 throw new Nette \Application \BadRequestException ("File ' $ file' doesn't exist or is not readable. " );
3633 }
3734
38- $ this ->file = $ file ;
3935 $ this ->name = $ name ?? basename ($ file );
40- $ this ->contentType = $ contentType ?? 'application/octet-stream ' ;
41- $ this ->forceDownload = $ forceDownload ;
4236 }
4337
4438
Original file line number Diff line number Diff line change 1717 */
1818final class ForwardResponse implements Nette \Application \Response
1919{
20- private Nette \Application \Request $ request ;
21-
22-
23- public function __construct (Nette \Application \Request $ request )
24- {
25- $ this ->request = $ request ;
20+ public function __construct (
21+ private readonly Nette \Application \Request $ request ,
22+ ) {
2623 }
2724
2825
Original file line number Diff line number Diff line change 1717 */
1818final class JsonResponse implements Nette \Application \Response
1919{
20- private mixed $ payload ;
21- private string $ contentType ;
22-
23-
24- public function __construct (mixed $ payload , ?string $ contentType = null )
25- {
26- $ this ->payload = $ payload ;
27- $ this ->contentType = $ contentType ?? 'application/json ' ;
20+ public function __construct (
21+ private readonly mixed $ payload ,
22+ private readonly string $ contentType = 'application/json ' ,
23+ ) {
2824 }
2925
3026
Original file line number Diff line number Diff line change 1818 */
1919final class RedirectResponse implements Nette \Application \Response
2020{
21- private string $ url ;
22- private int $ httpCode ;
23-
24-
25- public function __construct (string $ url , int $ httpCode = Http \IResponse::S302_Found)
26- {
27- $ this ->url = $ url ;
28- $ this ->httpCode = $ httpCode ;
21+ public function __construct (
22+ private readonly string $ url ,
23+ private readonly int $ httpCode = Http \IResponse::S302_Found,
24+ ) {
2925 }
3026
3127
Original file line number Diff line number Diff line change 1717 */
1818final class TextResponse implements Nette \Application \Response
1919{
20- private mixed $ source ;
21-
22-
23- public function __construct (mixed $ source )
24- {
25- $ this ->source = $ source ;
20+ public function __construct (
21+ private readonly mixed $ source ,
22+ ) {
2623 }
2724
2825
Original file line number Diff line number Diff line change @@ -20,12 +20,10 @@ final class CliRouter implements Nette\Routing\Router
2020{
2121 private const PresenterKey = 'action ' ;
2222
23- private array $ defaults ;
2423
25-
26- public function __construct (array $ defaults = [])
27- {
28- $ this ->defaults = $ defaults ;
24+ public function __construct (
25+ private readonly array $ defaults = [],
26+ ) {
2927 }
3028
3129
You can’t perform that action at this time.
0 commit comments