Skip to content

Commit

Permalink
Merge 5eb1d7b into 1a5a6cd
Browse files Browse the repository at this point in the history
  • Loading branch information
nbayramberdiyev committed Feb 21, 2022
2 parents 1a5a6cd + 5eb1d7b commit a85699a
Show file tree
Hide file tree
Showing 22 changed files with 71 additions and 190 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Expand Up @@ -27,7 +27,7 @@ jobs:
coverage: xdebug

- name: Install dependencies with Composer
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2

- name: Coding standards
if: matrix.analysis
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Expand Up @@ -2,21 +2,21 @@

## Pull Requests

1. Fork this repository
2. Create a new branch for each feature or improvement
3. Send a pull request from each feature branch to the **master** branch
1. Fork this repository.
2. Create a new branch for each feature or improvement.
3. Send a pull request from each feature branch to the **master** branch.

It is very important to separate new features or improvements into separate
feature branches, and to send a pull request for each branch. This allows me to
review and pull in new features or improvements individually.

## Style Guide

All pull requests must adhere to the [PSR-2 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md).
All pull requests must adhere to the [PSR-12 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md).

## Unit Testing

All pull requests must be accompanied by passing unit tests and complete code
coverage. The Slim Framework uses phpunit for testing.
coverage. The Slim Framework uses PHPUnit for testing.

[Learn about PHPUnit](https://github.com/sebastianbergmann/phpunit/)
[Learn about PHPUnit](https://github.com/sebastianbergmann/phpunit/).
22 changes: 4 additions & 18 deletions src/Factory/RequestFactory.php
Expand Up @@ -23,32 +23,18 @@

class RequestFactory implements RequestFactoryInterface
{
/**
* @var StreamFactoryInterface|StreamFactory
*/
protected $streamFactory;
protected StreamFactoryInterface $streamFactory;

/**
* @var UriFactoryInterface|UriFactory
*/
protected $uriFactory;
protected UriFactoryInterface $uriFactory;

/**
* @param StreamFactoryInterface|null $streamFactory
* @param UriFactoryInterface|null $uriFactory
*/
public function __construct(?StreamFactoryInterface $streamFactory = null, ?UriFactoryInterface $uriFactory = null)
{
if (!isset($streamFactory)) {
$streamFactory = new StreamFactory();
}

if (!isset($uriFactory)) {
$uriFactory = new UriFactory();
}

$this->streamFactory = $streamFactory;
$this->uriFactory = $uriFactory;
$this->streamFactory = $streamFactory ?? new StreamFactory();
$this->uriFactory = $uriFactory ?? new UriFactory();
}

/**
Expand Down
22 changes: 4 additions & 18 deletions src/Factory/ServerRequestFactory.php
Expand Up @@ -30,32 +30,18 @@

class ServerRequestFactory implements ServerRequestFactoryInterface
{
/**
* @var StreamFactoryInterface|StreamFactory
*/
protected $streamFactory;
protected StreamFactoryInterface $streamFactory;

/**
* @var UriFactoryInterface|UriFactory
*/
protected $uriFactory;
protected UriFactoryInterface $uriFactory;

/**
* @param StreamFactoryInterface|null $streamFactory
* @param UriFactoryInterface|null $uriFactory
*/
public function __construct(?StreamFactoryInterface $streamFactory = null, ?UriFactoryInterface $uriFactory = null)
{
if (!isset($streamFactory)) {
$streamFactory = new StreamFactory();
}

if (!isset($uriFactory)) {
$uriFactory = new UriFactory();
}

$this->streamFactory = $streamFactory;
$this->uriFactory = $uriFactory;
$this->streamFactory = $streamFactory ?? new StreamFactory();
$this->uriFactory = $uriFactory ?? new UriFactory();
}

/**
Expand Down
15 changes: 3 additions & 12 deletions src/Header.php
Expand Up @@ -18,20 +18,11 @@

class Header
{
/**
* @var string
*/
private $originalName;
private string $originalName;

/**
* @var string
*/
private $normalizedName;
private string $normalizedName;

/**
* @var array
*/
private $values;
private array $values;

/**
* Header constructor.
Expand Down
14 changes: 4 additions & 10 deletions src/Headers.php
Expand Up @@ -28,19 +28,13 @@

class Headers implements HeadersInterface
{
/**
* @var array
*/
protected $globals;
protected array $globals;

/**
* @var Header[]
*/
protected $headers;
protected array $headers;

/**
* @param array $headers
* @param array $globals
* @param array $headers
* @param array|null $globals
*/
final public function __construct(array $headers = [], ?array $globals = null)
{
Expand Down
21 changes: 4 additions & 17 deletions src/Request.php
Expand Up @@ -13,7 +13,6 @@
use InvalidArgumentException;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UploadedFileInterface;
use Psr\Http\Message\UriInterface;
use Slim\Psr7\Interfaces\HeadersInterface;

Expand Down Expand Up @@ -51,30 +50,18 @@ class Request extends Message implements ServerRequestInterface
*/
protected $queryParams;

/**
* @var array
*/
protected $cookies;
protected array $cookies;

/**
* @var array
*/
protected $serverParams;
protected array $serverParams;

/**
* @var array
*/
protected $attributes;
protected array $attributes;

/**
* @var null|array|object
*/
protected $parsedBody;

/**
* @var UploadedFileInterface[]
*/
protected $uploadedFiles;
protected array $uploadedFiles;

/**
* @param string $method The request method
Expand Down
16 changes: 5 additions & 11 deletions src/Stream.php
Expand Up @@ -48,10 +48,7 @@ class Stream implements StreamInterface
*/
protected $stream;

/**
* @var array|null
*/
protected $meta;
protected ?array $meta;

/**
* @var bool|null
Expand Down Expand Up @@ -80,18 +77,15 @@ class Stream implements StreamInterface

protected bool $finished = false;

/**
* @var StreamInterface | null
*/
protected $cache;
protected ?StreamInterface $cache;

/**
* @param resource $stream A PHP resource handle.
* @param StreamInterface $cache A stream to cache $stream (useful for non-seekable streams)
* @param resource $stream A PHP resource handle.
* @param ?StreamInterface $cache A stream to cache $stream (useful for non-seekable streams)
*
* @throws InvalidArgumentException If argument is not a resource.
*/
public function __construct($stream, StreamInterface $cache = null)
public function __construct($stream, ?StreamInterface $cache = null)
{
$this->attach($stream);

Expand Down
17 changes: 4 additions & 13 deletions src/UploadedFile.php
Expand Up @@ -34,29 +34,20 @@ class UploadedFile implements UploadedFileInterface
{
/**
* The client-provided full path to the file
*
* @var string
*/
protected $file;
protected string $file;

/**
* The client-provided file name.
*
* @var string|null
*/
protected $name;
protected ?string $name;

/**
* The client-provided media type of the file.
*
* @var string|null
*/
protected $type;
protected ?string $type;

/**
* @var int|null
*/
protected $size;
protected ?int $size;

/**
* A valid PHP UPLOAD_ERR_xxx code for the file upload.
Expand Down
25 changes: 11 additions & 14 deletions src/Uri.php
Expand Up @@ -47,10 +47,7 @@ class Uri implements UriInterface

protected string $host = '';

/**
* @var null|int
*/
protected $port;
protected ?int $port;

protected string $path = '';

Expand All @@ -65,14 +62,14 @@ class Uri implements UriInterface
protected string $fragment = '';

/**
* @param string $scheme Uri scheme.
* @param string $host Uri host.
* @param int $port Uri port number.
* @param string $path Uri path.
* @param string $query Uri query string.
* @param string $fragment Uri fragment.
* @param string $user Uri user.
* @param string $password Uri password.
* @param string $scheme Uri scheme.
* @param string $host Uri host.
* @param int|null $port Uri port number.
* @param string $path Uri path.
* @param string $query Uri query string.
* @param string $fragment Uri fragment.
* @param string $user Uri user.
* @param string $password Uri password.
*/
public function __construct(
string $scheme,
Expand Down Expand Up @@ -290,9 +287,9 @@ protected function hasStandardPort(): bool
/**
* Filter Uri port.
*
* @param null|int $port The Uri port number.
* @param int|null $port The Uri port number.
*
* @return null|int
* @return int|null
*
* @throws InvalidArgumentException If the port is invalid.
*/
Expand Down
6 changes: 3 additions & 3 deletions tests/Assets/HeaderStack.php
Expand Up @@ -56,7 +56,7 @@ public static function push(array $header)
*
* @return string[][]
*/
public static function stack()
public static function stack(): array
{
return self::$data;
}
Expand All @@ -68,7 +68,7 @@ public static function stack()
*
* @return bool
*/
public static function has($header)
public static function has($header): bool
{
foreach (self::$data as $item) {
if ($item['header'] === $header) {
Expand All @@ -84,7 +84,7 @@ public static function has($header)
*
* @param string $header
*/
public static function remove($header)
public static function remove($header): void
{
foreach (self::$data as $key => $item) {
if (false !== strpos($item['header'], "$header:")) {
Expand Down
2 changes: 1 addition & 1 deletion tests/BodyTest.php
Expand Up @@ -52,7 +52,7 @@ protected function tearDown(): void
*
* @return resource
*/
public function resourceFactory($mode = 'r+')
public function resourceFactory(string $mode = 'r+')
{
$stream = fopen('php://temp', $mode);
fwrite($stream, $this->text);
Expand Down
11 changes: 2 additions & 9 deletions tests/Factory/RequestFactoryTest.php
Expand Up @@ -19,19 +19,12 @@

class RequestFactoryTest extends RequestFactoryTestCase
{
/**
* @return RequestFactory
*/
protected function createRequestFactory()
protected function createRequestFactory(): RequestFactory
{
return new RequestFactory();
}

/**
* @param string $uri
* @return UriInterface
*/
protected function createUri($uri)
protected function createUri($uri): UriInterface
{
return (new UriFactory())->createUri($uri);
}
Expand Down

0 comments on commit a85699a

Please sign in to comment.