Skip to content
This repository was archived by the owner on Mar 11, 2023. It is now read-only.

Commit 02b7daa

Browse files
committed
Copio configuraciones interesantes
1 parent f2a4b70 commit 02b7daa

File tree

9 files changed

+260
-5
lines changed

9 files changed

+260
-5
lines changed

Diff for: .codeclimate.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
engines:
2+
phpcodesniffer:
3+
enabled: true
4+
config:
5+
file_extensions: "php,inc,lib"
6+
standard: "PSR1,PSR2,Yii2"
7+
ignore_warnings: true
8+
encoding: utf-8
9+
duplication:
10+
enabled: true
11+
config:
12+
languages:
13+
- javascript
14+
- php
15+
eslint:
16+
enabled: true
17+
fixme:
18+
enabled: true
19+
phpmd:
20+
enabled: true
21+
config:
22+
rulesets: "codesize,design,unusedcode,phpmd.xml"
23+
ratings:
24+
paths:
25+
- "**.js"
26+
- "**.php"
27+
exclude_paths:
28+
- views/
29+
- tests/
30+
- docs/
31+
- requirements.php

Diff for: .gitattributes

-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
/.github export-ignore
33
/.gitattributes export-ignore
44
/.scrutinizer.yml export-ignore
5-
/.travis.yml export-ignore
65
/docs export-ignore

Diff for: .gitignore

+8-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ phpunit.phar
2828

2929
tests/_output/*
3030
tests/_support/_generated
31+
tests/chromedriver
3132

3233
#vagrant folder
33-
/.vagrant
34+
/.vagrant
35+
36+
# codesniffer cache
37+
.php_cs.cache
38+
39+
# local environment variables
40+
.env

Diff for: .php_cs.dist

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude(['views', 'tests'])
5+
->in(__DIR__);
6+
7+
return PhpCsFixer\Config::create()
8+
->setUsingCache(true)
9+
->setRiskyAllowed(true)
10+
->setRules([
11+
'@PSR2' => true,
12+
'array_syntax' => [
13+
'syntax' => 'short',
14+
],
15+
'binary_operator_spaces' => [
16+
'align_double_arrow' => false,
17+
'align_equals' => false,
18+
],
19+
'blank_line_after_opening_tag' => true,
20+
'braces' => [
21+
'allow_single_line_closure' => true,
22+
],
23+
'cast_spaces' => true,
24+
'concat_space' => [
25+
'spacing' => 'one',
26+
],
27+
'dir_constant' => true,
28+
'ereg_to_preg' => true,
29+
'function_typehint_space' => true,
30+
'hash_to_slash_comment' => true,
31+
'include' => true,
32+
'heredoc_to_nowdoc' => true,
33+
'is_null' => [
34+
'use_yoda_style' => false,
35+
],
36+
'linebreak_after_opening_tag' => true,
37+
'lowercase_cast' => true,
38+
'magic_constant_casing' => true,
39+
// 'mb_str_functions' => true, // needs more discussion
40+
// 'method_separation' => true, // conflicts with current Yii style with double line between properties and methods
41+
'modernize_types_casting' => true,
42+
'native_function_casing' => true,
43+
'new_with_braces' => true,
44+
'no_alias_functions' => true,
45+
'no_blank_lines_after_class_opening' => true,
46+
'no_blank_lines_after_phpdoc' => true,
47+
'no_empty_comment' => true,
48+
'no_empty_phpdoc' => true,
49+
'no_empty_statement' => true,
50+
'no_extra_consecutive_blank_lines' => [
51+
'tokens' => [
52+
'break',
53+
'continue',
54+
// 'extra', // conflicts with current Yii style with double line between properties and methods
55+
'return',
56+
'throw',
57+
'use',
58+
'use_trait',
59+
// 'curly_brace_block', // breaks namespaces blocks
60+
'parenthesis_brace_block',
61+
'square_brace_block',
62+
],
63+
],
64+
'no_leading_import_slash' => true,
65+
'no_leading_namespace_whitespace' => true,
66+
'no_mixed_echo_print' => true,
67+
'no_multiline_whitespace_around_double_arrow' => true,
68+
'no_multiline_whitespace_before_semicolons' => true,
69+
'no_php4_constructor' => true,
70+
'no_short_bool_cast' => true,
71+
'no_singleline_whitespace_before_semicolons' => true,
72+
'no_spaces_around_offset' => true,
73+
'no_trailing_comma_in_list_call' => true,
74+
'no_trailing_comma_in_singleline_array' => true,
75+
'no_unneeded_control_parentheses' => true,
76+
'no_unused_imports' => true,
77+
'no_useless_else' => true,
78+
'no_useless_return' => true,
79+
'no_whitespace_before_comma_in_array' => true,
80+
'no_whitespace_in_blank_line' => true,
81+
'non_printable_character' => true,
82+
'normalize_index_brace' => true,
83+
'object_operator_without_whitespace' => true,
84+
// 'ordered_class_elements' => [ // needs more discussion
85+
// 'order' => [
86+
// 'use_trait',
87+
// 'constant_public',
88+
// 'constant_protected',
89+
// 'constant_private',
90+
// 'property_public',
91+
// 'property_protected',
92+
// 'property_private',
93+
// 'construct',
94+
// 'destruct',
95+
// 'magic',
96+
// ],
97+
// ],
98+
'ordered_imports' => [
99+
'sortAlgorithm' => 'alpha',
100+
'importsOrder' => [
101+
'const',
102+
'function',
103+
'class',
104+
],
105+
],
106+
'php_unit_construct' => true,
107+
'php_unit_dedicate_assert' => true,
108+
'php_unit_fqcn_annotation' => true,
109+
// 'php_unit_strict' => true, // needs more attention
110+
'phpdoc_add_missing_param_annotation' => true,
111+
'phpdoc_indent' => true,
112+
// 'phpdoc_inline_tag' => true, // see https://github.com/yiisoft/yii2/issues/11635
113+
'phpdoc_no_access' => true,
114+
'phpdoc_no_empty_return' => true,
115+
'phpdoc_no_package' => true,
116+
'phpdoc_no_useless_inheritdoc' => true,
117+
// 'phpdoc_order', // may be useful, but should be configurable: https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/1602
118+
'phpdoc_return_self_reference' => true,
119+
'phpdoc_scalar' => true,
120+
'phpdoc_single_line_var_spacing' => true,
121+
'phpdoc_summary' => true,
122+
// 'phpdoc_to_comment' => true, // breaks phpdoc for define('CONSTANT', $value);
123+
'phpdoc_trim' => true,
124+
'phpdoc_types' => true,
125+
'phpdoc_var_without_name' => true,
126+
'protected_to_private' => true,
127+
'psr4' => true,
128+
'self_accessor' => true,
129+
'short_scalar_cast' => true,
130+
'single_blank_line_before_namespace' => true,
131+
'single_quote' => true,
132+
'standardize_not_equals' => true,
133+
'ternary_operator_spaces' => true,
134+
'trailing_comma_in_multiline_array' => true,
135+
'trim_array_spaces' => true,
136+
'unary_operator_spaces' => true,
137+
'whitespace_after_comma_in_array' => true,
138+
])
139+
->setFinder($finder);

Diff for: codeception.yml

+9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ modules:
1313
Yii2:
1414
configFile: 'config/test.php'
1515
cleanup: false
16+
enabled:
17+
- Db:
18+
dsn: 'pgsql:host=localhost;dbname=plantilla_test'
19+
user: 'plantilla'
20+
password: 'plantilla'
21+
dump: 'tests/_data/plantilla.sql'
22+
populate: true ## run populator before all tests
23+
cleanup: true ## run populator before each test
24+
populator: 'psql -U $user -h $host -d $dbname < $dump'
1625

1726
# To enable code coverage:
1827
#coverage:

Diff for: phpcs.xml.dist

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Proyecto">
3+
<description>Configuración para proyectos.</description>
4+
5+
<file>.</file>
6+
7+
<exclude-pattern>requirements.php</exclude-pattern>
8+
<exclude-pattern>vendor/*</exclude-pattern>
9+
<exclude-pattern>views/*</exclude-pattern>
10+
<exclude-pattern>tests/*</exclude-pattern>
11+
<exclude-pattern>docs/*</exclude-pattern>
12+
<exclude-pattern>guia/*</exclude-pattern>
13+
<exclude-pattern>web/assets/*</exclude-pattern>
14+
15+
<rule ref="vendor/yiisoft/yii2-coding-standards/Yii2"/>
16+
</ruleset>

Diff for: phpmd.xml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="PHPMD rule set for Yii 2" xmlns="http://pmd.sf.net/ruleset/1.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
5+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
6+
<description>Custom PHPMD settings for naming, cleancode and controversial rulesets</description>
7+
8+
<rule ref="rulesets/naming.xml">
9+
<exclude name="ShortVariable" />
10+
</rule>
11+
12+
<rule ref="rulesets/naming.xml/ShortVariable">
13+
<properties>
14+
<property name="minimum" value="2" />
15+
</properties>
16+
</rule>
17+
18+
<rule ref="rulesets/design.xml" />
19+
<rule ref="rulesets/unusedcode.xml" />
20+
21+
<rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass" />
22+
<rule ref="rulesets/naming.xml/ConstantNamingConventions" />
23+
<!-- Long variable names can help with better understanding so we increase the limit a bit -->
24+
<rule ref="rulesets/naming.xml/LongVariable">
25+
<properties>
26+
<property name="maximum" value="25" />
27+
</properties>
28+
</rule>
29+
<!-- method names like up(), gc(), ... are okay. -->
30+
<rule ref="rulesets/naming.xml/ShortMethodName">
31+
<properties>
32+
<property name="minimum" value="2" />
33+
</properties>
34+
</rule>
35+
36+
<rule ref="rulesets/cleancode.xml">
37+
<!-- else is not always bad. Disabling this as there is no way to differentiate between early return and normal else cases. -->
38+
<exclude name="ElseExpression" />
39+
<!-- Static access on Yii::$app is normal in Yii -->
40+
<exclude name="StaticAccess" />
41+
</rule>
42+
43+
<rule ref="rulesets/controversial.xml/Superglobals" />
44+
<rule ref="rulesets/controversial.xml/CamelCaseClassName" />
45+
<rule ref="rulesets/controversial.xml/CamelCaseMethodName" />
46+
<rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
47+
<rule ref="rulesets/controversial.xml/CamelCaseVariableName" />
48+
<!-- allow private properties to start with $_ -->
49+
<rule ref="rulesets/controversial.xml/CamelCasePropertyName">
50+
<properties>
51+
<property name="allow-underscore" value="true" />
52+
</properties>
53+
</rule>
54+
</ruleset>

Diff for: views/layouts/main.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<meta charset="<?= Yii::$app->charset ?>">
2020
<meta http-equiv="X-UA-Compatible" content="IE=edge">
2121
<meta name="viewport" content="width=device-width, initial-scale=1">
22-
<?php $this->registerCsrfMetaTags() ?>
22+
<?= Html::csrfMetaTags() ?>
2323
<title><?= Html::encode($this->title) ?></title>
2424
<?php $this->head() ?>
2525
</head>

Diff for: yii

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* @license http://www.yiiframework.com/license/
99
*/
1010

11-
defined('YII_DEBUG') or define('YII_DEBUG', true);
12-
defined('YII_ENV') or define('YII_ENV', 'dev');
11+
define('YII_ENV', getenv('YII_ENV') ?: 'dev');
12+
define('YII_DEBUG', getenv('YII_DEBUG') ?: YII_ENV == 'dev');
1313

1414
require __DIR__ . '/vendor/autoload.php';
1515
require __DIR__ . '/vendor/yiisoft/yii2/Yii.php';

0 commit comments

Comments
 (0)