Skip to content

Commit

Permalink
Add standardized version of php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
allejo committed May 15, 2023
1 parent 4ad3348 commit d1c6b09
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
->in('src')
->in('test')
->in('tools')
->exclude('lib_dojo')
->in('translator')
->exclude('lib_highlight')
->exclude('output')
;

$config = new PhpCsFixer\Config();
Expand Down
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
"type": "library",
"license": "BSD-3-Clause",
"scripts": {
"format": "php-cs-fixer fix $(if [ ! -z $CI ]; then echo \"--format=checkstyle\"; fi)",
"test:detection": "phpunit test/Highlight/DetectionTest.php",
"test:markup": "phpunit test/Highlight/MarkupTest.php",
"test": "phpunit -v"
"test": "phpunit -v",
"tools": "@composer bin all install --ansi"
},
"support": {
"issues": "https://github.com/scrivo/highlight.php/issues",
Expand Down Expand Up @@ -55,6 +57,8 @@
"ext-mbstring": "*"
},
"require-dev": {
"php": ">=8.0",
"bamarni/composer-bin-plugin": "^1.8",
"phpbench/phpbench": "^1.0",
"phpunit/phpunit": "^5.7",
"sabberworm/php-css-parser": "^8.3",
Expand All @@ -67,6 +71,9 @@
}
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"bamarni/composer-bin-plugin": true
}
}
}
4 changes: 2 additions & 2 deletions demo/compare.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ function getLanguageDemo($lang)

if (isset($_GET['raw'])) {
echo getLanguageRaw($lang);
die();
die;
}

echo getLanguageDemo($_GET['lang']);
die();
die;
}

?>
Expand Down
4 changes: 2 additions & 2 deletions demo/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ function getLanguageDemo($lang)

if (isset($_GET['raw'])) {
echo getLanguageRaw($lang);
die();
die;
}

echo getLanguageDemo($_GET['lang']);
die();
die;
}

$styles = HighlightUtilities\Functions::getAvailableStyleSheets();
Expand Down
8 changes: 4 additions & 4 deletions demo/line-numbers.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@

<?php
$hl = new Highlight\Highlighter();
$snippet = file_get_contents("../test/detect/php/default.txt");
$result = $hl->highlight("php", $snippet);
$snippet = file_get_contents("../test/detect/php/default.txt");
$result = $hl->highlight("php", $snippet);

$lines = HighlightUtilities\Functions::splitCodeIntoArray($result->value);
?>
$lines = HighlightUtilities\Functions::splitCodeIntoArray($result->value);
?>
<table>
<tbody>
<?php foreach ($lines as $number => $line): ?>
Expand Down
2 changes: 2 additions & 0 deletions test/Benchmark/HighlighterBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class HighlighterBench
{
/**
* @Revs(500)
*
* @Iterations(5)
*/
public function benchLoadNoLanguages()
Expand All @@ -20,6 +21,7 @@ public function benchLoadNoLanguages()

/**
* @Revs(500)
*
* @Iterations(5)
*/
public function benchLoadAllLanguages()
Expand Down
4 changes: 2 additions & 2 deletions tools/get_language_definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@
$jsonLangDef = preg_replace('/(\[[^:]*?\w)(-)([^a-zA-Z0-9\\\\]+?)/um', '$1\\\\\\-$3', $jsonLangDef);

if (!$languageName) {
die(sprintf("ERROR: No language name on line %d\n", ($i + 1)));
die(sprintf("ERROR: No language name on line %d\n", $i + 1));
}
if (!@json_decode($jsonLangDef)) {
die(sprintf("ERROR: Invalid JSON data on line %d\n", ($i + 2)));
die(sprintf("ERROR: Invalid JSON data on line %d\n", $i + 2));
}

if (isset($patches[$languageName])) {
Expand Down
6 changes: 6 additions & 0 deletions vendor-bin/php-cs-fixer/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"require": {
"friendsofphp/php-cs-fixer": "^3.16",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.14"
}
}

0 comments on commit d1c6b09

Please sign in to comment.