Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,29 @@ run-tests.log
/test/*/*/*/*.log
/test/*/*/*/*.out


# Added by horde-components QC --fix-qc-issues
# Build artifacts directory
/build/
# Composer dependencies directory
/vendor/
# Composer lock file (libraries should not commit lock files)
/composer.lock
# PHPStorm IDE settings
/.idea/
# VSCode IDE settings
/.vscode/
# Claude Code CLI cache and state
/.claude/
# Cline extension data
/.cline/
# PHP CS Fixer cache file
/.php-cs-fixer.cache
# PHPUnit result cache
/.phpunit.result.cache
# PHPUnit Cache (other)
/.phpunit.cache
# PHPStan local configuration
/phpstan.neon
# PHPStan cache directory
/.phpstan.cache/
9 changes: 7 additions & 2 deletions .horde.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ license:
uri: http://www.horde.org/licenses/bsd
dependencies:
required:
php: ^7.4 || ^8
php: ^8
dev:
composer:
horde/log: ^3
horde/test: ^3
optional:
composer:
horde/log: ^3
keywords:
- decorator
vendor: horde
quality:
phpstan:
level: 3
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"php": "^7.4 || ^8"
},
"require-dev": {
"horde/log": "^3 || dev-FRAMEWORK_6_0",
"horde/test": "^3 || dev-FRAMEWORK_6_0"
"horde/log": "^3 || dev-FRAMEWORK_6_0"
},
"suggest": {
"horde/log": "^3 || dev-FRAMEWORK_6_0"
Expand All @@ -47,4 +46,4 @@
"Horde\\Stream\\Wrapper\\Test\\": "test/"
}
}
}
}
51 changes: 26 additions & 25 deletions lib/Horde/Stream/Wrapper/Combine.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2009-2017 Horde LLC (http://www.horde.org/)
* Copyright 2009-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
Expand All @@ -24,7 +25,7 @@
class Horde_Stream_Wrapper_Combine
{
/**/
const WRAPPER_NAME = 'horde-stream-wrapper-combine';
public const WRAPPER_NAME = 'horde-stream-wrapper-combine';

/**
* Context.
Expand All @@ -38,7 +39,7 @@ class Horde_Stream_Wrapper_Combine
*
* @var array
*/
protected $_data = array();
protected $_data = [];

/**
* The combined length of the stream.
Expand Down Expand Up @@ -95,11 +96,11 @@ public static function getStream($data)
self::WRAPPER_NAME . '://' . ++self::$_id,
'wb',
false,
stream_context_create(array(
self::WRAPPER_NAME => array(
'data' => $data
)
))
stream_context_create([
self::WRAPPER_NAME => [
'data' => $data,
],
])
);
}
/**
Expand Down Expand Up @@ -137,11 +138,11 @@ public function stream_open($path, $mode, $options, &$opened_path)
$length = ftell($fp);
rewind($fp);

$this->_data[] = array(
$this->_data[] = [
'fp' => $fp,
'l' => $length,
'p' => 0
);
'p' => 0,
];

$this->_length += $length;
}
Expand Down Expand Up @@ -252,7 +253,7 @@ public function stream_eof()
*/
public function stream_stat()
{
return array(
return [
'dev' => 0,
'ino' => 0,
'mode' => 0,
Expand All @@ -265,8 +266,8 @@ public function stream_stat()
'mtime' => 0,
'ctime' => 0,
'blksize' => 0,
'blocks' => 0
);
'blocks' => 0,
];
}

/**
Expand All @@ -283,20 +284,20 @@ public function stream_seek($offset, $whence)
$this->_ateof = false;

switch ($whence) {
case SEEK_SET:
$offset = $offset;
break;
case SEEK_SET:
$offset = $offset;
break;

case SEEK_CUR:
$offset = $this->_position + $offset;
break;
case SEEK_CUR:
$offset = $this->_position + $offset;
break;

case SEEK_END:
$offset = $this->_length + $offset;
break;
case SEEK_END:
$offset = $this->_length + $offset;
break;

default:
return false;
default:
return false;
}

$count = $this->_position = min($this->_length, $offset);
Expand Down
4 changes: 2 additions & 2 deletions lib/Horde/Stream/Wrapper/CombineStream.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2009-2017 Horde LLC (http://www.horde.org/)
* Copyright 2009-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
Expand Down Expand Up @@ -30,4 +31,3 @@ interface Horde_Stream_Wrapper_CombineStream
*/
public function getData();
}

45 changes: 23 additions & 22 deletions lib/Horde/Stream/Wrapper/String.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2007-2017 Horde LLC (http://www.horde.org/)
* Copyright 2007-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
Expand All @@ -24,7 +25,7 @@
class Horde_Stream_Wrapper_String
{
/**/
const WRAPPER_NAME = 'horde-stream-wrapper-string';
public const WRAPPER_NAME = 'horde-stream-wrapper-string';

/**
* The current context.
Expand Down Expand Up @@ -70,18 +71,18 @@ public static function getStream(&$string)
}

/* Needed to keep reference. */
$ob = new stdClass;
$ob = new stdClass();
$ob->string = &$string;

return fopen(
self::WRAPPER_NAME . '://' . ++self::$_id,
'wb',
false,
stream_context_create(array(
self::WRAPPER_NAME => array(
'string' => $ob
)
))
stream_context_create([
self::WRAPPER_NAME => [
'string' => $ob,
],
])
);
}

Expand All @@ -93,10 +94,10 @@ public function stream_open($path, $mode, $options, &$opened_path)
$opts = stream_context_get_options($this->context);

if (isset($opts[self::WRAPPER_NAME]['string'])) {
$this->_string =& $opts[self::WRAPPER_NAME]['string']->string;
$this->_string = & $opts[self::WRAPPER_NAME]['string']->string;
} elseif (isset($opts['horde-string']['string'])) {
// @deprecated
$this->_string =& $opts['horde-string']['string']->getString();
$this->_string = & $opts['horde-string']['string']->getString();
} else {
throw new Exception('Use ' . __CLASS__ . '::getStream() to initialize the stream.');
}
Expand Down Expand Up @@ -163,7 +164,7 @@ public function stream_eof()
*/
public function stream_stat()
{
return array(
return [
'dev' => 0,
'ino' => 0,
'mode' => 0,
Expand All @@ -176,8 +177,8 @@ public function stream_stat()
'mtime' => 0,
'ctime' => 0,
'blksize' => 0,
'blocks' => 0
);
'blocks' => 0,
];
}

/**
Expand All @@ -186,17 +187,17 @@ public function stream_stat()
public function stream_seek($offset, $whence)
{
switch ($whence) {
case SEEK_SET:
$pos = $offset;
break;
case SEEK_SET:
$pos = $offset;
break;

case SEEK_CUR:
$pos = $this->_pos + $offset;
break;
case SEEK_CUR:
$pos = $this->_pos + $offset;
break;

case SEEK_END:
$pos = strlen($this->_string) + $offset;
break;
case SEEK_END:
$pos = strlen($this->_string) + $offset;
break;
}

if (($pos < 0) || ($pos > strlen($this->_string))) {
Expand Down
3 changes: 2 additions & 1 deletion lib/Horde/Stream/Wrapper/StringStream.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2007-2017 Horde LLC (http://www.horde.org/)
* Copyright 2007-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
Expand Down
19 changes: 8 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="test/bootstrap.php"
cacheResultFile=".phpunit.cache/test-results"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
forceCoversAnnotation="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerWarnings="true">
<testsuites>
<testsuite name="horde/stream_wrapper">
<directory>test</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">lib</directory>
<directory suffix=".php">src</directory>
</include>
</coverage>
</source>
</phpunit>
3 changes: 2 additions & 1 deletion src/CombineStreamWrapper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2009-2017 Horde LLC (http://www.horde.org/)
* Copyright 2009-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
Expand Down
25 changes: 13 additions & 12 deletions src/CombineWrapper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2009-2017 Horde LLC (http://www.horde.org/)
* Copyright 2009-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
Expand Down Expand Up @@ -317,20 +318,20 @@ public function stream_seek(int $offset, int $whence): bool
$this->ateof = false;

switch ($whence) {
case SEEK_SET:
$offset = $offset;
break;
case SEEK_SET:
$offset = $offset;
break;

case SEEK_CUR:
$offset = $this->position + $offset;
break;
case SEEK_CUR:
$offset = $this->position + $offset;
break;

case SEEK_END:
$offset = $this->length + $offset;
break;
case SEEK_END:
$offset = $this->length + $offset;
break;

default:
return false;
default:
return false;
}

$count = $this->position = min($this->length, $offset);
Expand Down
3 changes: 2 additions & 1 deletion src/StringStreamWrapper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2007-2017 Horde LLC (http://www.horde.org/)
* Copyright 2007-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
Expand Down
Loading
Loading