Skip to content

Commit

Permalink
Merge branch 'master' into stellr
Browse files Browse the repository at this point in the history
  • Loading branch information
pprkut committed Sep 23, 2024
2 parents d097ede + c48a2f0 commit 72c6301
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@

# Ignore built documentation
build/*

# ignore generated files
decomposer.autoload.inc.php
decomposer.diffnotes.md
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "third-party/slevomat"]
path = third-party/slevomat
url = [email protected]:slevomat/coding-standard.git
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,14 @@ $config = [
- Classes must have their opening bracket on a new line and not have it indented.
- There must be a single space after the scope keyword.
- All class keywords must be lowercase.
- Use declarations should be according to PSR-2 [psr-2/#3-namespace-and-use-declarations](https://www.php-fig.org/psr/psr-2/#3-namespace-and-use-declarations)
- There must be only one class declaration per file

## Use declarations
- Use declarations should be according to PSR-2 [psr-2/#3-namespace-and-use-declarations](https://www.php-fig.org/psr/psr-2/#3-namespace-and-use-declarations)
- Use imports should be sorted alphabetically
- All classes from other namespaces should be referenced through use statements
- Classes from the same namespace should not be referenced through use statements

## Strings
- Always have one space preceding and succeeding the concatenation symbol.

Expand Down
2 changes: 1 addition & 1 deletion Stellr/Sniffs/Commenting/FunctionCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
$commentLines = [];
if ($tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING) {
$matches = [];
preg_match('/([^$&.]+)(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/', $tokens[($tag + 2)]['content'], $matches);
preg_match('/((?:(?![$.]|&(?=\$)).)*)(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/', $tokens[($tag + 2)]['content'], $matches);

if (empty($matches) === false) {
$typeLen = strlen($matches[1]);
Expand Down
13 changes: 13 additions & 0 deletions Stellr/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,17 @@
<property name="spacing" value="1"/>
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
</ruleset>
16 changes: 16 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$base = __DIR__;

if (file_exists($base . '/vendor/autoload.php') == TRUE)
{
// Load composer autoloader.
$autoload_file = $base . '/vendor/autoload.php';
}
else
{
// Load decomposer autoloader.
$autoload_file = $base . '/decomposer.autoload.inc.php';
}

require_once $autoload_file;
18 changes: 18 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "lunr/coding-standard",
"description": "Lunr Coding Standard for PHP_CodeSniffer",
"license": "MIT",
"type": "phpcodesniffer-standard",
"keywords": [ "phpcs", "dev" ],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^8.1",
"phpstan/phpdoc-parser": "^1.23.1"
},
"autoload": {
"psr-4": {
"Lunr\\Sniffs\\": "Lunr/Sniffs/"
}
}
}
10 changes: 10 additions & 0 deletions decomposer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"phpdoc-parser": {
"url": "https://github.com/phpstan/phpdoc-parser.git",
"version": "1.29.1",
"psr4": {
"prefix": "PHPStan\\PhpDocParser",
"search-path": "/src/"
}
}
}
1 change: 1 addition & 0 deletions third-party/slevomat
Submodule slevomat added at 7d1d95

0 comments on commit 72c6301

Please sign in to comment.