Skip to content

Commit

Permalink
added php cs fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaRainone committed May 15, 2022
1 parent c3be3fe commit cbdd20c
Show file tree
Hide file tree
Showing 45 changed files with 3,167 additions and 649 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
vendor
composer.phar
builds
builds
.php-cs-fixer.cache
24 changes: 24 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()
->ignoreDotFiles(false)
->ignoreVCSIgnored(true)
->in(__DIR__)
->exclude('vendor')
;

$config = new PhpCsFixer\Config();
$config
->setFinder($finder)
->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'strict_param' => true,
'array_syntax' => ['syntax' => 'short'],
])

;

return $config;
42 changes: 21 additions & 21 deletions autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
// from https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
spl_autoload_register(function ($class) {

// project-specific namespace prefix
$prefix = 'rain1\\ConditionBuilder\\';
// project-specific namespace prefix
$prefix = 'rain1\\ConditionBuilder\\';

// base directory for the namespace prefix
$base_dir = __DIR__ . '/src/';
// base directory for the namespace prefix
$base_dir = __DIR__ . '/src/';

// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
return;
}
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
return;
}

// get the relative class name
$relative_class = substr($class, $len);
// get the relative class name
$relative_class = substr($class, $len);

// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';

// if the file exists, require it
if (file_exists($file)) {
require $file;
}
});
// if the file exists, require it
if (file_exists($file)) {
require $file;
}
});
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
]
},
"require" : {
"php" : ">= 7.0"
"php" : ">= 7.4",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^6.5",
"satooshi/php-coveralls": "^2.0"
},
"scripts": {
"cs" : "tools/php-cs-fixer/vendor/bin/php-cs-fixer fix"
}
}
Loading

0 comments on commit cbdd20c

Please sign in to comment.