Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1433070
MethodFactory.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
MethodFactory.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
phpDocumentor\Reflection\DocBlock\Tags\Factory
;
use
phpDocumentor\Reflection\DocBlock\DescriptionFactory
;
use
phpDocumentor\Reflection\DocBlock\Tag
;
use
phpDocumentor\Reflection\DocBlock\Tags\Method
;
use
phpDocumentor\Reflection\DocBlock\Tags\MethodParameter
;
use
phpDocumentor\Reflection\Type
;
use
phpDocumentor\Reflection\TypeResolver
;
use
phpDocumentor\Reflection\Types\Context
;
use
phpDocumentor\Reflection\Types\Mixed_
;
use
phpDocumentor\Reflection\Types\Void_
;
use
PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode
;
use
PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueParameterNode
;
use
PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode
;
use
Webmozart\Assert\Assert
;
use
function
array_map
;
use
function
trim
;
/**
* @internal This class is not part of the BC promise of this library.
*/
final
class
MethodFactory
implements
PHPStanFactory
{
private
DescriptionFactory
$descriptionFactory
;
private
TypeResolver
$typeResolver
;
public
function
__construct
(
TypeResolver
$typeResolver
,
DescriptionFactory
$descriptionFactory
)
{
$this
->
descriptionFactory
=
$descriptionFactory
;
$this
->
typeResolver
=
$typeResolver
;
}
public
function
create
(
PhpDocTagNode
$node
,
Context
$context
):
Tag
{
$tagValue
=
$node
->
value
;
Assert
::
isInstanceOf
(
$tagValue
,
MethodTagValueNode
::
class
);
return
new
Method
(
$tagValue
->
methodName
,
[],
$this
->
createReturnType
(
$tagValue
,
$context
),
$tagValue
->
isStatic
,
$this
->
descriptionFactory
->
create
(
$tagValue
->
description
,
$context
),
false
,
array_map
(
function
(
MethodTagValueParameterNode
$param
)
use
(
$context
)
{
return
new
MethodParameter
(
trim
(
$param
->
parameterName
,
'$'
),
$param
->
type
===
null
?
new
Mixed_
()
:
$this
->
typeResolver
->
createType
(
$param
->
type
,
$context
),
$param
->
isReference
,
$param
->
isVariadic
,
$param
->
defaultValue
===
null
?
MethodParameter
::
NO_DEFAULT_VALUE
:
(
string
)
$param
->
defaultValue
);
},
$tagValue
->
parameters
),
);
}
public
function
supports
(
PhpDocTagNode
$node
,
Context
$context
):
bool
{
return
$node
->
value
instanceof
MethodTagValueNode
;
}
private
function
createReturnType
(
MethodTagValueNode
$tagValue
,
Context
$context
):
Type
{
if
(
$tagValue
->
returnType
===
null
)
{
return
new
Void_
();
}
return
$this
->
typeResolver
->
createType
(
$tagValue
->
returnType
,
$context
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 22:37 (1 h, 58 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
7d/ad/ef99ea87454bae7137d026cb671c
Default Alt Text
MethodFactory.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment