Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
5976d1c5
Commit
5976d1c5
authored
Jul 29, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added property spacing to code style fixer
parent
1c414caa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
0 deletions
+108
-0
PhpDocController.php
build/controllers/PhpDocController.php
+108
-0
No files found.
build/controllers/PhpDocController.php
View file @
5976d1c5
...
...
@@ -85,6 +85,7 @@ class PhpDocController extends Controller
$this
->
fixFileDoc
(
$lines
);
$this
->
fixDocBlockIndentation
(
$lines
);
$lines
=
array_values
(
$this
->
fixLineSpacing
(
$lines
));
$newContent
=
implode
(
"
\n
"
,
$lines
);
if
(
$sha
!==
sha1
(
$newContent
))
{
...
...
@@ -163,6 +164,9 @@ class PhpDocController extends Controller
return
FileHelper
::
findFiles
(
$root
,
$options
);
}
/**
* Fix file PHPdoc
*/
protected
function
fixFileDoc
(
&
$lines
)
{
// find namespace
...
...
@@ -257,6 +261,110 @@ class PhpDocController extends Controller
}
}
/**
* Fixes line spacing code style for properties and constants
*/
protected
function
fixLineSpacing
(
$lines
)
{
$propertiesOnly
=
false
;
// remove blank lines between properties
$skip
=
true
;
foreach
(
$lines
as
$i
=>
$line
)
{
if
(
strpos
(
$line
,
'class '
)
!==
false
)
{
$skip
=
false
;
}
if
(
$skip
)
{
continue
;
}
if
(
trim
(
$line
)
===
''
)
{
unset
(
$lines
[
$i
]);
}
elseif
(
ltrim
(
$line
)[
0
]
!==
'*'
&&
strpos
(
$line
,
'function'
)
!==
false
)
{
break
;
}
elseif
(
trim
(
$line
)
===
'}'
)
{
$propertiesOnly
=
true
;
break
;
}
}
$lines
=
array_values
(
$lines
);
// add back some
$endofUse
=
false
;
$endofConst
=
false
;
$endofPublic
=
false
;
$endofProtected
=
false
;
$endofPrivate
=
false
;
$skip
=
true
;
$level
=
0
;
// track array properties
$property
=
''
;
foreach
(
$lines
as
$i
=>
$line
)
{
if
(
strpos
(
$line
,
'class '
)
!==
false
)
{
$skip
=
false
;
}
if
(
$skip
)
{
continue
;
}
if
(
$level
>
0
)
{
$
{
'endof'
.
$property
}
=
$i
;
$level
-=
substr_count
(
$line
,
']'
);
}
if
(
strncmp
(
trim
(
$line
),
'public $'
,
8
)
===
0
||
strncmp
(
trim
(
$line
),
'public static $'
,
15
)
===
0
)
{
$endofPublic
=
$i
;
$property
=
'Public'
;
}
elseif
(
strncmp
(
trim
(
$line
),
'protected $'
,
11
)
===
0
||
strncmp
(
trim
(
$line
),
'protected static $'
,
18
)
===
0
)
{
$endofProtected
=
$i
;
$property
=
'Protected'
;
}
elseif
(
strncmp
(
trim
(
$line
),
'private $'
,
9
)
===
0
||
strncmp
(
trim
(
$line
),
'private static $'
,
16
)
===
0
)
{
$endofPrivate
=
$i
;
$property
=
'Private'
;
}
elseif
(
substr
(
trim
(
$line
),
0
,
6
)
===
'const '
)
{
$endofConst
=
$i
;
$property
=
false
;
}
elseif
(
substr
(
trim
(
$line
),
0
,
4
)
===
'use '
)
{
$endofUse
=
$i
;
$property
=
false
;
}
elseif
(
ltrim
(
$line
)[
0
]
===
'*'
)
{
$property
=
false
;
}
elseif
(
ltrim
(
$line
)[
0
]
!==
'*'
&&
strpos
(
$line
,
'function'
)
!==
false
||
trim
(
$line
)
===
'}'
)
{
break
;
}
// check for multi line array
if
(
$property
!==
false
)
{
$level
+=
substr_count
(
$line
,
'['
)
-
substr_count
(
$line
,
']'
);
}
}
$endofAll
=
false
;
foreach
([
'Private'
,
'Protected'
,
'Public'
,
'Const'
,
'Use'
]
as
$var
)
{
if
(
$
{
'endof'
.
$var
}
!==
false
)
{
$endofAll
=
$
{
'endof'
.
$var
};
break
;
}
}
// $this->checkPropertyOrder($lineInfo);
$result
=
[];
foreach
(
$lines
as
$i
=>
$line
)
{
$result
[]
=
$line
;
if
(
!
(
$propertiesOnly
&&
$i
===
$endofAll
))
{
if
(
$i
===
$endofUse
||
$i
===
$endofConst
||
$i
===
$endofPublic
||
$i
===
$endofProtected
||
$i
===
$endofPrivate
)
{
$result
[]
=
''
;
}
if
(
$i
===
$endofAll
)
{
$result
[]
=
''
;
}
}
}
return
$result
;
}
protected
function
checkPropertyOrder
(
$lineInfo
)
{
// TODO
}
protected
function
updateClassPropertyDocs
(
$file
,
$className
,
$propertyDoc
)
{
$ref
=
new
\ReflectionClass
(
$className
);
...
...
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