Skip to content

Commit

Permalink
Merge pull request #12 from lisachenko/feature/small-improvements
Browse files Browse the repository at this point in the history
[Feature] Add PhpStorm meta + make some constructor arguments required
  • Loading branch information
lisachenko committed Jan 12, 2021
2 parents a3af19b + 22a18a7 commit d33d013
Show file tree
Hide file tree
Showing 28 changed files with 65 additions and 76 deletions.
56 changes: 56 additions & 0 deletions .phpstorm.meta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/*
* Protocol FCGI library
*
* @copyright Copyright 2021. Lisachenko Alexander <lisachenko.it@gmail.com>
* This source file is subject to the license that is bundled
* with this source code in the file LICENSE.
*/

declare(strict_types=1);

namespace PHPSTORM_META;

expectedArguments(
\Lisachenko\Protocol\FCGI\Record\BeginRequest::__construct(),
0,
\Lisachenko\Protocol\FCGI::RESPONDER,
\Lisachenko\Protocol\FCGI::AUTHORIZER,
\Lisachenko\Protocol\FCGI::FILTER,
);

expectedArguments(
\Lisachenko\Protocol\FCGI\Record\BeginRequest::__construct(),
1,
\Lisachenko\Protocol\FCGI::KEEP_CONN,
);

expectedArguments(
\Lisachenko\Protocol\FCGI\Record\EndRequest::__construct(),
0,
\Lisachenko\Protocol\FCGI::KEEP_CONN,
\Lisachenko\Protocol\FCGI::REQUEST_COMPLETE,
\Lisachenko\Protocol\FCGI::CANT_MPX_CONN,
\Lisachenko\Protocol\FCGI::OVERLOADED,
\Lisachenko\Protocol\FCGI::UNKNOWN_ROLE
);

expectedReturnValues(
\Lisachenko\Protocol\FCGI\Record::getVersion(),
\Lisachenko\Protocol\FCGI::VERSION_1
);

expectedReturnValues(
\Lisachenko\Protocol\FCGI\Record::getType(),
\Lisachenko\Protocol\FCGI::BEGIN_REQUEST,
\Lisachenko\Protocol\FCGI::ABORT_REQUEST,
\Lisachenko\Protocol\FCGI::END_REQUEST,
\Lisachenko\Protocol\FCGI::PARAMS,
\Lisachenko\Protocol\FCGI::STDIN,
\Lisachenko\Protocol\FCGI::STDOUT,
\Lisachenko\Protocol\FCGI::STDERR,
\Lisachenko\Protocol\FCGI::DATA,
\Lisachenko\Protocol\FCGI::GET_VALUES,
\Lisachenko\Protocol\FCGI::GET_VALUES_RESULT,
\Lisachenko\Protocol\FCGI::UNKNOWN_TYPE,
);
2 changes: 0 additions & 2 deletions src/FCGI.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

