@exercism/codemirror-lang-php 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/LICENSE +21 -0
- package/README.md +97 -2
- package/dist/index.cjs +621 -0
- package/dist/index.d.cts +52 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +615 -0
- package/package.json +54 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
## 1.0.0
|
|
2
|
+
|
|
3
|
+
This is Exercism's first release of the package, published as
|
|
4
|
+
`@exercism/codemirror-lang-php`. It adds completion of keywords, built-ins,
|
|
5
|
+
snippets, the names declared in the file and class members, and uses Exercism's
|
|
6
|
+
fork of the grammar, `@exercism/lezer-php`.
|
|
7
|
+
|
|
8
|
+
## 6.0.2 (2025-06-19)
|
|
9
|
+
|
|
10
|
+
### Bug fixes
|
|
11
|
+
|
|
12
|
+
Add a .d.cts file to make TypeScript happy.
|
|
13
|
+
## 6.0.1 (2022-10-24)
|
|
14
|
+
|
|
15
|
+
### Bug fixes
|
|
16
|
+
|
|
17
|
+
Fix (non-)auto indentation in template strings and comments.
|
|
18
|
+
|
|
19
|
+
Allow prefixed strings to be closed by `closeBrackets`.
|
|
20
|
+
|
|
21
|
+
## 6.0.0 (2022-06-08)
|
|
22
|
+
|
|
23
|
+
### Breaking changes
|
|
24
|
+
|
|
25
|
+
Update dependencies to 6.0.0
|
|
26
|
+
|
|
27
|
+
## 0.20.0 (2022-04-20)
|
|
28
|
+
|
|
29
|
+
### Bug fixes
|
|
30
|
+
|
|
31
|
+
Fix missing highlighting info for the `declare`, `enddeclare`, and `interface` keywords.
|
|
32
|
+
|
|
33
|
+
## 0.19.1 (2021-09-04)
|
|
34
|
+
|
|
35
|
+
### Bug fixes
|
|
36
|
+
|
|
37
|
+
Fix the `plain` option, which was accidentally ignored before.
|
|
38
|
+
|
|
39
|
+
Improve indentation of colon block syntax constructs.
|
|
40
|
+
|
|
41
|
+
## 0.19.0 (2021-09-03)
|
|
42
|
+
|
|
43
|
+
### Breaking changes
|
|
44
|
+
|
|
45
|
+
First numbered release.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,98 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- NOTE: README.md is generated from src/README.md -->
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @codemirror/lang-php [](https://www.npmjs.org/package/@codemirror/lang-php)
|
|
4
|
+
|
|
5
|
+
[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://code.haverbeke.berlin/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/) | [**CHANGELOG**](https://code.haverbeke.berlin/codemirror/lang-php/src/branch/main/CHANGELOG.md) ]
|
|
6
|
+
|
|
7
|
+
This package implements PHP language support for the
|
|
8
|
+
[CodeMirror](https://codemirror.net/) code editor.
|
|
9
|
+
|
|
10
|
+
The [project page](https://codemirror.net/) has more information, a
|
|
11
|
+
number of [examples](https://codemirror.net/examples/) and the
|
|
12
|
+
[documentation](https://codemirror.net/docs/).
|
|
13
|
+
|
|
14
|
+
This code is released under an
|
|
15
|
+
[MIT license](https://code.haverbeke.berlin/codemirror/lang-php/tree/main/LICENSE).
|
|
16
|
+
|
|
17
|
+
We aim to be an inclusive, welcoming community. To make that explicit,
|
|
18
|
+
we have a [code of
|
|
19
|
+
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
|
20
|
+
to communication around the project.
|
|
21
|
+
|
|
22
|
+
## Exercism's fork
|
|
23
|
+
|
|
24
|
+
This is Exercism's fork of `@codemirror/lang-php`, published as
|
|
25
|
+
`@exercism/codemirror-lang-php`. Our changes live on the `exercism`
|
|
26
|
+
branch. The grammar comes from Exercism's fork of `@lezer/php`,
|
|
27
|
+
`@exercism/lezer-php`, which parses a few things that are errors in the official grammar (`function from()`, `foreach ($xs as &$x)` and mixed-case
|
|
28
|
+
`Class` and `Static`).
|
|
29
|
+
|
|
30
|
+
The fork adds completion to `php()`:
|
|
31
|
+
|
|
32
|
+
- keywords, types, and the built-in functions, classes and constants
|
|
33
|
+
that are used most often in PHP solutions
|
|
34
|
+
- snippets for functions, methods, classes, loops, `if`, `switch`,
|
|
35
|
+
`match` and `try`
|
|
36
|
+
- the names declared in the file: functions, classes, interfaces,
|
|
37
|
+
traits, enums, constants and imported names, and the variables in
|
|
38
|
+
scope at the cursor (parameters, locals, `foreach` and `catch`
|
|
39
|
+
variables, closure `use` variables and `$this`)
|
|
40
|
+
- after `$this->`, the class's properties and methods, and after
|
|
41
|
+
`self::`, `static::`, `parent::` or a class name, its static
|
|
42
|
+
members, constants and enum cases
|
|
43
|
+
|
|
44
|
+
PHP variables belong to the whole function, so a function sees only its own variables, and none of the variables at the top level of the file. An arrow
|
|
45
|
+
function also sees the variables around it. Completion offers nothing inside strings and comments.
|
|
46
|
+
|
|
47
|
+
To use it, install it from npm:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
npm install @exercism/codemirror-lang-php
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
To build and test it from a checkout, run `npm install` (which also builds the package), then `npm test`.
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
import {EditorView, basicSetup} from "codemirror"
|
|
59
|
+
import {php} from "@exercism/codemirror-lang-php"
|
|
60
|
+
|
|
61
|
+
const view = new EditorView({
|
|
62
|
+
parent: document.body,
|
|
63
|
+
doc: `<? echo "Hello world" ?>`,
|
|
64
|
+
extensions: [basicSetup, php()]
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## API Reference
|
|
69
|
+
|
|
70
|
+
<dl>
|
|
71
|
+
<dt id="user-content-php">
|
|
72
|
+
<code><strong><a href="#user-content-php">php</a></strong>(<a id="user-content-php^config" href="#user-content-php^config">config</a>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a> = {}) → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
|
|
73
|
+
|
|
74
|
+
<dd><p>PHP language support.</p>
|
|
75
|
+
<dl><dt id="user-content-php^config">
|
|
76
|
+
<code><strong><a href="#user-content-php^config">config</a></strong></code></dt>
|
|
77
|
+
|
|
78
|
+
<dd><dl><dt id="user-content-php^config.baselanguage">
|
|
79
|
+
<code><strong><a href="#user-content-php^config.baselanguage">baseLanguage</a></strong>⁠?: <a href="https://codemirror.net/docs/ref#language.Language">Language</a></code></dt>
|
|
80
|
+
|
|
81
|
+
<dd><p>By default, the parser will treat content outside of <code><?</code> and
|
|
82
|
+
<code>?></code> markers as HTML. You can pass a different language here to
|
|
83
|
+
change that. Explicitly passing disables parsing of such content.</p>
|
|
84
|
+
</dd><dt id="user-content-php^config.plain">
|
|
85
|
+
<code><strong><a href="#user-content-php^config.plain">plain</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
|
|
86
|
+
|
|
87
|
+
<dd><p>By default, PHP parsing only starts at the first <code><?</code> marker.
|
|
88
|
+
When you set this to true, it starts immediately at the start of
|
|
89
|
+
the document.</p>
|
|
90
|
+
</dd></dl></dd></dl></dd>
|
|
91
|
+
<dt id="user-content-phplanguage">
|
|
92
|
+
<code><strong><a href="#user-content-phplanguage">phpLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
|
|
93
|
+
|
|
94
|
+
<dd><p>A language provider based on the <a href="https://code.haverbeke.berlin/lezer/php">Lezer PHP
|
|
95
|
+
parser</a>, extended with
|
|
96
|
+
highlighting and indentation information.</p>
|
|
97
|
+
</dd>
|
|
98
|
+
</dl>
|