Skip to content

Commit 29b92ae

Browse files
authored
Merge pull request #3 from Schlue/FRAMEWORK_6_0
Make unit test working with PHP8.3
2 parents a1362b5 + fe09bb6 commit 29b92ae

File tree

18 files changed

+231
-76
lines changed

18 files changed

+231
-76
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ jobs:
2626
runs-on: ${{ matrix.operating-system }}
2727
strategy:
2828
matrix:
29-
operating-system: ['ubuntu-20.04']
29+
operating-system: ['ubuntu-20.04', 'ubuntu-latest']
3030
php-versions: ['7.4', '8.0', 'latest']
31-
phpunit-versions: ['latest', '9.5']
31+
phpunit-versions: ['9.5', 'latest']
3232
steps:
3333
- name: Setup github ssh key
3434
run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts
3535
- name: Checkout
36-
uses: actions/checkout@v2
36+
uses: actions/checkout@v4
3737

3838
- name: Setup PHP
3939
uses: shivammathur/setup-php@v2

composer.json

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,15 @@
2323
}
2424
],
2525
"time": "2022-11-04",
26-
"repositories": [
27-
{
28-
"type": "composer",
29-
"url": "https://horde-satis.maintaina.com"
30-
}
31-
],
26+
"repositories": [ ],
3227
"require": {
3328
"php": "^7.4 || ^8",
3429
"horde/cli": "^3 || dev-FRAMEWORK_6_0",
3530
"horde/exception": "^3 || dev-FRAMEWORK_6_0",
3631
"horde/translation": "^3 || dev-FRAMEWORK_6_0",
3732
"horde/util": "^3 || dev-FRAMEWORK_6_0"
3833
},
39-
"require-dev": {
40-
"horde/test": "^3 || dev-FRAMEWORK_6_0"
41-
},
34+
"require-dev": { },
4235
"suggest": {
4336
"horde/test": "^3 || dev-FRAMEWORK_6_0"
4437
},
@@ -52,12 +45,12 @@
5245
},
5346
"autoload-dev": {
5447
"psr-4": {
55-
"Horde\\Argv\\Test\\": "test/"
48+
"Horde\\Argv\\": "test/Horde/Argv"
5649
}
5750
},
5851
"config": {
5952
"allow-plugins": {
6053
"horde/horde-installer-plugin": true
6154
}
6255
}
63-
}
56+
}

lib/Horde/Argv/HelpFormatter.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ abstract class Horde_Argv_HelpFormatter
7070
const NO_DEFAULT_VALUE = 'none';
7171

7272
public $parser = null;
73+
public $_color;
74+
public $indent_increment;
75+
public $max_help_position;
76+
public $help_position;
77+
public $width;
78+
public $level;
79+
public $current_indent;
80+
public $help_width;
81+
public $default_tag;
82+
public $option_strings;
83+
public $_short_opt_fmt;
84+
public $_long_opt_fmt;
85+
public $short_first;
7386

7487
public function __construct(
7588
$indent_increment, $max_help_position, $width = null,
@@ -92,7 +105,7 @@ public function __construct(
92105
$this->help_width = null; // computed later
93106
$this->short_first = $short_first;
94107
$this->default_tag = '%default';
95-
$this->option_strings = array();
108+
$this->option_strings = [];
96109
$this->_short_opt_fmt = '%s %s';
97110
$this->_long_opt_fmt = '%s=%s';
98111
}

lib/Horde/Argv/Option.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,21 @@ public function checkChoice($opt, $value)
263263

264264
// -- Constructor/initialization methods ----------------------------
265265

266-
public $shortOpts = array();
267-
public $longOpts = array();
266+
public $shortOpts = [];
267+
public $longOpts = [];
268+
269+
public $action;
270+
public $type;
268271
public $dest;
269272
public $default;
273+
public $nargs;
274+
public $const;
275+
public $choices;
276+
public $callback;
277+
public $callbackArgs;
278+
public $help;
279+
public $metavar;
280+
public $container;
270281

271282
/**
272283
* Constructor.

lib/Horde/Argv/OptionException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
*/
2828
class Horde_Argv_OptionException extends Horde_Argv_Exception
2929
{
30+
public string $optionId;
31+
3032
public function __construct($msg, $option = null)
3133
{
3234
$this->optionId = (string)$option;

lib/Horde/Argv/OptionGroup.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
class Horde_Argv_OptionGroup extends Horde_Argv_OptionContainer
2929
{
3030
protected $_title;
31+
public $parser;
3132

3233
public function __construct($parser, $title, $description = null)
3334
{

lib/Horde/Argv/Parser.php

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,23 @@
8181
*/
8282
class Horde_Argv_Parser extends Horde_Argv_OptionContainer
8383
{
84-
public $standardOptionList = array();
85-
84+
public $standardOptionList = [];
8685
protected $_usage;
87-
public $optionGroups = array();
88-
89-
public function __construct($args = array())
90-
{
91-
$args = array_merge(array(
86+
public $prog;
87+
public $epilog;
88+
public $optionGroups = [];
89+
public $allowInterspersedArgs;
90+
public $ignoreUnknownArgs;
91+
public $rargs;
92+
public $largs;
93+
public $values;
94+
public $formatter;
95+
public $version;
96+
public $allowUnknownArgs;
97+
98+
public function __construct($args = [])
99+
{
100+
$args = array_merge([
92101
'usage' => null,
93102
'optionList' => null,
94103
'optionClass' => 'Horde_Argv_Option',
@@ -102,7 +111,7 @@ public function __construct($args = array())
102111
'allowInterspersedArgs' => true,
103112
'allowUnknownArgs' => false,
104113
'ignoreUnknownArgs' => false,
105-
), $args);
114+
], $args);
106115

107116
parent::__construct($args['optionClass'], $args['conflictHandler'], $args['description']);
108117
$this->setUsage($args['usage']);
@@ -133,8 +142,8 @@ public function __construct($args = array())
133142

134143
protected function _createOptionList()
135144
{
136-
$this->optionList = array();
137-
$this->optionGroups = array();
145+
$this->optionList = [];
146+
$this->optionGroups = [];
138147
$this->_createOptionMappings();
139148
}
140149

@@ -165,9 +174,9 @@ protected function _populateOptionList($optionList, $add_help = true)
165174
protected function _initParsingState()
166175
{
167176
// These are set in parseArgs() for the convenience of callbacks.
168-
$this->rargs = null;
169-
$this->largs = null;
170-
$this->values = null;
177+
$this->rargs = [];
178+
$this->largs = [];
179+
$this->values = [];
171180
}
172181

173182
// -- Simple modifier methods ---------------------------------------
@@ -177,7 +186,7 @@ public function setUsage($usage)
177186
if (is_null($usage))
178187
$this->_usage = '%prog ' . Horde_Argv_Translation::t("[options]");
179188
elseif ($usage == Horde_Argv_Option::SUPPRESS_USAGE)
180-
$this->_usage = null;
189+
$this->_usage = '';
181190
else
182191
$this->_usage = $usage;
183192
}

lib/Horde/Argv/Values.php

Lines changed: 111 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,60 +24,152 @@
2424
* @copyright 2010-2017 Horde LLC
2525
* @license http://www.horde.org/licenses/bsd BSD
2626
*/
27+
2728
class Horde_Argv_Values implements IteratorAggregate, ArrayAccess, Countable
2829
{
29-
public function __construct($defaults = array())
30+
// Array to store the dynamic attributes
31+
private $data = [];
32+
33+
/**
34+
* Summary of __construct
35+
* @param mixed $defaults
36+
*/
37+
public function __construct($defaults = [])
3038
{
3139
foreach ($defaults as $attr => $val) {
32-
$this->$attr = $val;
40+
$this->data[$attr] = $val;
3341
}
3442
}
3543

36-
public function __toString()
44+
/**
45+
* __set: Set a value
46+
*
47+
* @param string $attr The name of the attribute
48+
* @param mixed $value The content of the attribute
49+
*/
50+
public function __set($attr, $value): void
51+
{
52+
$this->data[$attr] = $value;
53+
}
54+
55+
/**
56+
* __get: Returns a value of an attribute
57+
*
58+
* @param string $attr The name of the attribute
59+
* @return mixed The value of the attribute
60+
*/
61+
public function &__get($attr)
62+
{
63+
return $this->data[$attr];
64+
}
65+
66+
/**
67+
* __isset: check if an attribute is set
68+
*
69+
* @param string $attr The name of the attribute
70+
* @return bool True, when the attribute exists/ is set else false
71+
*/
72+
public function __isset($attr): bool
73+
{
74+
return isset($this->data[$attr]);
75+
}
76+
77+
/**
78+
* __unset: removes a attribute
79+
*
80+
* @param string $attr The name of the attribute
81+
* @return void
82+
*/
83+
public function __unset($attr): void
84+
{
85+
unset($this->data[$attr]);
86+
}
87+
88+
/**
89+
* __toString: The whole content as a string
90+
*
91+
* @return string The content as a string
92+
*/
93+
public function __toString(): string
3794
{
38-
$str = array();
39-
foreach ($this as $attr => $val) {
95+
$str = [];
96+
foreach ($this->data as $attr => $val) {
4097
$str[] = $attr . ': ' . (string)$val;
4198
}
4299
return implode(', ', $str);
43100
}
44101

45-
public function offsetExists($attr)
102+
/**
103+
* Summary of offsetExists
104+
* @param mixed $attr
105+
* @return bool
106+
*/
107+
public function offsetExists($attr): bool
46108
{
47-
return isset($this->$attr) && !is_null($this->$attr);
109+
return isset($this->data[$attr]) && !$this->data[$attr] === null;
48110
}
49111

112+
/**
113+
* Summary of offsetGet
114+
* @param mixed $attr
115+
* @return mixed
116+
*/
50117
public function offsetGet($attr)
51118
{
52-
return $this->$attr;
119+
return $this->data[$attr] ?? null;
53120
}
54121

55-
public function offsetSet($attr, $val)
122+
/**
123+
* Summary of offsetSet
124+
* @param mixed $attr
125+
* @param mixed $val
126+
* @return void
127+
*/
128+
public function offsetSet($attr, $val): void
56129
{
57-
$this->$attr = $val;
130+
$this->data[$attr] = $val;
58131
}
59132

60-
public function offsetUnset($attr)
133+
/**
134+
* Summary of offsetUnset
135+
* @param mixed $attr
136+
* @return void
137+
*/
138+
public function offsetUnset($attr): void
61139
{
62-
unset($this->$attr);
140+
unset($this->data[$attr]);
63141
}
64142

65-
public function getIterator()
143+
/**
144+
* Summary of getIterator
145+
* @return ArrayIterator
146+
*/
147+
public function getIterator(): ArrayIterator
66148
{
67-
return new ArrayIterator(get_object_vars($this));
149+
return new ArrayIterator($this->data);
68150
}
69151

70-
public function count()
152+
/**
153+
* Summary of count
154+
* @return int
155+
*/
156+
public function count(): int
71157
{
72-
return count(get_object_vars($this));
158+
return count(get_object_vars($this->data));
73159
}
74160

161+
/**
162+
* Summary of ensureValue
163+
* @param mixed $attr
164+
* @param mixed $value
165+
* @return mixed
166+
*/
75167
public function ensureValue($attr, $value)
76168
{
77-
if (is_null($this->$attr)) {
78-
$this->$attr = $value;
169+
if ($this->data[$attr] === null) {
170+
$this->data[$attr] = $value;
79171
}
80-
return $this->$attr;
172+
return $this->data[$attr];
81173
}
82174

83175
}

test/Horde/Argv/AllTests.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
if (!class_exists('Horde_Test_AllTests')) {
3-
require_once 'Horde/Test/AllTests.php';
2+
use Horde\Tests\AllTests;
3+
4+
if (class_exists(AllTests::class)) {
5+
Horde\Test\AllTests::init(__FILE__)->run();
46
}
5-
Horde_Test_AllTests::init(__FILE__)->run();

test/Horde/Argv/CountTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
class CountTest extends TestCase
1616
{
17+
public $vOpt;
1718
public function setUp(): void
1819
{
1920
parent::setUp();

0 commit comments

Comments
 (0)