Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/need-fix-to-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ concurrency:

jobs:
main:
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@6857ef6d10f704e0998aa4955282f27d1b9be778 # 0.23.1
uses: hoverkraft-tech/ci-github-common/.github/workflows/need-fix-to-issue.yml@b4883995e100e291a1fed68678d47a560328ed08 # 0.24.0
with:
manual-commit-ref: ${{ inputs.manual-commit-ref }}
manual-base-ref: ${{ inputs.manual-base-ref }}
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ on:

jobs:
main:
uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@6857ef6d10f704e0998aa4955282f27d1b9be778 # 0.23.1
uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@b4883995e100e291a1fed68678d47a560328ed08 # 0.24.0
15 changes: 6 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
"name": "Neilime",
"homepage": "https://github.com/neilime",
"role": "Developer"
},
{
"name": "ESCEMI",
"homepage": "https://github.com/escemi-tech",
"role": "Developer"
}
],
"support": {
Expand Down Expand Up @@ -77,14 +82,6 @@
},
"config": {
"optimize-autoloader": true,
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
"sort-packages": true
}
}
104 changes: 52 additions & 52 deletions src/CssLint/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,58 +70,58 @@ private function printUsage(): void
$defaultFormatter = $availableFormatters[0];

$this->printLine(
'Usage:' . PHP_EOL .
'------' . PHP_EOL .
PHP_EOL .
' ' . self::SCRIPT_NAME . " [--options='{ }'] [--formatter=name] [--formatter=name:path] input_to_lint" . PHP_EOL .
PHP_EOL .
'Arguments:' . PHP_EOL .
'----------' . PHP_EOL .
PHP_EOL .
' --options' . PHP_EOL .
' Options (optional), must be a json object:' . PHP_EOL .
' * "allowedIndentationChars" => [" "] or ["\t"]: will override the current property' . PHP_EOL .
' * "constructors": { "property" => bool }: will merge with the current property' . PHP_EOL .
' * "standards": { "property" => bool }: will merge with the current property' . PHP_EOL .
' * "nonStandards": { "property" => bool }: will merge with the current property' . PHP_EOL .
' Example: --options=\'{ "constructors": {"o" : false}, "allowedIndentationChars": ["\t"] }\'' .
PHP_EOL .
PHP_EOL .
' --formatter' . PHP_EOL .
' The formatter(s) to be used. Can be specified multiple times.' . PHP_EOL .
' Format: --formatter=name (output to stdout) or --formatter=name:path (output to file)' . PHP_EOL .
' If not specified, the default formatter will output to stdout.' . PHP_EOL .
' Available formatters: ' . implode(', ', $availableFormatters) . PHP_EOL .
' Examples:' . PHP_EOL .
' output to stdout: --formatter=' . $defaultFormatter . PHP_EOL .
' output to file: --formatter=' . $defaultFormatter . ':report.txt' . PHP_EOL .
' multiple outputs: --formatter=' . $defaultFormatter . ' --formatter=' . $availableFormatters[1] . ':report.json' . PHP_EOL .
PHP_EOL .
' input_to_lint' . PHP_EOL .
' The CSS file path (absolute or relative)' . PHP_EOL .
' a glob pattern of file(s) to be linted' . PHP_EOL .
' or a CSS string to be linted' . PHP_EOL .
' Example:' . PHP_EOL .
' "./path/to/css_file_path_to_lint.css"' . PHP_EOL .
' "./path/to/css_file_path_to_lint/*.css"' . PHP_EOL .
' ".test { color: red; }"' . PHP_EOL .
PHP_EOL .
'Examples:' . PHP_EOL .
'---------' . PHP_EOL .
PHP_EOL .
' Lint a CSS file:' . PHP_EOL .
' ' . self::SCRIPT_NAME . ' "./path/to/css_file_path_to_lint.css"' . PHP_EOL . PHP_EOL .
' Lint a CSS string:' . PHP_EOL .
' ' . self::SCRIPT_NAME . ' ".test { color: red; }"' . PHP_EOL . PHP_EOL .
' Lint with only tabulation as indentation:' . PHP_EOL .
' ' . self::SCRIPT_NAME .
' --options=\'{ "allowedIndentationChars": ["\t"] }\' ".test { color: red; }"' . PHP_EOL . PHP_EOL .
' Output to a file:' . PHP_EOL .
' ' . self::SCRIPT_NAME . ' --formatter=plain:output.txt ".test { color: red; }"' . PHP_EOL . PHP_EOL .
' Generate GitLab CI report:' . PHP_EOL .
' ' . self::SCRIPT_NAME . ' --formatter=gitlab-ci:report.json "./path/to/css_file.css"' . PHP_EOL . PHP_EOL .
' Multiple outputs (console and file):' . PHP_EOL .
' ' . self::SCRIPT_NAME . ' --formatter=plain --formatter=gitlab-ci:ci-report.json ".test { color: red; }"' . PHP_EOL . PHP_EOL
'Usage:' . PHP_EOL
. '------' . PHP_EOL
. PHP_EOL
. ' ' . self::SCRIPT_NAME . " [--options='{ }'] [--formatter=name] [--formatter=name:path] input_to_lint" . PHP_EOL
. PHP_EOL
. 'Arguments:' . PHP_EOL
. '----------' . PHP_EOL
. PHP_EOL
. ' --options' . PHP_EOL
. ' Options (optional), must be a json object:' . PHP_EOL
. ' * "allowedIndentationChars" => [" "] or ["\t"]: will override the current property' . PHP_EOL
. ' * "constructors": { "property" => bool }: will merge with the current property' . PHP_EOL
. ' * "standards": { "property" => bool }: will merge with the current property' . PHP_EOL
. ' * "nonStandards": { "property" => bool }: will merge with the current property' . PHP_EOL
. ' Example: --options=\'{ "constructors": {"o" : false}, "allowedIndentationChars": ["\t"] }\''
. PHP_EOL
. PHP_EOL
. ' --formatter' . PHP_EOL
. ' The formatter(s) to be used. Can be specified multiple times.' . PHP_EOL
. ' Format: --formatter=name (output to stdout) or --formatter=name:path (output to file)' . PHP_EOL
. ' If not specified, the default formatter will output to stdout.' . PHP_EOL
. ' Available formatters: ' . implode(', ', $availableFormatters) . PHP_EOL
. ' Examples:' . PHP_EOL
. ' output to stdout: --formatter=' . $defaultFormatter . PHP_EOL
. ' output to file: --formatter=' . $defaultFormatter . ':report.txt' . PHP_EOL
. ' multiple outputs: --formatter=' . $defaultFormatter . ' --formatter=' . $availableFormatters[1] . ':report.json' . PHP_EOL
. PHP_EOL
. ' input_to_lint' . PHP_EOL
. ' The CSS file path (absolute or relative)' . PHP_EOL
. ' a glob pattern of file(s) to be linted' . PHP_EOL
. ' or a CSS string to be linted' . PHP_EOL
. ' Example:' . PHP_EOL
. ' "./path/to/css_file_path_to_lint.css"' . PHP_EOL
. ' "./path/to/css_file_path_to_lint/*.css"' . PHP_EOL
. ' ".test { color: red; }"' . PHP_EOL
. PHP_EOL
. 'Examples:' . PHP_EOL
. '---------' . PHP_EOL
. PHP_EOL
. ' Lint a CSS file:' . PHP_EOL
. ' ' . self::SCRIPT_NAME . ' "./path/to/css_file_path_to_lint.css"' . PHP_EOL . PHP_EOL
. ' Lint a CSS string:' . PHP_EOL
. ' ' . self::SCRIPT_NAME . ' ".test { color: red; }"' . PHP_EOL . PHP_EOL
. ' Lint with only tabulation as indentation:' . PHP_EOL
. ' ' . self::SCRIPT_NAME
. ' --options=\'{ "allowedIndentationChars": ["\t"] }\' ".test { color: red; }"' . PHP_EOL . PHP_EOL
. ' Output to a file:' . PHP_EOL
. ' ' . self::SCRIPT_NAME . ' --formatter=plain:output.txt ".test { color: red; }"' . PHP_EOL . PHP_EOL
. ' Generate GitLab CI report:' . PHP_EOL
. ' ' . self::SCRIPT_NAME . ' --formatter=gitlab-ci:report.json "./path/to/css_file.css"' . PHP_EOL . PHP_EOL
. ' Multiple outputs (console and file):' . PHP_EOL
. ' ' . self::SCRIPT_NAME . ' --formatter=plain --formatter=gitlab-ci:ci-report.json ".test { color: red; }"' . PHP_EOL . PHP_EOL
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/CssLint/Tokenizer/Parser/BlockParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static function getBlockContent(TokenizerContext $tokenizerContext): stri
/**
* Performs parsing tokenizer current context, check block part
*/
public function parseCurrentContext(TokenizerContext $tokenizerContext): BlockToken|null
public function parseCurrentContext(TokenizerContext $tokenizerContext): ?BlockToken
{
if ($this->lastCharIsSpace($tokenizerContext)) {
return null;
Expand All @@ -76,7 +76,7 @@ public function parseCurrentContext(TokenizerContext $tokenizerContext): BlockTo
return $this->handleBlockToken($tokenizerContext, $currentBlockToken);
}

private function handleBlockToken(TokenizerContext $tokenizerContext, ?BlockToken $currentBlockToken): BlockToken|null
private function handleBlockToken(TokenizerContext $tokenizerContext, ?BlockToken $currentBlockToken): ?BlockToken
{
if (static::isBlockStart($tokenizerContext)) {
$blockToken = $this->createBlockToken($tokenizerContext);
Expand Down
54 changes: 27 additions & 27 deletions tests/TestSuite/CliTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public function testRunWithoutArgumentMustReturnsErrorCode()
public function testRunWithValidStringShouldReturnSuccessCode()
{
$this->expectOutputString(
'# Lint CSS string...' . PHP_EOL .
"\033[32m => Success: CSS string is valid.\033[0m" . PHP_EOL .
PHP_EOL
'# Lint CSS string...' . PHP_EOL
. "\033[32m => Success: CSS string is valid.\033[0m" . PHP_EOL
. PHP_EOL
);
$this->assertEquals(
0,
Expand All @@ -62,10 +62,10 @@ public function testRunWithValidStringShouldReturnSuccessCode()
public function testRunWithNotValidStringShouldReturnErrorCode()
{
$this->expectOutputString(
'# Lint CSS string...' . PHP_EOL .
"\033[31m - [unexpected_character_in_block_content]: block - Unexpected character: \":\" (line 1, column 6 to line 3, column 16)\033[0m" . PHP_EOL .
"\033[31m - [invalid_property_declaration]: property - Unknown property \"displady\" (line 1, column 7 to line 1, column 23)\033[0m" . PHP_EOL .
"\033[31m => Failure: CSS string is invalid CSS.\033[0m" . PHP_EOL
'# Lint CSS string...' . PHP_EOL
. "\033[31m - [unexpected_character_in_block_content]: block - Unexpected character: \":\" (line 1, column 6 to line 3, column 16)\033[0m" . PHP_EOL
. "\033[31m - [invalid_property_declaration]: property - Unknown property \"displady\" (line 1, column 7 to line 1, column 23)\033[0m" . PHP_EOL
. "\033[31m => Failure: CSS string is invalid CSS.\033[0m" . PHP_EOL
);

$this->assertEquals(1, $this->cli->run([
Expand All @@ -81,10 +81,10 @@ public function testRunWithNotValidFileShouldReturnErrorCode()
$fileToLint = $this->testFixturesDir . '/not_valid.css';

$this->expectOutputString(
"# Lint CSS file \"$fileToLint\"..." . PHP_EOL .
"\033[31m - [invalid_property_declaration]: property - Unknown property \"bordr-top-style\" (line 3, column 5 to line 3, column 27)\033[0m" . PHP_EOL .
"\033[31m - [unclosed_token]: block - Unclosed \"block\" detected (line 1, column 23 to line 6, column 2)\033[0m" . PHP_EOL .
"\033[31m => Failure: CSS file \"$fileToLint\" is invalid CSS.\033[0m" . PHP_EOL
"# Lint CSS file \"$fileToLint\"..." . PHP_EOL
. "\033[31m - [invalid_property_declaration]: property - Unknown property \"bordr-top-style\" (line 3, column 5 to line 3, column 27)\033[0m" . PHP_EOL
. "\033[31m - [unclosed_token]: block - Unclosed \"block\" detected (line 1, column 23 to line 6, column 2)\033[0m" . PHP_EOL
. "\033[31m => Failure: CSS file \"$fileToLint\" is invalid CSS.\033[0m" . PHP_EOL
);
$this->assertEquals(1, $this->cli->run(['php-css-lint', $fileToLint]));
}
Expand All @@ -93,9 +93,9 @@ public function testRunWithGlobShouldReturnSuccessCode()
{
$fileToLint = $this->testFixturesDir . '/valid.css';
$this->expectOutputString(
"# Lint CSS file \"$fileToLint\"..." . PHP_EOL .
"\033[32m => Success: CSS file \"$fileToLint\" is valid.\033[0m" . PHP_EOL .
PHP_EOL
"# Lint CSS file \"$fileToLint\"..." . PHP_EOL
. "\033[32m => Success: CSS file \"$fileToLint\" is valid.\033[0m" . PHP_EOL
. PHP_EOL
);
$this->assertEquals(0, $this->cli->run(['php-css-lint', $this->testFixturesDir . '/valid*.css']), $this->getActualOutput());
}
Expand All @@ -114,20 +114,20 @@ public function testRunWithNotValidFileGlobShouldReturnErrorCode()
{
$fileToLint = $this->testFixturesDir . '/not_valid.css';
$this->expectOutputString(
"# Lint CSS file \"$fileToLint\"..." . PHP_EOL .
"\033[31m - [invalid_property_declaration]: property - Unknown property \"bordr-top-style\" (line 3, column 5 to line 3, column 27)\033[0m" . PHP_EOL .
"\033[31m - [unclosed_token]: block - Unclosed \"block\" detected (line 1, column 23 to line 6, column 2)\033[0m" . PHP_EOL .
"\033[31m => Failure: CSS file \"$fileToLint\" is invalid CSS.\033[0m" . PHP_EOL
"# Lint CSS file \"$fileToLint\"..." . PHP_EOL
. "\033[31m - [invalid_property_declaration]: property - Unknown property \"bordr-top-style\" (line 3, column 5 to line 3, column 27)\033[0m" . PHP_EOL
. "\033[31m - [unclosed_token]: block - Unclosed \"block\" detected (line 1, column 23 to line 6, column 2)\033[0m" . PHP_EOL
. "\033[31m => Failure: CSS file \"$fileToLint\" is invalid CSS.\033[0m" . PHP_EOL
);
$this->assertEquals(1, $this->cli->run(['php-css-lint', $this->testFixturesDir . '/not_valid*.css']));
}

public function testRunWithOptionsMustBeUsedByTheLinter()
{
$this->expectOutputString(
"# Lint CSS string..." . PHP_EOL .
"\033[31m - [invalid_indentation_character]: whitespace - Unexpected char \" \" (line 2, column 1 to line 2, column 2)\033[0m" . PHP_EOL .
"\033[31m => Failure: CSS string is invalid CSS.\033[0m" . PHP_EOL
"# Lint CSS string..." . PHP_EOL
. "\033[31m - [invalid_indentation_character]: whitespace - Unexpected char \" \" (line 2, column 1 to line 2, column 2)\033[0m" . PHP_EOL
. "\033[31m => Failure: CSS string is invalid CSS.\033[0m" . PHP_EOL
);

$this->assertEquals(1, $this->cli->run([
Expand Down Expand Up @@ -168,9 +168,9 @@ public function testRunWithFormatterArgumentShouldReturnSuccessCode()
{
$fileToLint = $this->testFixturesDir . '/valid.css';
$this->expectOutputString(
"::group::Lint CSS file \"$fileToLint\"" . PHP_EOL .
"::notice ::Success: CSS file \"$fileToLint\" is valid." . PHP_EOL .
"::endgroup::" . PHP_EOL
"::group::Lint CSS file \"$fileToLint\"" . PHP_EOL
. "::notice ::Success: CSS file \"$fileToLint\" is valid." . PHP_EOL
. "::endgroup::" . PHP_EOL
);
$this->assertEquals(0, $this->cli->run(['php-css-lint', '--formatter=github-actions', $fileToLint]), $this->getActualOutput());
}
Expand Down Expand Up @@ -203,9 +203,9 @@ public function testRunWithValidFileShouldReturnSuccessCode(string $fileToLint)
{
$fileToLint = $this->testFixturesDir . '/' . $fileToLint;
$this->expectOutputString(
"# Lint CSS file \"$fileToLint\"..." . PHP_EOL .
"\033[32m => Success: CSS file \"$fileToLint\" is valid.\033[0m" . PHP_EOL .
PHP_EOL
"# Lint CSS file \"$fileToLint\"..." . PHP_EOL
. "\033[32m => Success: CSS file \"$fileToLint\" is valid.\033[0m" . PHP_EOL
. PHP_EOL
);
$this->assertEquals(0, $this->cli->run(['php-css-lint', $fileToLint]), $this->getActualOutput());
}
Expand Down
12 changes: 6 additions & 6 deletions tests/TestSuite/LinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ public function testLintFileWithUnreadableFilePathParam()
public function testLintComment()
{
// Act
$errors =
$this->linter->lintString(
"/*" . PHP_EOL .
" * This is a comment" . PHP_EOL .
"*/" . PHP_EOL .
".test { }"
$errors
= $this->linter->lintString(
"/*" . PHP_EOL
. " * This is a comment" . PHP_EOL
. "*/" . PHP_EOL
. ".test { }"
);

// Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public function testEndLintingOutputsEndGroup(): void

// Assert
$this->assertSame(
"::notice ::Success: file.css is valid." . PHP_EOL .
"::endgroup::" . PHP_EOL,
"::notice ::Success: file.css is valid." . PHP_EOL
. "::endgroup::" . PHP_EOL,
$content
);
}
Expand Down
2 changes: 2 additions & 0 deletions tools/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"rector/rector": "^2.1"
},
"config": {
"optimize-autoloader": true,
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
Expand Down