Skip to content

Commit 0b29b82

Browse files
committedApr 13, 2023
Update testbed class methods to match new signatures
1 parent 5330f1a commit 0b29b82

12 files changed

+94
-88
lines changed
 

Diff for: ‎php-refdb-backend-internal.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ zend_function_entry php_git2::refdb_backend_internal_methods[] = {
103103
PHP_ME(
104104
GitRefDBBackend_Internal,
105105
reflog_rename,
106-
arginfo_class_GitRefDBBackend_reflog_delete,
106+
arginfo_class_GitRefDBBackend_reflog_rename,
107107
ZEND_ACC_PUBLIC
108108
)
109109
PHP_ME(

Diff for: ‎php-refdb-backend.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ zend_function_entry php_git2::refdb_backend_methods[] = {
319319
PHP_ABSTRACT_ME(
320320
GitRefDBBackend,
321321
reflog_rename,
322-
arginfo_class_GitRefDBBackend_reflog_delete
322+
arginfo_class_GitRefDBBackend_reflog_rename
323323
)
324324
PHP_ABSTRACT_ME(
325325
GitRefDBBackend,

Diff for: ‎stubs/GitConfigBackend.stub.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function del_multivar(string $name,string $regexp) : void;
1818

1919
public function iterator_new() : mixed;
2020

21-
public function iterator_next(mixed $context) : array;
21+
public function iterator_next(mixed $context) : mixed;
2222

2323
public function snapshot() : \GitConfigBackend;
2424

Diff for: ‎stubs/GitConfigBackend_arginfo.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: cbde75694a9cc6672ba0ebd3c9e44914e534d578 */
2+
* Stub hash: ef5aa2ec0b1a20e6b3125c45b69354f9c611e993 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GitConfigBackend_open, 0, 2, IS_VOID, 0)
55
ZEND_ARG_TYPE_INFO(0, level, IS_LONG, 0)
@@ -33,7 +33,7 @@ ZEND_END_ARG_INFO()
3333
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GitConfigBackend_iterator_new, 0, 0, IS_MIXED, 0)
3434
ZEND_END_ARG_INFO()
3535

36-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GitConfigBackend_iterator_next, 0, 1, IS_ARRAY, 0)
36+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GitConfigBackend_iterator_next, 0, 1, IS_MIXED, 0)
3737
ZEND_ARG_TYPE_INFO(0, context, IS_MIXED, 0)
3838
ZEND_END_ARG_INFO()
3939

Diff for: ‎stubs/GitODBBackend.stub.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

33
abstract class GitODBBackend {
4-
public function read(int &$type,string $oid) : string;
4+
public function read(int &$type,string $oid) : string|bool;
55

6-
public function read_prefix(string &$full_oid,int &$type,string $abbrev_oid) : string;
6+
public function read_prefix(string &$full_oid,int &$type,string $abbrev_oid) : string|bool;
77

8-
public function read_header(int &$size,int &$type,string $oid) : void;
8+
public function read_header(int &$size,int &$type,string $oid) : bool;
99

1010
public function write(string $oid,string $data,int $type) : void;
1111

Diff for: ‎stubs/GitODBBackend_arginfo.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: b64e84e7fa50b6421659c9aa4160e193dabf67cb */
2+
* Stub hash: 299894342d76827e7d900ff9ebe3e3662afb4ac7 */
33

4-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GitODBBackend_read, 0, 2, IS_STRING, 0)
4+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_GitODBBackend_read, 0, 2, MAY_BE_STRING|MAY_BE_BOOL)
55
ZEND_ARG_TYPE_INFO(1, type, IS_LONG, 0)
66
ZEND_ARG_TYPE_INFO(0, oid, IS_STRING, 0)
77
ZEND_END_ARG_INFO()
88

9-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GitODBBackend_read_prefix, 0, 3, IS_STRING, 0)
9+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_GitODBBackend_read_prefix, 0, 3, MAY_BE_STRING|MAY_BE_BOOL)
1010
ZEND_ARG_TYPE_INFO(1, full_oid, IS_STRING, 0)
1111
ZEND_ARG_TYPE_INFO(1, type, IS_LONG, 0)
1212
ZEND_ARG_TYPE_INFO(0, abbrev_oid, IS_STRING, 0)
1313
ZEND_END_ARG_INFO()
1414

15-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GitODBBackend_read_header, 0, 3, IS_VOID, 0)
15+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GitODBBackend_read_header, 0, 3, _IS_BOOL, 0)
1616
ZEND_ARG_TYPE_INFO(1, size, IS_LONG, 0)
1717
ZEND_ARG_TYPE_INFO(1, type, IS_LONG, 0)
1818
ZEND_ARG_TYPE_INFO(0, oid, IS_STRING, 0)

