Skip to content

Commit

Permalink
add explicit type declarations on class properties
Browse files Browse the repository at this point in the history
  • Loading branch information
deminy committed Dec 9, 2023
1 parent 2c15750 commit 1de2307
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 31 deletions.
6 changes: 3 additions & 3 deletions src/core/Coroutine/WaitGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

class WaitGroup
{
protected $chan;
protected Channel $chan;

protected $count = 0;
protected int $count = 0;

protected $waiting = false;
protected bool $waiting = false;

public function __construct(int $delta = 0)
{
Expand Down
6 changes: 1 addition & 5 deletions src/core/Database/RedisPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@
*/
class RedisPool extends ConnectionPool
{
/** @var RedisConfig */
protected $config;

public function __construct(RedisConfig $config, int $size = self::DEFAULT_SIZE)
public function __construct(protected RedisConfig $config, int $size = self::DEFAULT_SIZE)
{
$this->config = $config;
parent::__construct(function () {
$redis = new \Redis();
/* Compatible with different versions of Redis extension as much as possible */
Expand Down
2 changes: 1 addition & 1 deletion src/core/FastCGI/HttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class HttpRequest extends Request
{
protected $params = [
protected array $params = [
'REQUEST_SCHEME' => 'http',
'REQUEST_METHOD' => 'GET',
'DOCUMENT_ROOT' => '',
Expand Down
9 changes: 3 additions & 6 deletions src/core/FastCGI/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@

class Message
{
/** @var array */
protected $params = [];
protected array $params = [];

/** @var string */
protected $body = '';
protected string $body = '';

/** @var string */
protected $error = '';
protected string $error = '';

public function getParam(string $name): ?string
{
Expand Down
20 changes: 5 additions & 15 deletions src/core/FastCGI/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,28 @@ class Record implements \Stringable
{
/**
* Identifies the FastCGI protocol version.
*
* @var int
*/
protected $version = FastCGI::VERSION_1;
protected int $version = FastCGI::VERSION_1;

/**
* Identifies the FastCGI record type, i.e. the general function that the record performs.
*
* @var int
*/
protected $type = FastCGI::UNKNOWN_TYPE;
protected int $type = FastCGI::UNKNOWN_TYPE;

/**
* Identifies the FastCGI request to which the record belongs.
*
* @var int
*/
protected $requestId = FastCGI::DEFAULT_REQUEST_ID;
protected int $requestId = FastCGI::DEFAULT_REQUEST_ID;

/**
* Reserved byte for future proposes
*
* @var int
*/
protected $reserved = 0;
protected int $reserved = 0;

/**
* The number of bytes in the contentData component of the record.
*
* @var int
*/
private $contentLength = 0;
private int $contentLength = 0;

/**
* The number of bytes in the paddingData component of the record.
Expand Down
2 changes: 1 addition & 1 deletion src/core/FastCGI/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class Request extends Message implements \Stringable
{
protected $keepConn = false;
protected bool $keepConn = false;

public function __toString(): string
{
Expand Down

0 comments on commit 1de2307

Please sign in to comment.