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
file-upload-bundle
Commits
9f8a8c4b
Commit
9f8a8c4b
authored
Jul 26, 2018
by
Guillaume Perréal
Browse files
Conserve une copie propre de .php_cs.dist.
parent
459488b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
.php_cs.dist
deleted
120000 → 0
View file @
459488b7
devtools/php/php_cs.dist
\ No newline at end of file
.php_cs.dist
0 → 100644
View file @
9f8a8c4b
<?php
define
(
'COMMIT_CACHE'
,
'.php_cs.commit-cache'
);
$finder
=
PhpCsFixer\Finder
::
create
()
->
exclude
(
'vendor'
)
->
exclude
(
'node_modules'
)
->
exclude
(
'cache'
)
->
files
()
->
name
(
'*.php'
)
->
in
(
'.'
);
$yearRange
=
getGitCommitYears
();
$ruleSets
=
[
'@PSR2'
=>
true
,
'@Symfony'
=>
true
];
$rules
=
[
// Configuration && overrides
'binary_operator_spaces'
=>
[
'align_double_arrow'
=>
true
],
'blank_line_after_opening_tag'
=>
false
,
'concat_space'
=>
[
'spacing'
=>
'one'
],
'method_argument_space'
=>
[
'ensure_fully_multiline'
=>
true
],
// Risky
'is_null'
=>
[
'use_yoda_style'
=>
false
],
'non_printable_character'
=>
[
'use_escape_sequences_in_strings'
=>
true
],
// Safe
'align_multiline_comment'
=>
true
,
'array_syntax'
=>
[
'syntax'
=>
'short'
],
'general_phpdoc_annotation_remove'
=>
[
'annotations'
=>
[
'author'
,
'package'
]],
'no_multiline_whitespace_before_semicolons'
=>
true
,
'no_useless_else'
=>
true
,
'no_useless_return'
=>
true
,
'ordered_imports'
=>
true
,
'phpdoc_add_missing_param_annotation'
=>
true
,
'phpdoc_annotation_without_dot'
=>
true
,
'phpdoc_order'
=>
true
,
'semicolon_after_instruction'
=>
true
,
'yoda_style'
=>
false
,
'self_accessor'
=>
false
,
'header_comment'
=>
[
'commentType'
=>
'comment'
,
'location'
=>
'after_declare_strict'
,
'separate'
=>
'bottom'
,
'header'
=>
<<<HEADER
irstea/file-upload-bundle provides services and widgets to manage user-submitted files.
Copyright (C) $yearRange IRSTEA
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License and the GNU
Lesser General Public License along with this program. If not, see
<https://www.gnu.org/licenses/>.
HEADER
,
],
];
$phpVersion
=
findComposerPhpReq
();
if
(
$phpVersion
>=
5.6
)
{
$ruleSets
[
'@PHP56Migration'
]
=
true
;
}
if
(
$phpVersion
>=
7.0
)
{
$ruleSets
[
'@PHP70Migration'
]
=
true
;
$rules
[
'declare_strict_types'
]
=
true
;
}
if
(
$phpVersion
>=
7.1
)
{
$ruleSets
[
'@PHP71Migration'
]
=
true
;
}
echo
"Rulesets: "
.
implode
(
', '
,
array_keys
(
$ruleSets
))
.
".
\n
"
;
return
PhpCsFixer\Config
::
create
()
->
setRiskyAllowed
(
true
)
->
setUsingCache
(
false
)
->
setIndent
(
' '
)
->
setLineEnding
(
"
\n
"
)
->
setRules
(
array_merge
(
$ruleSets
,
$rules
))
->
setFinder
(
$finder
);
/**
* @return string
*/
function
getGitCommitYears
():
string
{
return
getCachedValue
(
'years'
,
function
()
{
echo
"Examining git history...
\n
"
;
$last
=
date
(
'Y'
);
$first
=
exec
(
'git log --format=%cd --date=format:%Y --date-order | tail -n1'
)
??
$last
;
return
(
null
!==
$last
&&
$last
!==
$first
)
?
"
$first
-
$last
"
:
$first
;
});
}
/**
* @return float
*/
function
findComposerPhpReq
()
{
return
getCachedValue
(
'php-req'
,
function
()
{
if
(
file_exists
(
'composer.json'
))
{
$data
=
json_decode
(
file_get_contents
(
'composer.json'
),
true
);
if
(
is_array
(
$data
)
&&
isset
(
$data
[
'require'
][
'php'
]))
{
if
(
preg_match
(
'/(?:>=?|\^|~)\s*([57]\.[0-9])/'
,
$data
[
'require'
][
'php'
],
$groups
))
{
return
(
float
)
$groups
[
1
];
}
}
}
return
5.6
;
});
}
/**
* @param string $key
* @param callable $produce
*
* @return string|int|bool|array
*/
function
getCachedValue
(
$key
,
$produce
)
{
static
$commit
=
null
;
if
(
null
===
$commit
)
{
$commit
=
trim
(
`git rev-parse HEAD`
);
}
if
(
file_exists
(
COMMIT_CACHE
)
&&
filemtime
(
COMMIT_CACHE
)
>=
filemtime
(
__FILE__
))
{
$cache
=
json_decode
(
file_get_contents
(
COMMIT_CACHE
),
true
);
}
else
{
$cache
=
[];
}
if
(
!
isset
(
$cache
[
$commit
][
$key
]))
{
if
(
!
isset
(
$cache
[
$commit
]))
{
$cache
[
$commit
]
=
[];
}
$cache
[
$commit
][
$key
]
=
$produce
();
file_put_contents
(
COMMIT_CACHE
,
json_encode
(
$cache
));
}
return
$cache
[
$commit
][
$key
];
}
// vim:filetype=php
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