PHP code example of grafema-team / grafema-phpcs
1. Go to this page and download the library: Download grafema-team/grafema-phpcs library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
grafema-team / grafema-phpcs example snippets
$header = <<<'EOF'
This file is part of Grafema Projects.
EOF;
return (new PhpCsFixer\Config())
->setRiskyAllowed( true )
->registerCustomFixers( [
new GrafemaPHPCS\Fixer\SpaceInsideParenthesisFixer(),
] )
->setRules( [
'@DoctrineAnnotation' => true,
'@PSR2' => true,
'@PhpCsFixer' => true,
'@Symfony' => true,
'GrafemaPHPCS/space_inside_parenthesis' => true,
'align_multiline_comment' => true,
'array_syntax' => [
'syntax' => 'short',
],
'binary_operator_spaces' => [
'operators' => [
'=>' => 'align_single_space_minimal',
'=' => 'align_single_space_minimal',
],
],
'blank_line_before_statement' => [
'statements' => [
'declare',
'return',
'try',
'while',
'for',
'foreach',
'do',
],
],
'class_attributes_separation' => true,
'combine_consecutive_unsets' => true,
'concat_space' => [
'spacing' => 'one',
],
'constant_case' => [
'case' => 'lower',
],
'general_phpdoc_annotation_remove' => [
'annotations' => [
'author',
],
],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
'header_comment' => [
'comment_type' => 'PHPDoc',
'header' => $header,
'separate' => 'none',
'location' => 'after_declare_strict',
],
'linebreak_after_opening_tag' => true,
'list_syntax' => [
'syntax' => 'short',
],
'lowercase_static_reference' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line',
],
'no_unused_imports' => true,
'no_useless_else' => true,
'not_operator_with_successor_space' => true,
'ordered_class_elements' => true,
'ordered_imports' => [
'imports_order' => [
'class',
'function',
'const',
],
'sort_algorithm' => 'alpha',
],
'phpdoc_align' => [
'align' => 'vertical',
],
'phpdoc_no_alias_tag' => true,
'phpdoc_separation' => true,
'single_line_comment_style' => [
'comment_types' => [],
],
'single_quote' => true,
'standardize_not_equals' => true,
'yoda_style' => [
'always_move_variable' => false,
'equal' => false,
'identical' => false,
],
] )
->setIndent( ' ' )
->setFinder(
PhpCsFixer\Finder::create()
->exclude( 'documentation' )
->exclude( 'vendor' )
->exclude( 'src' )
->in( __DIR__ )
)
->setUsingCache( false );