/**
* FCGI constants.
*
* @author Alexander.Lisachenko
*/
class FCGI
{
Expand Down
2 changes: 0 additions & 2 deletions src/FCGI/FrameParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

/**
* Utility class to simplify parsing of FCGI protocol data.
*
* @author Alexander.Lisachenko
*/
class FrameParser
{
Expand Down
2 changes: 0 additions & 2 deletions src/FCGI/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

/**
* FCGI record.
*
* @author Alexander.Lisachenko
*/
class Record
{
Expand Down
4 changes: 1 addition & 3 deletions src/FCGI/Record/AbortRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

/**
* The Web server sends a FCGI_ABORT_REQUEST record to abort a request
*
* @author Alexander.Lisachenko
*/
class AbortRequest extends Record
{
public function __construct(int $requestId = 0)
public function __construct(int $requestId)
{
$this->type = FCGI::ABORT_REQUEST;
$this->setRequestId($requestId);
Expand Down
2 changes: 0 additions & 2 deletions src/FCGI/Record/BeginRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

/**
* The Web server sends a FCGI_BEGIN_REQUEST record to start a request.
*
* @author Alexander.Lisachenko
*/
class BeginRequest extends Record
{
Expand Down
4 changes: 1 addition & 3 deletions src/FCGI/Record/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
* Data binary stream
*
* FCGI_DATA is a second stream record type used to send additional data to the application.
*
* @author Alexander.Lisachenko
*/
class Data extends Record
{
public function __construct(string $contentData = '')
public function __construct(string $contentData)
{
$this->type = FCGI::DATA;
$this->setContentData($contentData);
Expand Down
2 changes: 0 additions & 2 deletions src/FCGI/Record/EndRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
/**
* The application sends a FCGI_END_REQUEST record to terminate a request, either because the application
* has processed the request or because the application has rejected the request.
*
* @author Alexander.Lisachenko
*/
class EndRequest extends Record
{
Expand Down
4 changes: 1 addition & 3 deletions src/FCGI/Record/GetValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
* FCGI_MAX_REQS: The maximum number of concurrent requests this application will accept, e.g. "1" or "50".
* FCGI_MPXS_CONNS: "0" if this application does not multiplex connections (i.e. handle concurrent requests
* over each connection), "1" otherwise.
*
* @author Alexander.Lisachenko
*/
class GetValues extends Params
{
Expand All @@ -44,7 +42,7 @@ class GetValues extends Params
*
* @phpstan-param list<string> $keys
*/
public function __construct(array $keys = [])
public function __construct(array $keys)
{
parent::__construct(array_fill_keys($keys, ''));
$this->type = FCGI::GET_VALUES;
Expand Down
4 changes: 1 addition & 3 deletions src/FCGI/Record/GetValuesResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
* FCGI_MAX_REQS: The maximum number of concurrent requests this application will accept, e.g. "1" or "50".
* FCGI_MPXS_CONNS: "0" if this application does not multiplex connections (i.e. handle concurrent requests
* over each connection), "1" otherwise.
*
* @author Alexander.Lisachenko
*/
class GetValuesResult extends Params
{
Expand All @@ -42,7 +40,7 @@ class GetValuesResult extends Params
*
* @phpstan-param array<string, string> $values
*/
public function __construct(array $values = [])
public function __construct(array $values)
{
parent::__construct($values);
$this->type = FCGI::GET_VALUES_RESULT;
Expand Down
4 changes: 1 addition & 3 deletions src/FCGI/Record/Params.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

/**
* Params request record
*
* @author Alexander.Lisachenko
*/
class Params extends Record
{
Expand All @@ -34,7 +32,7 @@ class Params extends Record
*
* @phpstan-param array<string, string> $values
*/
public function __construct(array $values = [])
public function __construct(array $values)
{
$this->type = FCGI::PARAMS;
$this->values = $values;
Expand Down
4 changes: 1 addition & 3 deletions src/FCGI/Record/Stderr.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
* Stderr binary stream
*
* FCGI_STDERR is a stream record for sending arbitrary data from the application to the Web server
*
* @author Alexander.Lisachenko
*/
class Stderr extends Record
{
public function __construct(string $contentData = '')
public function __construct(string $contentData)
{
$this->type = FCGI::STDERR;
$this->setContentData($contentData);
Expand Down
4 changes: 1 addition & 3 deletions src/FCGI/Record/Stdin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
* Stdin binary stream
*
* FCGI_STDIN is a stream record type used in sending arbitrary data from the Web server to the application
*
* @author Alexander.Lisachenko
*/
class Stdin extends Record
{
public function __construct(string $contentData = '')
public function __construct(string $contentData)
{
$this->type = FCGI::STDIN;
$this->setContentData($contentData);
Expand Down
4 changes: 1 addition & 3 deletions src/FCGI/Record/Stdout.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
* Stdout binary stream
*
* FCGI_STDOUT is a stream record for sending arbitrary data from the application to the Web server
*
* @author Alexander.Lisachenko
*/
class Stdout extends Record
{
public function __construct(string $contentData = '')
public function __construct(string $contentData)
{
$this->type = FCGI::STDOUT;
$this->setContentData($contentData);
Expand Down
4 changes: 1 addition & 3 deletions src/FCGI/Record/UnknownType.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
* To provide for this evolution, the protocol includes the FCGI_UNKNOWN_TYPE management record.
* When an application receives a management record whose type T it does not understand, the application responds
* with {FCGI_UNKNOWN_TYPE, 0, {T}}.
*
* @author Alexander.Lisachenko
*/
class UnknownType extends Record
{
Expand All @@ -36,7 +34,7 @@ class UnknownType extends Record
*/
protected string $reserved1;

public function __construct(int $type = 0, string $reserved = '')
public function __construct(int $type, string $reserved = '')
{
$this->type = FCGI::UNKNOWN_TYPE;
$this->type1 = $type;
Expand Down
3 changes: 0 additions & 3 deletions tests/FCGI/FrameParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
use Lisachenko\Protocol\FCGI\Record\BeginRequest;
use Lisachenko\Protocol\FCGI\Record\Params;

/**
* @author Alexander.Lisachenko
*/
class FrameParserTest extends TestCase
{
public function testHasFrame(): void
Expand Down
3 changes: 0 additions & 3 deletions tests/FCGI/Record/AbortRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PHPUnit\Framework\TestCase;
use Lisachenko\Protocol\FCGI;

/**
* @author Alexander.Lisachenko
*/
class AbortRequestTest extends TestCase
{
protected static string $rawMessage = '0102000100000000';
Expand Down
3 changes: 0 additions & 3 deletions tests/FCGI/Record/BeginRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PHPUnit\Framework\TestCase;
use Lisachenko\Protocol\FCGI;

/**
* @author Alexander.Lisachenko
*/
class BeginRequestTest extends TestCase
{
protected static string $rawMessage = '01010000000800000001010000000000';
Expand Down
3 changes: 0 additions & 3 deletions tests/FCGI/Record/DataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PHPUnit\Framework\TestCase;
use Lisachenko\Protocol\FCGI;

/**
* @author Alexander.Lisachenko
*/
class DataTest extends TestCase
{
protected static string $rawMessage = '01080000000404007465737400000000';
Expand Down
3 changes: 0 additions & 3 deletions tests/FCGI/Record/EndRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PHPUnit\Framework\TestCase;
use Lisachenko\Protocol\FCGI;

/**
* @author Alexander.Lisachenko
*/
class EndRequestTest extends TestCase
{
protected static string $rawMessage = '01030000000800000000006400000000';
Expand Down
3 changes: 0 additions & 3 deletions tests/FCGI/Record/GetValuesResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PHPUnit\Framework\TestCase;
use Lisachenko\Protocol\FCGI;

/**
* @author Alexander.Lisachenko
*/
class GetValuesResultTest extends TestCase
{
protected static string $rawMessage = '010a0000001206000f01464347495f4d5058535f434f4e4e5331000000000000';
Expand Down
3 changes: 0 additions & 3 deletions tests/FCGI/Record/GetValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PHPUnit\Framework\TestCase;
use Lisachenko\Protocol\FCGI;

/**
* @author Alexander.Lisachenko
*/
class GetValuesTest extends TestCase
{
protected static string $rawMessage = '01090000001107000f00464347495f4d5058535f434f4e4e5300000000000000';
Expand Down
3 changes: 0 additions & 3 deletions tests/FCGI/Record/ParamsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use Lisachenko\Protocol\FCGI;
use PHPUnit\Framework\TestCase;

/**
* @author Alexander.Lisachenko
*/
class ParamsTest extends TestCase
{
protected static string $rawMessage ='
Expand Down
3 changes: 0 additions & 3 deletions tests/FCGI/Record/StderrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PHPUnit\Framework\TestCase;
use Lisachenko\Protocol\FCGI;

/**
* @author Alexander.Lisachenko
*/
class StderrTest extends TestCase
{
protected static string $rawMessage = '01070000000404007465737400000000';
Expand Down
3 changes: 0 additions & 3 deletions tests/FCGI/Record/StdinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PHPUnit\Framework\TestCase;
use Lisachenko\Protocol\FCGI;

/**
* @author Alexander.Lisachenko
*/
class StdinTest extends TestCase
{
protected static string $rawMessage = '01050000000404007465737400000000';
Expand Down
3 changes: 0 additions & 3 deletions tests/FCGI/Record/StdoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PHPUnit\Framework\TestCase;
use Lisachenko\Protocol\FCGI;

/**
* @author Alexander.Lisachenko
*/
class StdoutTest extends TestCase
{
protected static string $rawMessage = '01060000000404007465737400000000';
Expand Down
3 changes: 0 additions & 3 deletions tests/FCGI/Record/UnknownTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PHPUnit\Framework\TestCase;
use Lisachenko\Protocol\FCGI;

/**
* @author Alexander.Lisachenko
*/
class UnknownTypeTest extends TestCase
{
protected static string $rawMessage = '010b0000000800002a57544621000000';
Expand Down
3 changes: 0 additions & 3 deletions tests/FCGI/RecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PHPUnit\Framework\TestCase;
use Lisachenko\Protocol\FCGI;

/**
* @author Alexander.Lisachenko
*/
class RecordTest extends TestCase
{
// from the wireshark captured traffic
Expand Down

0 comments on commit d33d013

Please sign in to comment.