Skip to content

Commit 903f797

Browse files
Merge branch 'release/0.3.2'
2 parents d996026 + 7522ef0 commit 903f797

File tree

11 files changed

+109
-45
lines changed

11 files changed

+109
-45
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# CHANGELOG
22

3+
## v0.3.2 - [2023/07/19]
4+
5+
- Fixed issues with nullable objects and values
6+
- Added `setListener($listener)` method to Application
7+
8+
## v0.3.1 - [2023/07/18]
9+
10+
- Removed method.
11+
312
## v0.3.0 - [2023/07/17]
413

514
- Removed Application class

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55

66
_THIS PROJECT IN DEVELOPMENT. DON'T USE IT IN PRODUCTION_
77

8+
## Supported Versions
9+
10+
| Version | Supported |
11+
|---------|--------------------|
12+
| 0.3.x | :white_check_mark: |
13+
| < 0.3.1 | :x: |
14+
815
## Quick start
916

1017
### Pre-requirements
@@ -53,3 +60,9 @@ More information about changes you can see [here](CHANGELOG.md)
5360

5461
More info about contribution you can
5562
read [here](https://docs.github.com/en/get-started/quickstart/contributing-to-projects)
63+
64+
## Security Policy
65+
66+
If you find bugs and vulnerabilities, please contact [[email protected]](mailto:[email protected]).
67+
68+
More info [here](SECURITY.md)

SECURITY.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| ------- | ------------------ |
7+
| 0.3.x | :white_check_mark: |
8+
| < 0.3.1 | :x: |
9+
10+
## Vulnerability Report
11+
12+
Please report all package vulnerabilities as well as dependencies that may also compromise the safe use of this project to [email protected]. Each vulnerability will be treated as a priority for fixes.

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"authors": [
2323
{
2424
"name": "Pavel Zavadski",
25-
"email": "[email protected]"
25+
"email": "[email protected]",
26+
"homepage": "https://pavlusha.me/"
2627
}
2728
],
2829
"minimum-stability": "stable",

composer.lock

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Abstract/ApplicationAbstract.php

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,46 @@
55
use Pavlusha311245\UnitPhpSdk\Config\Application\ProcessManagement\ApplicationProcess;
66
use Pavlusha311245\UnitPhpSdk\Config\Application\ProcessManagement\ProcessIsolation;
77
use Pavlusha311245\UnitPhpSdk\Config\Application\ProcessManagement\RequestLimit;
8+
use Pavlusha311245\UnitPhpSdk\Config\Listener;
89
use Pavlusha311245\UnitPhpSdk\Enums\ApplicationTypeEnum;
910
use Pavlusha311245\UnitPhpSdk\Exceptions\UnitException;
1011
use Pavlusha311245\UnitPhpSdk\Interfaces\ApplicationInterface;
1112

1213
abstract class ApplicationAbstract implements ApplicationInterface
1314
{
15+
private ?Listener $_listener = null;
16+
1417
private string $_type;
1518

1619
/**
1720
* Environment variables to be passed to the app
1821
*
1922
* @var array
2023
*/
21-
private array $_environment;
24+
private array $_environment = [];
2225

2326
/**
2427
* Group name that runs the app process
2528
*
2629
* @var string
2730
*/
28-
protected string $_group;
31+
protected string $_group = '';
2932

3033
/**
3134
* Username that runs the app process
3235
*
3336
* @var string
3437
*/
35-
protected string $_user;
38+
protected string $_user = '';
3639

3740
/**
3841
* The app working directory.
3942
*
4043
* @var string
4144
*/
42-
private string $_working_directory;
45+
private string $_working_directory = '';
4346

44-
private string $_name;
47+
private string $_name = '';
4548

4649
/**
4750
* The file path to which Unit redirects the application's error stream output in --no-daemon mode.
@@ -60,13 +63,23 @@ abstract class ApplicationAbstract implements ApplicationInterface
6063
/**
6164
* Static number of app processes or object options
6265
*
63-
* @var ApplicationProcess|string
66+
* @var string|ApplicationProcess|null
6467
*/
65-
private ApplicationProcess|string $_processes;
68+
private string|null|ApplicationProcess $_processes = null;
6669

67-
private RequestLimit $_limits;
70+
/**
71+
* Control requests limits
72+
*
73+
* @var RequestLimit|null
74+
*/
75+
private ?RequestLimit $_limits = null;
6876

69-
private ProcessIsolation $_isolation;
77+
/**
78+
* You can use namespace and file system isolation for your apps if Unit’s underlying OS supports them
79+
*
80+
* @var ProcessIsolation|null
81+
*/
82+
private ?ProcessIsolation $_isolation = null;
7083

7184
public function __construct(array $data = null)
7285
{
@@ -121,7 +134,7 @@ public function setEnvironment(array $environment): void
121134
$this->_environment = $environment;
122135
}
123136

124-
public function getIsolation(): ProcessIsolation
137+
public function getIsolation(): ?ProcessIsolation
125138
{
126139
return $this->_isolation;
127140
}
@@ -131,7 +144,7 @@ public function setIsolation(ProcessIsolation $isolation): void
131144
$this->_isolation = $isolation;
132145
}
133146

134-
public function getProcesses(): ApplicationProcess|int
147+
public function getProcesses(): ApplicationProcess|int|null
135148
{
136149
return $this->_processes;
137150
}
@@ -141,7 +154,7 @@ public function setProcesses(ApplicationProcess|int $processes): void
141154
$this->_processes = $processes;
142155
}
143156

