Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pôle IS
Bundles Symfony 2
plantuml-bundle
Commits
c89ed3ec
Commit
c89ed3ec
authored
Mar 11, 2016
by
Guillaume Perréal
Browse files
N'affiche pas les accesseurs.
parent
f7cf7bc6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Model/Decorator/MethodDecorator.php
View file @
c89ed3ec
...
...
@@ -28,7 +28,7 @@ class MethodDecorator implements DecoratorInterface
foreach
(
$class
->
getMethods
()
as
$method
)
{
/* @var $method ReflectionMethod */
if
(
$method
->
getDeclaringClass
()
!=
$class
)
{
if
(
$method
->
getDeclaringClass
()
!=
$class
||
$this
->
isAccessor
(
$method
,
$class
)
)
{
continue
;
}
...
...
@@ -44,4 +44,28 @@ class MethodDecorator implements DecoratorInterface
);
}
}
/**
* @param ReflectionMethod $method
* @param ReflectionClass $class
* @return boolean
*/
protected
function
isAccessor
(
ReflectionMethod
$method
,
ReflectionClass
$class
)
{
if
(
!
$method
->
isPublic
()
||
$method
->
isAbstract
()
||
$method
->
getDeclaringClass
()
->
isInterface
())
{
return
false
;
}
if
(
$method
->
getNumberOfParameters
()
===
0
&&
preg_match
(
'/(?:get|is)(\w+)/'
,
$method
->
getName
(),
$groups
))
{
$name
=
lcfirst
(
$groups
[
1
]);
}
elseif
(
$method
->
getNumberOfParameters
()
===
1
&&
preg_match
(
'/(?:set|add|remove)(\w+)/'
,
$method
->
getName
(),
$groups
))
{
$name
=
lcfirst
(
$groups
[
1
]);
}
else
{
return
false
;
}
if
(
!
$class
->
hasProperty
(
$name
))
{
return
false
;
}
$property
=
$class
->
getProperty
(
$name
);
return
$property
->
isStatic
()
==
$method
->
isStatic
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment