Skip to content

Commit

Permalink
fix psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed May 10, 2024
1 parent 206e133 commit de7fd38
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/FilterCollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
* @author Christoph Kappestein <christoph.kappestein@gmail.com>
* @license http://www.apache.org/licenses/LICENSE-2.0
* @link https://phpsx.org
*
* @extends \IteratorAggregate<FilterInterface>
*/
interface FilterCollectionInterface extends \IteratorAggregate
{
Expand Down
12 changes: 8 additions & 4 deletions src/Server/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
class RequestFactory implements RequestFactoryInterface
{
private ?string $baseUri;

/**
* @var array<string, string>
*/
private array $server;

public function __construct(?string $baseUri = null, ?array $server = null)
Expand Down Expand Up @@ -137,11 +141,11 @@ protected function getRequestMethod(): string
*/
protected function getRequestHeaders(): array
{
$contentKeys = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true);
$headers = array();
$contentKeys = ['CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true];
$headers = [];

foreach ($this->server as $key => $value) {
if (strpos($key, 'HTTP_') === 0) {
if (str_starts_with($key, 'HTTP_')) {
$headers[str_replace('_', '-', substr($key, 5))] = $value;
} elseif (isset($contentKeys[$key])) {
$headers[str_replace('_', '-', $key)] = $value;
Expand All @@ -152,7 +156,7 @@ protected function getRequestHeaders(): array
if (isset($this->server['REDIRECT_HTTP_AUTHORIZATION'])) {
$headers['AUTHORIZATION'] = $this->server['REDIRECT_HTTP_AUTHORIZATION'];
} elseif (isset($this->server['PHP_AUTH_USER'])) {
$headers['AUTHORIZATION'] = 'Basic ' . base64_encode($this->server['PHP_AUTH_USER'] . ':' . (isset($this->server['PHP_AUTH_PW']) ? $this->server['PHP_AUTH_PW'] : ''));
$headers['AUTHORIZATION'] = 'Basic ' . base64_encode($this->server['PHP_AUTH_USER'] . ':' . ($this->server['PHP_AUTH_PW'] ?? ''));
} elseif (isset($this->server['PHP_AUTH_DIGEST'])) {
$headers['AUTHORIZATION'] = $this->server['PHP_AUTH_DIGEST'];
}
Expand Down
2 changes: 2 additions & 0 deletions src/Stream/MultipartStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
* @author Christoph Kappestein <christoph.kappestein@gmail.com>
* @license http://www.apache.org/licenses/LICENSE-2.0
* @link https://phpsx.org
*
* @implements \IteratorAggregate<FileStream|string>
*/
class MultipartStream extends StringStream implements \Countable, \IteratorAggregate
{
Expand Down

0 comments on commit de7fd38

Please sign in to comment.