Permalink
Browse files

uses PHP 7.1 features

  • Loading branch information...
dg committed Feb 5, 2019
1 parent c7c4a0c commit 282908f77802dd0f36f428b29e2986e173435fbc
Showing with 5 additions and 5 deletions.
  1. +2 −2 src/SafeStream/SafeStream.php
  2. +3 −3 tests/SafeStream/SafeStream.stress.phpt
@@ -23,7 +23,7 @@
class SafeStream
{
/** Name of stream protocol - nette.safe:// */
const PROTOCOL = 'nette.safe';
public const PROTOCOL = 'nette.safe';

This comment has been minimized.

@ondrejd

ondrejd Feb 7, 2019

Tak tomuhle říkám změna - jediná věc, která je nekompatibilní s PHP 7.0 a přitom je to úplně nanic (public je default).
Opravdu výborná práce!!!!

This comment has been minimized.

@dg

dg Feb 7, 2019

Author Member

SafeStream 2.3 je kompatibilní s PHP 7.0, kde je problém?

/** @var resource orignal file handle */
private $handle;
@@ -50,7 +50,7 @@ class SafeStream
*/
public static function register()
{
foreach (array_intersect(stream_get_wrappers(), array('safe', self::PROTOCOL)) as $name) {
foreach (array_intersect(stream_get_wrappers(), ['safe', self::PROTOCOL]) as $name) {
stream_wrapper_unregister($name);
}
stream_wrapper_register('safe', __CLASS__); // old protocol
@@ -35,7 +35,7 @@ for ($i = 0; $i <= COUNT_FILES; $i++) {
// test loop
$hits = array('ok' => 0, 'notfound' => 0, 'error' => 0, 'cantwrite' => 0, 'cantdelete' => 0);
$hits = ['ok' => 0, 'notfound' => 0, 'error' => 0, 'cantwrite' => 0, 'cantdelete' => 0];
for ($counter = 0; $counter < 300; $counter++) {
// write
@@ -63,10 +63,10 @@ for ($counter = 0; $counter < 300; $counter++) {
}
}
Assert::same(array(
Assert::same([
'ok' => $counter, // should be 1000. If unlink() is used, sum [ok] + [notfound] should be 1000
'notfound' => 0, // means 'file not found', should be 0 if unlink() is not used
'error' => 0, // means 'file contents is damaged', MUST be 0
'cantwrite' => 0, // means 'somebody else is writing this file'
'cantdelete' => 0, // means 'unlink() has timeout', should be 0
), $hits);
], $hits);

0 comments on commit 282908f

Please sign in to comment.