Skip to content

Commit

Permalink
Regression - FileStreamWrapper for PHP <= 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
bkdotcom committed Jan 15, 2024
1 parent 82cdb65 commit aef0d77
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/Debug/Utility/FileStreamWrapperBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ class FileStreamWrapperBase

public static $filesTransformed = array();

/** @var Manager */
protected static $eventManager;

protected static $isRegistered = false;

/** @var string[] */
protected static $protocols = array('file', 'phar');

/** @var Manager */
private static $eventManager;

/** @var array paths to exclude from adding tick declaration */
private static $pathsExclude = array();
protected static $pathsExclude = array();

/**
* Register this stream wrapper
Expand Down
5 changes: 3 additions & 2 deletions src/ErrorHandler/AbstractError.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ public static function typeStr($type)
*/
private function assertValues($values)
{
$values = \array_merge($this->values, $values);
$keysMustHave = array('type', 'message', 'file', 'line');
$keys = \array_keys(\array_filter($values));
$values = \array_merge($this->values, $values);
$valuesCheck = \array_intersect_key($values, \array_flip($keysMustHave));
$keys = \array_keys(\array_filter($valuesCheck, 'strlen'));
if (\array_intersect($keysMustHave, $keys) !== $keysMustHave) {
throw new InvalidArgumentException('Error values must include: type, message, file, & line');
}
Expand Down
4 changes: 2 additions & 2 deletions src/HttpMessage/ServerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public static function fromGlobals($parseStrOpts = array())
$queryParams = self::parseStr($query, $parseStrOpts);
return $serverRequest
->withBody(new Stream(
PHP_VERSION_ID < 50600
? \stream_get_contents(\fopen('php://input', 'r+')) // prev 5.6 is not seekable / read once
PHP_VERSION_ID < 70000
? \stream_get_contents(\fopen('php://input', 'r+')) // prev 5.6 is not seekable / read once.. still not reliable in 5.6
: \fopen('php://input', 'r+')
))
->withCookieParams($_COOKIE)
Expand Down
8 changes: 6 additions & 2 deletions tests/docroot/frontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

require __DIR__ . '/../../vendor/autoload.php';

if (!\defined('STDERR')) {
\define('STDERR', \fopen('php://stderr', 'wb'));
}

$serverRequest = \bdk\HttpMessage\ServerRequest::fromGlobals();
$serverParams = $serverRequest->getServerParams();
$requestUri = $serverRequest->getUri();
Expand All @@ -25,8 +29,8 @@
$requestUri,
$error['typeStr'] . ': ' . $error['file'] . '(' . $error['line'] . ') ' . $error['message']
);
\fwrite(STDERR, "\e[38;5;250m" . $logEntry . "\e[0m" . "\n");
\file_put_contents($logFile, $logEntry, FILE_APPEND);
// \fwrite(STDERR, "\e[38;5;250m" . $logEntry . "\e[0m" . "\n");
\file_put_contents($logFile, $logEntry . "\n", FILE_APPEND);
});
}

Expand Down

0 comments on commit aef0d77

Please sign in to comment.