Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6029966
FauxHookHandlerArray.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
FauxHookHandlerArray.php
View Options
<?php
namespace
MediaWiki\HookContainer
;
use
InvalidArgumentException
;
use
LogicException
;
use
OutOfBoundsException
;
/**
* @internal
*/
class
FauxHookHandlerArray
implements
\ArrayAccess
,
\IteratorAggregate
{
private
HookContainer
$hookContainer
;
private
string
$name
;
private
?
array
$handlers
=
null
;
/**
* @param HookContainer $hookContainer
* @param string $name
*/
public
function
__construct
(
HookContainer
$hookContainer
,
string
$name
)
{
$this
->
hookContainer
=
$hookContainer
;
$this
->
name
=
$name
;
}
/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public
function
offsetExists
(
$offset
)
{
return
$this
->
getHandler
(
$offset
)
!==
null
;
}
/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public
function
offsetGet
(
$offset
)
{
$handler
=
$this
->
getHandler
(
$offset
);
if
(
!
$handler
)
{
throw
new
OutOfBoundsException
(
"No such index in the handler list: $offset"
);
}
return
$handler
;
}
/**
* @inheritDoc
*/
#[\ReturnTypeWillChange]
public
function
offsetSet
(
$offset
,
$value
)
{
if
(
$offset
!==
null
)
{
throw
new
InvalidArgumentException
(
'$offset must be null, this array is append only'
);
}
$this
->
hookContainer
->
register
(
$this
->
name
,
$value
);
$this
->
handlers
=
null
;
}
/**
* @inheritDoc
* @return never
*/
#[\ReturnTypeWillChange]
public
function
offsetUnset
(
$offset
)
{
throw
new
LogicException
(
'unset is not supported for hook handler arrays'
);
}
private
function
getHandler
(
$offset
)
{
if
(
$this
->
handlers
===
null
)
{
// NOTE: getHandlerCallbacks() only exists to support this.
// It should be deleted when we no longer need it here.
$this
->
handlers
=
$this
->
hookContainer
->
getHandlerCallbacks
(
$this
->
name
);
}
return
$this
->
handlers
[
$offset
]
??
null
;
}
#[\ReturnTypeWillChange]
public
function
getIterator
()
{
if
(
$this
->
handlers
===
null
)
{
// NOTE: getHandlerCallbacks() only exists to support this.
// It should be deleted when we no longer need it here.
$this
->
handlers
=
$this
->
hookContainer
->
getHandlerCallbacks
(
$this
->
name
);
}
return
new
\ArrayIterator
(
$this
->
handlers
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 4 2026, 17:40 (5 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0b/83/2c72adfe5c2ff35ad3095c4869e6
Default Alt Text
FauxHookHandlerArray.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment