Skip to content

Commit cb71193

Browse files
committed
Initial skeleton files for a PHP library
0 parents  commit cb71193

File tree

11 files changed

+221
-0
lines changed

11 files changed

+221
-0
lines changed

.gitignore

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

.gitreview

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[gerrit]
2+
host=gerrit.wikimedia.org
3+
port=29418
4+
project=mediawiki/libs/WebIDL.git
5+
track=1
6+
defaultrebase=0

.phan/config.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
$cfg = require __DIR__ . '/../vendor/mediawiki/mediawiki-phan-config/src/config.php';
3+
4+
$cfg['directory_list'] = [ 'src' /*,'tests'*/ ];
5+
$cfg['suppress_issue_types'] = [];
6+
7+
return $cfg;

.phan/config.php~

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
return require __DIR__ . '/../vendor/mediawiki/mediawiki-phan-config/src/config.php';

.phpcs.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset>
3+
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
4+
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
5+
<exclude name="MediaWiki.Commenting.MissingCovers.MissingCovers" />
6+
<exclude name="Squiz.Scope.MethodScope.Missing" />
7+
<exclude name="Generic.Files.LineLength.TooLong" />
8+
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
9+
<exclude name="MediaWiki.Commenting.FunctionComment.MissingParamTag" />
10+
<exclude name="MediaWiki.Commenting.FunctionComment.MissingReturn" />
11+
<exclude name="MediaWiki.Commenting.FunctionComment.ParamNameNoMatch" />
12+
<exclude name="MediaWiki.Commenting.FunctionComment.SpacingAfter" />
13+
<exclude name="MediaWiki.Commenting.FunctionComment.WrongStyle" />
14+
<exclude name="MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures" />
15+
</rule>
16+
<file>.</file>
17+
<arg name="encoding" value="UTF-8"/>
18+
<arg name="extensions" value="php"/>
19+
<exclude-pattern>coverage</exclude-pattern>
20+
<exclude-pattern>vendor</exclude-pattern>
21+
<exclude-pattern>doc/html</exclude-pattern>
22+
</ruleset>

CODE_OF_CONDUCT.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The development of this software is covered by a [Code of Conduct](https://www.mediawiki.org/wiki/Special:MyLanguage/Code_of_Conduct).
2+

Doxyfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Doxyfile for WebIDL
2+
#
3+
# See <http://www.stack.nl/~dimitri/doxygen/manual/config.html>
4+
# for help on how to use this file to configure Doxygen.
5+
6+
PROJECT_NAME = "WebIDL"
7+
PROJECT_BRIEF = "WebIDL parser"
8+
OUTPUT_DIRECTORY = doc
9+
JAVADOC_AUTOBRIEF = YES
10+
QT_AUTOBRIEF = YES
11+
WARN_NO_PARAMDOC = YES
12+
INPUT = README.md src/
13+
FILE_PATTERNS = *.php
14+
RECURSIVE = YES
15+
USE_MDFILE_AS_MAINPAGE = README.md
16+
FILTER_PATTERNS = *md=build/doxygen_escape.sh
17+
HTML_DYNAMIC_SECTIONS = YES
18+
GENERATE_TREEVIEW = YES
19+
TREEVIEW_WIDTH = 250
20+
GENERATE_LATEX = NO
21+
HAVE_DOT = YES
22+
DOT_FONTNAME = Helvetica
23+
DOT_FONTSIZE = 10
24+
TEMPLATE_RELATIONS = YES
25+
CALL_GRAPH = NO
26+
CALLER_GRAPH = NO
27+
DOT_MULTI_TARGETS = YES

LICENSE

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

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# WebIDL
2+
3+
__WebIDL__ is a parser for [Web
4+
IDL](https://heycam.github.io/webidl/), a language [to specify web
5+
APIs in interoperable
6+
way](https://heycam.github.io/webidl/#introduction). This library
7+
supports PHP, and is in the same spirit as (but shares no code with)
8+
[webidl2](https://github.com/w3c/webidl2.js) for JavaScript and the
9+
browser.
10+
11+
Report issues on [Phabricator](https://phabricator.wikimedia.org/maniphest/task/edit/form/1/?projects=Parsoid&title=WebIDL:%20).
12+
13+
## Install
14+
15+
This package is [available on Packagist](https://packagist.org/packages/wikimedia/webidl):
16+
17+
```bash
18+
$ composer require wikimedia/webidl
19+
```
20+
21+
## Usage
22+
23+
WebIDL provides one function, `parse`, which converts a WebIDL string into a
24+
syntax tree.
25+
26+
```php
27+
use Wikimedia\WebIDL;
28+
29+
$tree = WebIDL::parse("string of WebIDL");
30+
```
31+
32+
The `parse()` method optionally takes an option array with the following
33+
keys:
34+
* `concrete`: Boolean indicating whether the result should include an EOF node or not.
35+
* `sourceName`: The source name, typically a filename. Errors and validation objects can indicate their origin if you pass a value.
36+
37+
## AST (Abstract Syntax Tree)
38+
39+
Will be documented. For now, look at the [webidl2 AST
40+
docs](https://github.com/w3c/webidl2.js#ast-abstract-syntax-tree) and
41+
convert JavaScript objects to PHP associative arrays.
42+
43+
## Tests
44+
45+
```bash
46+
$ composer test
47+
```
48+
49+
## License and Credits
50+
51+
The initial version of this code was written by C. Scott Ananian and is
52+
(c) Copyright 2019 Wikimedia Foundation.
53+
54+
This code is distributed under the MIT license; see LICENSE for more
55+
info.

composer.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "wikimedia/webidl",
3+
"description": "WebIDL parser for PHP",
4+
"keywords": [
5+
"webidl",
6+
"wikipeg"
7+
],
8+
"license": "MIT",
9+
"homepage": "https://www.mediawiki.org/wiki/WebIDL",
10+
"authors": [
11+
{
12+
"name": "C. Scott Ananian",
13+
"email": "cananian@wikimedia.org"
14+
}
15+
],
16+
"require": {
17+
"php": ">=7.2.0",
18+
"ext-mbstring": "*",
19+
"ext-xml": "*"
20+
},
21+
"suggest": {
22+
"ext-intl": "*"
23+
},
24+
"require-dev": {
25+
"jakub-onderka/php-parallel-lint": "1.0.0",
26+
"jakub-onderka/php-console-highlighter": "0.4.0",
27+
"mediawiki/mediawiki-codesniffer": "30.0.0",
28+
"mediawiki/mediawiki-phan-config": "0.9.1",
29+
"mediawiki/minus-x": "1.0.0",
30+
"ockcyp/covers-validator": "1.1.1",
31+
"phpunit/phpunit": "^8.5",
32+
"wikimedia/wikipeg": "^2.0.5",
33+
"wikimedia/testing-access-wrapper": "~1.0"
34+
},
35+
"autoload": {
36+
"psr-4": {
37+
"Wikimedia\\WebIDL\\": "src/"
38+
}
39+
},
40+
"autoload-dev": {
41+
"psr-4": {
42+
"Wikimedia\\WebIDL\\Tests\\": "tests/"
43+
}
44+
},
45+
"scripts": {
46+
"test": [
47+
"parallel-lint . --exclude vendor",
48+
"phpunit",
49+
"@phan",
50+
"covers-validator",
51+
"phpcs -sp",
52+
"minus-x check ."
53+
],
54+
"cover": "phpunit --coverage-html coverage",
55+
"fix": [
56+
"minus-x fix .",
57+
"phpcbf"
58+
],
59+
"phan": "phan --allow-polyfill-parser"
60+
}
61+
}

0 commit comments

Comments
 (0)