Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
plantuml-bundle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Pôle IS
Bundles Symfony 2
plantuml-bundle
Commits
3fe87e8e
Commit
3fe87e8e
authored
Jul 04, 2019
by
Guillaume Perréal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CS et correction d'un bug dans les filters.
parent
6b09c22c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
18 deletions
+81
-18
src/Model/Filter/AbstractListFilter.php
src/Model/Filter/AbstractListFilter.php
+18
-7
src/Model/Filter/ClassFilter.php
src/Model/Filter/ClassFilter.php
+15
-3
src/Model/Filter/DirectoryFilter.php
src/Model/Filter/DirectoryFilter.php
+22
-3
src/Model/Filter/NamespaceFilter.php
src/Model/Filter/NamespaceFilter.php
+12
-3
src/Model/Graph.php
src/Model/Graph.php
+14
-2
No files found.
src/Model/Filter/AbstractListFilter.php
View file @
3fe87e8e
...
@@ -34,16 +34,25 @@ abstract class AbstractListFilter implements ClassFilterInterface
...
@@ -34,16 +34,25 @@ abstract class AbstractListFilter implements ClassFilterInterface
private
$allowed
=
[];
private
$allowed
=
[];
/**
/**
* @var bool
ena
* @var bool
*/
*/
private
$notFound
;
private
$notFound
;
/**
* AbstractListFilter constructor.
* @param array $allowed
* @param bool $notFound
*/
public
function
__construct
(
array
$allowed
,
$notFound
=
false
)
public
function
__construct
(
array
$allowed
,
$notFound
=
false
)
{
{
$this
->
allowed
=
array_map
([
$this
,
'normalize'
],
$allowed
);
$this
->
allowed
=
array_map
([
$this
,
'normalize'
],
$allowed
);
$this
->
notFound
=
$notFound
;
$this
->
notFound
=
$notFound
;
}
}
/**
* @param ReflectionClass $class
* @return bool
*/
public
function
accept
(
ReflectionClass
$class
)
public
function
accept
(
ReflectionClass
$class
)
{
{
$tested
=
$this
->
normalize
(
$this
->
extract
(
$class
));
$tested
=
$this
->
normalize
(
$this
->
extract
(
$class
));
...
@@ -56,6 +65,9 @@ abstract class AbstractListFilter implements ClassFilterInterface
...
@@ -56,6 +65,9 @@ abstract class AbstractListFilter implements ClassFilterInterface
return
$this
->
notFound
;
return
$this
->
notFound
;
}
}
/**
* @param array $conf
*/
public
function
toConfig
(
array
&
$conf
)
public
function
toConfig
(
array
&
$conf
)
{
{
$key
=
$this
->
notFound
?
'exclude'
:
'include'
;
$key
=
$this
->
notFound
?
'exclude'
:
'include'
;
...
@@ -70,21 +82,20 @@ abstract class AbstractListFilter implements ClassFilterInterface
...
@@ -70,21 +82,20 @@ abstract class AbstractListFilter implements ClassFilterInterface
*
*
* @return string
* @return string
*/
*/
abstract
protected
function
normalize
(
$value
);
abstract
protected
function
normalize
(
$value
)
:
string
;
/**
/**
* @param ReflectionClass $class
* @param ReflectionClass $class
*
*
* @return string
* @return string
*/
*/
abstract
protected
function
extract
(
ReflectionClass
$class
);
abstract
protected
function
extract
(
ReflectionClass
$class
)
:
string
;
/**
/**
* @param string $value
* @param mixed $tested
* @param mixed $tested
* @param mixed $reference
* @param mixed $reference
*
*
* @return bool
* @return bool
*/
*/
abstract
protected
function
matches
(
$tested
,
$reference
);
abstract
protected
function
matches
(
$tested
,
$reference
)
:
bool
;
}
}
src/Model/Filter/ClassFilter.php
View file @
3fe87e8e
...
@@ -27,19 +27,31 @@ use ReflectionClass;
...
@@ -27,19 +27,31 @@ use ReflectionClass;
*/
*/
class
ClassFilter
extends
AbstractListFilter
class
ClassFilter
extends
AbstractListFilter
{
{
/**
* @var string
*/
public
const
CONF_TYPE
=
'classes'
;
public
const
CONF_TYPE
=
'classes'
;
protected
function
extract
(
ReflectionClass
$class
)
/**
* {@inheritDoc}
*/
protected
function
extract
(
ReflectionClass
$class
):
string
{
{
return
$class
->
getName
();
return
$class
->
getName
();
}
}
protected
function
matches
(
$tested
,
$reference
)
/**
* {@inheritDoc}
*/
protected
function
matches
(
$tested
,
$reference
):
bool
{
{
return
$tested
===
$reference
;
return
$tested
===
$reference
;
}
}
protected
function
normalize
(
$className
)
/**
* {@inheritDoc}
*/
protected
function
normalize
(
$className
):
string
{
{
return
trim
(
$className
,
'\\'
);
return
trim
(
$className
,
'\\'
);
}
}
...
...
src/Model/Filter/DirectoryFilter.php
View file @
3fe87e8e
...
@@ -27,19 +27,38 @@ use ReflectionClass;
...
@@ -27,19 +27,38 @@ use ReflectionClass;
*/
*/
class
DirectoryFilter
extends
AbstractListFilter
class
DirectoryFilter
extends
AbstractListFilter
{
{
/**
* @var string
*/
public
const
CONF_TYPE
=
'directories'
;
public
const
CONF_TYPE
=
'directories'
;
protected
function
extract
(
ReflectionClass
$class
)
/**
* {@inheritDoc}
*/
protected
function
extract
(
ReflectionClass
$class
):
string
{
{
$filename
=
$class
->
getFileName
();
if
(
$filename
===
false
)
{
return
''
;
}
return
dirname
(
$class
->
getFileName
());
return
dirname
(
$class
->
getFileName
());
}
}
protected
function
matches
(
$tested
,
$reference
)
/**
* @param mixed $tested
* @param mixed $reference
* @return bool
*/
protected
function
matches
(
$tested
,
$reference
):
bool
{
{
return
strpos
(
$tested
,
$reference
)
===
0
;
return
strpos
(
$tested
,
$reference
)
===
0
;
}
}
protected
function
normalize
(
$path
)
/**
* @param string $path
* @return string
*/
protected
function
normalize
(
$path
):
string
{
{
return
rtrim
(
strtr
(
$path
,
'/\\'
,
DIRECTORY_SEPARATOR
),
DIRECTORY_SEPARATOR
)
.
DIRECTORY_SEPARATOR
;
return
rtrim
(
strtr
(
$path
,
'/\\'
,
DIRECTORY_SEPARATOR
),
DIRECTORY_SEPARATOR
)
.
DIRECTORY_SEPARATOR
;
}
}
...
...
src/Model/Filter/NamespaceFilter.php
View file @
3fe87e8e
...
@@ -29,17 +29,26 @@ class NamespaceFilter extends AbstractListFilter
...
@@ -29,17 +29,26 @@ class NamespaceFilter extends AbstractListFilter
{
{
public
const
CONF_TYPE
=
'namespaces'
;
public
const
CONF_TYPE
=
'namespaces'
;
protected
function
extract
(
ReflectionClass
$class
)
/**
* {@inheritDoc}
*/
protected
function
extract
(
ReflectionClass
$class
):
string
{
{
return
$class
->
getNamespaceName
();
return
$class
->
getNamespaceName
();
}
}
protected
function
matches
(
$tested
,
$reference
)
/**
* {@inheritDoc}
*/
protected
function
matches
(
$tested
,
$reference
):
bool
{
{
return
strpos
(
$tested
,
$reference
)
===
0
;
return
strpos
(
$tested
,
$reference
)
===
0
;
}
}
protected
function
normalize
(
$namespace
)
/**
* {@inheritDoc}
*/
protected
function
normalize
(
$namespace
):
string
{
{
return
trim
(
$namespace
,
'\\'
)
.
'\\'
;
return
trim
(
$namespace
,
'\\'
)
.
'\\'
;
}
}
...
...
src/Model/Graph.php
View file @
3fe87e8e
...
@@ -38,20 +38,32 @@ class Graph implements GraphInterface
...
@@ -38,20 +38,32 @@ class Graph implements GraphInterface
*/
*/
private
$finder
;
private
$finder
;
/**
* Graph constructor.
* @param ClassVisitorInterface $visitor
* @param FinderInterface $finder
*/
public
function
__construct
(
ClassVisitorInterface
$visitor
,
FinderInterface
$finder
)
public
function
__construct
(
ClassVisitorInterface
$visitor
,
FinderInterface
$finder
)
{
{
$this
->
visitor
=
$visitor
;
$this
->
visitor
=
$visitor
;
$this
->
finder
=
$finder
;
$this
->
finder
=
$finder
;
}
}
public
function
visitAll
()
/**
*
*/
public
function
visitAll
():
void
{
{
foreach
(
$this
->
finder
->
getIterator
()
as
$class
)
{
foreach
(
$this
->
finder
->
getIterator
()
as
$class
)
{
$this
->
visitor
->
visitClass
(
$class
);
$this
->
visitor
->
visitClass
(
$class
);
}
}
}
}
public
function
writeTo
(
WriterInterface
$writer
)
/**
* @param WriterInterface $writer
* @return $this
*/
public
function
writeTo
(
WriterInterface
$writer
):
self
{
{
$writer
->
write
(
"@startuml@
\n
"
);
$writer
->
write
(
"@startuml@
\n
"
);
$this
->
visitor
->
writeTo
(
$writer
);
$this
->
visitor
->
writeTo
(
$writer
);
...
...
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