Diff for: ‎testbed/src/Backend/PHPSerializedConfigBackend.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class PHPSerializedConfigBackend extends \GitConfigBackend {
1414

1515
private $iterator = false;
1616

17-
public function open($level,$repo) {
17+
public function open(int $level,$repo) : void {
1818
$repoPath = git_repository_path($repo);
1919
if (!$this->readonly && !empty($repoPath)) {
2020
$this->path = "${repoPath}config.phpserial";
@@ -24,7 +24,7 @@ public function open($level,$repo) {
2424
}
2525
}
2626

27-
public function get($name) {
27+
public function get(string $name) : array {
2828
if (!isset($this->storage[$name][0])) {
2929
return false;
3030
}
@@ -36,14 +36,14 @@ public function get($name) {
3636
];
3737
}
3838

39-
public function set($name,$value) {
39+
public function set(string $name,string $value) : void {
4040
$this->checkSnapshot();
4141

4242
$this->storage[$name][0] = $value;
4343
$this->writeOut();
4444
}
4545

46-
public function set_multivar($name,$regexp,$value) {
46+
public function set_multivar(string $name,string $regexp,string $value) : void {
4747
$this->checkSnapshot();
4848

4949
if (!isset($this->storage[$name])) {
@@ -72,14 +72,14 @@ public function set_multivar($name,$regexp,$value) {
7272
$this->writeOut();
7373
}
7474

75-
public function del($name) {
75+
public function del(string $name) : void {
7676
$this->checkSnapshot();
7777

7878
unset($this->storage[$name]);
7979
$this->writeOut();
8080
}
8181

82-
public function del_multivar($name,$regexp) {
82+
public function del_multivar(string $name,string $regexp) : void {
8383
$this->checkSnapshot();
8484

8585
if (!isset($this->storage[$name])) {
@@ -107,11 +107,11 @@ public function del_multivar($name,$regexp) {
107107
$this->writeOut();
108108
}
109109

110-
public function iterator_new() {
110+
public function iterator_new() : mixed {
111111
$this->iterator = $this->storage;
112112
}
113113

114-
public function iterator_next($context) {
114+
public function iterator_next($context) : mixed {
115115
if ($this->iterator === false) {
116116
return false;
117117
}
@@ -122,7 +122,7 @@ public function iterator_next($context) {
122122
return $value[0];
123123
}
124124

125-
public function snapshot() {
125+
public function snapshot() : \GitConfigBackend {
126126
if ($this->readonly) {
127127
return $this;
128128
}
@@ -131,11 +131,11 @@ public function snapshot() {
131131
return $snapshot;
132132
}
133133

134-
public function lock() {
134+
public function lock() : void {
135135
$this->locked = true;
136136
}
137137

138-
public function unlock() {
138+
public function unlock(bool $success) : void {
139139
$this->locked = false;
140140

141141
if ($this->lockedContent && is_resource($this->file)) {

Diff for: ‎testbed/src/Backend/PHPSerializedODBBackend.php

+12-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class PHPSerializedODBBackend extends \GitODBBackend {
1616
* @return string
1717
* The object contents.
1818
*/
19-
public function read(&$type,$oid) {
19+
public function read(&$type,string $oid) : string {
2020
if (isset($this->storage[$oid])) {
2121
$record = $this->storage[$oid];
2222
$type = $record['t'];
@@ -39,7 +39,7 @@ public function read(&$type,$oid) {
3939
* @return string
4040
* The object contents.
4141
*/
42-
public function read_prefix(&$fullOid,&$type,$abbrevOid) {
42+
public function read_prefix(&$fullOid,&$type,string $abbrevOid) : string {
4343
$i = 0;
4444
$keys = array_keys($this->storage);
4545
while ($i < count($keys)) {
@@ -64,14 +64,19 @@ public function read_prefix(&$fullOid,&$type,$abbrevOid) {
6464
* Returns the object type.
6565
* @param string $oid
6666
* The object ID.
67+
*
68+
* @return bool
69+
* Returns whether the header was found or not.
6770
*/
68-
public function read_header(&$size,&$type,$oid) {
71+
public function read_header(&$size,&$type,string $oid) : bool {
6972
if (!isset($this->storage[$oid])) {
7073
return false;
7174
}
7275

7376
$size = strlen($this->storage[$oid]['d']);
7477
$type = strlen($this->storage[$oid]['t']);
78+
79+
return true;
7580
}
7681

7782
/**
@@ -84,7 +89,7 @@ public function read_header(&$size,&$type,$oid) {
8489
* @param int $type
8590
* The type of the objects.
8691
*/
87-
public function write($oid,$data,$type) {
92+
public function write(string $oid,string $data,int $type) : void {
8893
$this->storage[$oid] = [
8994
't' => $type,
9095
'd' => $data,
@@ -99,7 +104,7 @@ public function write($oid,$data,$type) {
99104
*
100105
* @return bool
101106
*/
102-
public function exists($oid) {
107+
public function exists(string $oid) : bool {
103108
return isset($this->storage[$oid]);
104109
}
105110

@@ -113,7 +118,7 @@ public function exists($oid) {
113118
*
114119
* @return bool
115120
*/
116-
public function exists_prefix(&$fullOid,$prefix) {
121+
public function exists_prefix(&$fullOid,string $prefix) : bool {
117122
$i = 0;
118123
$keys = array_keys($this->storage);
119124
while ($i < count($keys)) {
@@ -136,7 +141,7 @@ public function exists_prefix(&$fullOid,$prefix) {
136141
* @param mixed $payload
137142
* The payload to pass through.
138143
*/
139-
public function for_each($callback,$payload) {
144+
public function for_each(callable $callback,mixed $payload = null) : void {
140145
foreach (array_keys($this->storage) as $oid) {
141146
if ($callback($oid,$payload) === false) {
142147
break;

Diff for: ‎testbed/src/Backend/PHPSerializedRefDbBackend.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class PHPSerializedRefDbBackend extends \GitRefDBBackend {
1212
*
1313
* @return bool
1414
*/
15-
public function exists($refName) {
15+
public function exists(string $refName) : bool {
1616
return isset($this->storage[$refName]);
1717
}
1818

@@ -23,7 +23,7 @@ public function exists($refName) {
2323
*
2424
* @return string
2525
*/
26-
public function lookup($refName) {
26+
public function lookup(string $refName) : mixed {
2727
return $this->storage[$refName];
2828
}
2929

@@ -32,7 +32,7 @@ public function lookup($refName) {
3232
*
3333
* @param string $glob
3434
*/
35-
public function iterator_new($glob) {
35+
public function iterator_new(string $glob) : void {
3636
reset($this->storage);
3737
}
3838

@@ -43,7 +43,7 @@ public function iterator_new($glob) {
4343
*
4444
* @return string
4545
*/
46-
public function iterator_next(&$name) {
46+
public function iterator_next(&$name) : mixed {
4747
$name = key($this->storage);
4848
$oid = current($this->storage);
4949

@@ -62,7 +62,7 @@ public function iterator_next(&$name) {
6262
* @param string $old
6363
* @param string $oldTarget
6464
*/
65-
public function write($ref,$force,$who,$message,$old,$oldTarget) {
65+
public function write($ref,bool $force,array $who,string $message,string $old,string $oldTarget) : void {
6666
$name = git_reference_name($ref);
6767
$target = git_reference_target($ref);
6868

@@ -86,7 +86,7 @@ public function write($ref,$force,$who,$message,$old,$oldTarget) {
8686
* @param array $who
8787
* @param string $message
8888
*/
89-
public function rename($oldName,$newName,$force,$who,$message) {
89+
public function rename(string $oldName,string $newName,bool $force,array $who,string $message) {
9090
if (!isset($this->storage[$oldName])) {
9191
throw new Exception("Reference with name '$oldName' does not exist");
9292
}
@@ -106,7 +106,7 @@ public function rename($oldName,$newName,$force,$who,$message) {
106106
* @param string $oldId
107107
* @param string $oldTarget
108108
*/
109-
public function del($refName,$oldId,$oldTarget) {
109+
public function del(string $refName,string $oldId,string $oldTarget) : void {
110110
if (!isset($this->storage[$refName])) {
111111
throw new Exception("Reference with name '$refName' does not exist");
112112
}
@@ -120,49 +120,49 @@ public function del($refName,$oldId,$oldTarget) {
120120
/**
121121
* Implements GitRefDbBackend::compress().
122122
*/
123-
public function compress() {
123+
public function compress() : void {
124124
// Compression is not relevant here.
125125
}
126126

127127
/**
128128
* Implements GitRefDbBackend::has_log().
129129
*/
130-
public function has_log($refname) {
130+
public function has_log(string $refname) : bool {
131131
throw new Exception('Reflogs are not implemented by this backend');
132132
}
133133

134134
/**
135135
* Implements GitRefDbBackend::ensure_log().
136136
*/
137-
public function ensure_log($refname) {
137+
public function ensure_log(string $refname) : void {
138138
throw new Exception('Reflogs are not implemented by this backend');
139139
}
140140

141141
/**
142142
* Implements GitRefDbBackend::reflog_write().
143143
*/
144-
public function reflog_write($name) {
144+
public function reflog_write($reflog) : void {
145145
throw new Exception('Reflogs are not implemented by this backend');
146146
}
147147

148148
/**
149149
* Implements GitRefDbBackend::reflog_read().
150150
*/
151-
public function reflog_read($name) {
151+
public function reflog_read($name) : array {
152152
throw new Exception('Reflogs are not implemented by this backend');
153153
}
154154

155155
/**
156156
* Implements GitRefDbBackend::reflog_rename().
157157
*/
158-
public function reflog_rename($oldName,$newName) {
158+
public function reflog_rename(string $oldName,string $newName) : void {
159159
throw new Exception('Reflogs are not implemented by this backend');
160160
}
161161

162162
/**
163163
* Implements GitRefDbBackend::reflog_delete().
164164
*/
165-
public function reflog_delete($name) {
165+
public function reflog_delete(string $name) : void {
166166
throw new Exception('Reflogs are not implemented by this backend');
167167
}
168168

0 commit comments

Comments
 (0)
Please sign in to comment.