Skip to content

A free open source IT asset/license management system

Added PHP_CS & PHPMD files (#6234)

Wes Hulette82affd515433
diff --git a/.php_cs.dist b/.php_cs.dist
new file mode 100644
index 0000000000..87846540f9
--- /dev/null
+++ b/.php_cs.dist
@@ -0,0 +1,39 @@
+<?php
+
+ini_set('memory_limit', '1024M');
+
+$finder = PhpCsFixer\Finder::create()
+ ->notPath('bootstrap/cache')
+ ->notPath('storage')
+ ->notPath('vendor')
+ ->notPath('node_modules')
+ ->in(__DIR__)
+ ->name('*.php')
+ ->notName('*.blade.php')
+ ->ignoreDotFiles(true)
+ ->ignoreVCS(true)
+;
+
+return PhpCsFixer\Config::create()
+ ->setRules(array(
+ '@Symfony' => true,
+ 'class_definition' => [
+ 'multiLineExtendsEachSingleLine' => true,
+ ],
+ 'ordered_class_elements' => [
+ 'use_trait', 'constant_public', 'constant_protected', 'constant_private',
+ 'property_public', 'property_protected', 'property_private', 'construct',
+ 'destruct', 'magic', 'phpunit', 'method_public', 'method_protected',
+ 'method_private'
+ ],
+ 'function_declaration' => ['closure_function_spacing' => 'none'],
+ 'binary_operator_spaces' => ['default' => 'align_single_space_minimal'],
+ 'array_syntax' => ['syntax' => 'short'],
+ 'concat_space' => ['spacing' => 'one'],
+ 'blank_line_after_namespace' => true,
+ 'linebreak_after_opening_tag' => true,
+ 'not_operator_with_successor_space' => true,
+ 'ordered_imports' => true,
+ 'phpdoc_order' => true,
+ ))
+ ->setFinder($finder);
diff --git a/phpmd.xml b/phpmd.xml
new file mode 100644
index 0000000000..d991b90fbb
--- /dev/null
+++ b/phpmd.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset name="Laravel and similar phpmd ruleset"
+ xmlns="http://pmd.sf.net/ruleset/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
+ xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
+ <description>
+ Inspired by https://github.com/phpmd/phpmd/issues/137
+ using http://phpmd.org/documentation/creating-a-ruleset.html
+ </description>
+ <!-- se importan los rulesets, en este caso todos. -->
+ <rule ref="rulesets/cleancode.xml">
+ <exclude name="StaticAccess"/>
+ </rule>
+ <rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>
+ <rule ref="rulesets/codesize.xml/NPathComplexity"/>
+ <rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>
+ <rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>
+ <rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>
+ <rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>
+ <rule ref="rulesets/codesize.xml/TooManyFields"/>
+ <rule ref="rulesets/codesize.xml/TooManyMethods">
+ <properties>
+ <property name="maxmethods" value="30"/>
+ </properties>
+ </rule>
+ <rule ref="rulesets/codesize.xml/ExcessiveClassComplexity"/>
+ <rule ref="rulesets/controversial.xml"/>
+ <rule ref="rulesets/design.xml">
+ <exclude name="CouplingBetweenObjects"/>
+ </rule>
+ <!-- beware the façades yo. -->
+ <rule ref="rulesets/design.xml/CouplingBetweenObjects">
+ <properties>
+ <property name="minimum" value="20"/>
+ </properties>
+ </rule>
+ <!-- se importa naming y se excluye ShortVariable para ser ajustada despues. -->
+ <rule ref="rulesets/naming.xml">
+ <exclude name="ShortVariable"/>
+ </rule>
+ <rule ref="rulesets/naming.xml/ShortVariable"
+ since="0.2"
+ message="Avoid variables with short names like {0}. Configured minimum length is {1}."
+ class="PHPMD\Rule\Naming\ShortVariable"
+ externalInfoUrl="http://phpmd.org/rules/naming.html#shortvariable">
+ <priority>3</priority>
+ <properties>
+ <property name="minimum" description="Minimum length for a variable, property or parameter name" value="3"/>
+ <property name="exceptions" value="id,q,w,i,j,v,e,f,fp" />
+ </properties>
+ </rule>
+ <rule ref="rulesets/unusedcode.xml"/>
+</ruleset>
\ No newline at end of file