144-
public function getLimits(): RequestLimit
157+
public function getLimits(): ?RequestLimit
145158
{
146159
return $this->_limits;
147160
}
@@ -251,4 +264,20 @@ public function parseFromArray(array $data): void
251264
$this->setLimits(new RequestLimit($data['limits']));
252265
}
253266
}
267+
268+
/**
269+
* @param Listener $listener
270+
*/
271+
public function setListener(Listener $listener): void
272+
{
273+
$this->_listener = $listener;
274+
}
275+
276+
/**
277+
* @return Listener
278+
*/
279+
public function getListener(): ?Listener
280+
{
281+
return $this->_listener;
282+
}
254283
}

src/Config.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function __construct(array $data)
6969
$typePath = $listener->getPass()[0];
7070
$typePathName = $listener->getPass()[1];
7171

72-
// ($this->{"_{$typePath}"}[$typePathName])->setListener($listener);
72+
($this->{"_{$typePath}"}[$typePathName])->setListener($listener);
7373

7474
$this->_listeners[] = $listener;
7575
}
@@ -141,9 +141,9 @@ public function getRoutes(): array
141141
* @param $routeName
142142
* @return mixed
143143
*/
144-
public function getRoute($routeName)
144+
public function getRoute(string $routeName): Route|null
145145
{
146-
return $this->_routes[$routeName];
146+
return $this->_routes[$routeName] ?? null;
147147
}
148148

149149
/**

src/Config/Application/PhpApplication.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
class PhpApplication extends ApplicationAbstract
99
{
10-
private string $_root;
10+
private string $_root = '';
1111

12-
private string $_index;
12+
private string $_index = '';
1313

14-
private string $_script;
14+
private string $_script = '';
1515

1616
private $_options;
1717

src/Config/Routes/RouteAction.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,66 +11,64 @@ class RouteAction
1111
*
1212
* @var string
1313
*/
14-
private string $_pass;
14+
private string $_pass = '';
1515

1616
/**
1717
* Socket address of an HTTP server to where the request is proxied.
1818
*
1919
* @var string
2020
*/
21-
private string $_proxy;
21+
private string $_proxy = '';
2222

2323
/**
2424
* HTTP status code with a context-dependent redirect location.
2525
* Integer (000–999); defines the HTTP response status code to be returned.
2626
*
27-
* @var int
27+
* @var int|null
2828
*/
29-
private int $_return;
29+
private ?int $_return = null;
3030

3131
/**
3232
* String URI; used if the return value implies redirection.
3333
*
3434
* @var string
3535
*/
36-
private string $_location;
36+
private string $_location = '';
3737

3838
/**
3939
* Lists file paths that are tried until a file is found.
4040
*
4141
* @var array|string
4242
*/
43-
private array|string $_share;
43+
private array|string $_share = '';
4444

45-
private string $_index;
45+
private string $_index = '';
4646

47-
private array $_fallback;
47+
private array $_fallback = [];
4848

49-
private array $_types;
49+
private array $_types = [];
5050

51-
private string $_chroot;
51+
private string $_chroot = '';
5252

5353
protected bool $_follow_symlinks;
5454

5555
protected bool $_traverse_mounts;
5656

57-
private string $_rewrite;
57+
private string $_rewrite = '';
5858

5959
public function __construct($data = null)
6060
{
6161
if (!empty($data)) {
6262
$this->parseFromArray($data);
6363
}
64-
65-
// $this->_share = $data['share'] ?? null;
6664
}
6765

6866
/**
6967
* Receive return key
7068
*
71-
* @return mixed
69+
* @return int|null
7270
*/
73-
public function getReturn()
71+
public function getReturn(): ?int
7472
{
7573
return $this->_return;
7674
}

src/Interfaces/ApplicationInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ public function getUser(): string;
2525

2626
public function setUser(string $name): void;
2727

28-
public function getIsolation(): ProcessIsolation;
28+
public function getIsolation(): ?ProcessIsolation;
2929

3030
public function setIsolation(ProcessIsolation $isolation): void;
3131

32-
public function getLimits(): RequestLimit;
32+
public function getLimits(): ?RequestLimit;
3333

3434
public function setLimits(RequestLimit $requestLimit): void;
3535

36-
public function getProcesses(): ApplicationProcess|int;
36+
public function getProcesses(): ApplicationProcess|int|null;
3737

3838
public function setProcesses(ApplicationProcess|int $processes): void;
3939

src/Interfaces/ConfigInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Pavlusha311245\UnitPhpSdk\Abstract\ApplicationAbstract;
66
use Pavlusha311245\UnitPhpSdk\Config\Listener;
7+
use Pavlusha311245\UnitPhpSdk\Config\Route;
78

89
interface ConfigInterface
910
{
@@ -13,7 +14,7 @@ public function getListenerByPort(int $port): Listener|null;
1314

1415
public function getRoutes(): array;
1516

16-
public function getRoute($routeName);
17+
public function getRoute(string $routeName): Route|null;
1718

1819
public function getApplications(): array;
1920

0 commit comments

Comments
 (0)