Skip to content

Commit 00abb12

Browse files
committed
Initial commit
0 parents  commit 00abb12

36 files changed

+5015
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
charset = utf-8
8+
indent_style = space
9+
indent_size = 4

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.editorconfig export-ignore
2+
.gitattributes export-ignore
3+
.github/ export-ignore
4+
.gitignore export-ignore
5+
phpcs.xml.dist export-ignore
6+
phpstan.neon export-ignore
7+
phpunit.xml.dist export-ignore
8+
tests/ export-ignore

.github/workflows/ci.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
8+
jobs:
9+
check_composer:
10+
name: Check composer.json
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: shivammathur/setup-php@v2
15+
with:
16+
coverage: none
17+
php-version: '8.3'
18+
- run: composer validate --strict --no-check-lock
19+
20+
21+
tests:
22+
name: "Tests on PHP ${{ matrix.php }}${{ matrix.name_suffix }}"
23+
runs-on: ${{ matrix.os }}
24+
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
php: [ '8.1', '8.2', '8.3', '8.4' ]
29+
os: [ubuntu-latest]
30+
include:
31+
- php: '8.3'
32+
os: windows-latest
33+
name_suffix: ' on Windows'
34+
- php: '8.3'
35+
os: macos-latest
36+
name_suffix: ' on macOS'
37+
38+
steps:
39+
- if: ${{ runner.os == 'Windows' }}
40+
run: git config --global core.autocrlf false
41+
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
45+
- name: Setup PHP
46+
uses: shivammathur/setup-php@v2
47+
with:
48+
coverage: "none"
49+
php-version: "${{ matrix.php }}"
50+
ini-file: development
51+
52+
- name: Install dependencies
53+
run: composer update --ansi --no-progress
54+
55+
- name: Run tests
56+
run: vendor/bin/phpunit --colors=always
57+
58+
static_analysis:
59+
name: Static analysis
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v4
65+
66+
- name: Setup PHP
67+
uses: shivammathur/setup-php@v2
68+
with:
69+
coverage: "none"
70+
php-version: "8.3"
71+
ini-file: development
72+
73+
- name: Install dependencies
74+
run: composer update --ansi --no-progress
75+
76+
- name: Run phpstan
77+
run: vendor/bin/phpstan analyse --ansi --no-progress
78+
79+
coding_styles:
80+
name: Coding styles
81+
runs-on: ubuntu-latest
82+
83+
steps:
84+
- name: Checkout
85+
uses: actions/checkout@v4
86+
87+
- name: Setup PHP
88+
uses: shivammathur/setup-php@v2
89+
with:
90+
coverage: "none"
91+
php-version: "8.3"
92+
ini-file: development
93+
94+
- name: Install dependencies
95+
run: composer update --ansi --no-progress
96+
97+
- name: Run phpcs
98+
run: vendor/bin/phpcs --extensions=php src tests

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
composer.lock
2+
/vendor/
3+
.phpunit.result.cache

LICENSE.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2024-present, the Scssphp project authors
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SourceSpan
2+
3+
`scssphp/source-span` is a library for tracking locations in source code. It's designed
4+
to provide a standard representation for source code locations and spans so that
5+
disparate packages can easily pass them among one another, and to make it easy
6+
to generate human-friendly messages associated with a given piece of code.
7+
8+
The most commonly-used interface is the package's namesake, `SourceSpan\SourceSpan`. It
9+
represents a span of characters in some source file, and is often attached to an
10+
object that has been parsed to indicate where it was parsed from. It provides
11+
access to the text of the span via `SourceSpan::getText()` and can be used to produce
12+
human-friendly messages using `SourceSpan::message()`. It's most simple implementation
13+
is `SourceSpan\SimpleSourceSpan` which holds directly the span information.
14+
15+
When parsing code from a file, `SourceSpan\SourceFile` is useful. Not only does it provide
16+
an efficient means of computing line and column numbers, `SourceFile#span()`
17+
returns special `FileSpan`s that are able to provide more context for their
18+
error messages.
19+
20+
## Credits
21+
22+
This library is a PHP port of the [Dart `source_span` package](https://github.com/dart-lang/source_span).

composer.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "scssphp/source-span",
3+
"type": "library",
4+
"description": "Provides a representation for source code locations and spans.",
5+
"keywords": ["parsing"],
6+
"license": [
7+
"MIT"
8+
],
9+
"authors": [
10+
{
11+
"name": "Christophe Coevoet",
12+
"homepage": "https://github.com/stof"
13+
}
14+
],
15+
"autoload": {
16+
"psr-4": { "SourceSpan\\": "src/" }
17+
},
18+
"autoload-dev": {
19+
"psr-4": { "SourceSpan\\Tests\\": "tests/" }
20+
},
21+
"require": {
22+
"php": ">=8.1",
23+
"league/uri": "^7.4",
24+
"league/uri-interfaces": "^7.4"
25+
},
26+
"suggest": {
27+
"ext-mbstring": "For best performance, mbstring should be installed as it is faster than the polyfill"
28+
},
29+
"require-dev": {
30+
"phpstan/phpstan": "^2.0",
31+
"phpstan/phpstan-deprecation-rules": "^2.0",
32+
"phpunit/phpunit": "^9.5.6",
33+
"squizlabs/php_codesniffer": "~3.5",
34+
"symfony/phpunit-bridge": "^5.1",
35+
"symfony/var-dumper": "^6.3"
36+
},
37+
"extra": {
38+
"branch-alias": {
39+
"dev-main": "1.x-dev"
40+
}
41+
},
42+
"config": {
43+
"sort-packages": true
44+
}
45+
}

phpcs.xml.dist

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Scssphp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
3+
<rule ref="PSR12">
4+
<!-- This sniff does not properly support functions returning never and so terminating the branch. -->
5+
<exclude name="PSR2.ControlStructures.SwitchDeclaration.TerminatingComment"/>
6+
7+
<!-- PSR12 does not actually have a hard line length -->
8+
<exclude name="Generic.Files.LineLength"/>
9+
</rule>
10+
<rule ref="Generic.NamingConventions.UpperCaseConstantName">
11+
<exclude-pattern>*/src/Highlighter/AsciiGlyph.php</exclude-pattern>
12+
</rule>
13+
</ruleset>

phpstan.neon

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
parameters:
2+
level: 8
3+
treatPhpDocTypesAsCertain: false
4+
paths:
5+
- ./src/
6+
7+
includes:
8+
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
9+
- vendor/phpstan/phpstan-deprecation-rules/rules.neon

phpunit.xml.dist

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
colors="true"
5+
bootstrap="vendor/autoload.php"
6+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
7+
>
8+
<coverage>
9+
<include>
10+
<directory>src/</directory>
11+
</include>
12+
</coverage>
13+
14+
<testsuites>
15+
<testsuite name="Project Test Suite">
16+
<directory>tests</directory>
17+
</testsuite>
18+
</testsuites>
19+
20+
<listeners>
21+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
22+
</listeners>
23+
</phpunit>

0 commit comments

Comments
 (0)