Skip to content

Commit 5634c56

Browse files
authored
Merge pull request #9 from moufmouf/moving-generator
Moving generator to a subdirectory and another composer.json file
2 parents 87991d5 + c5a2c57 commit 5634c56

33 files changed

+132
-119
lines changed

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
/vendor/
2-
/build/
3-
/doc/doc-en/
1+
/generator/vendor/
2+
/generator/build/
3+
/generator/doc/doc-en/
4+
/generator/doc/entities/generated.ent
5+
/composer.lock

.travis.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,31 @@ matrix:
88

99
cache:
1010
directories:
11-
- doc/doc-en
11+
- generator/doc/doc-en
1212
- vendor
13+
- generator/vendor
1314
- $HOME/.composer
1415

1516
before_script:
16-
- composer install --no-interaction
17-
- mkdir -p build/logs
17+
- cd generator && composer install --no-interaction && cd ..
1818
- |
19-
if [ ! -d "doc/doc-en/en" ]; then
20-
cd doc
19+
if [ ! -d "generator/doc/doc-en/en" ]; then
20+
cd generator/doc
2121
svn co https://svn.php.net/repository/phpdoc/modules/doc-en doc-en
22-
cd ..
22+
cd ../..
2323
else
24-
cd doc/doc-en
24+
cd generator/doc/doc-en
2525
svn update
26-
cd ../..
26+
cd ../../..
2727
fi
28+
- composer update
2829

2930
script:
30-
- "./vendor/bin/phpunit"
31-
#- "./vendor/bin/composer-require-checker --config-file=composer-require-checker.json"
31+
- cd generator && ./vendor/bin/phpunit && cd ..
32+
- cd generator && composer cs-check && cd ..
33+
- cd generator && composer phpstan && cd ..
3234
- composer cs-check
3335
- composer phpstan
36+
3437
after_script:
3538
- travis_retry php vendor/bin/php-coveralls

CONTRIBUTING.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,25 @@ Safe-PHP code is generated automatically from the PHP doc.
77
The first step is to download the PHP documentation project locally.
88
You will need Subversion (svn) installed on your computer.
99

10+
```bash
11+
$ cd generator/doc
12+
$ svn co https://svn.php.net/repository/phpdoc/modules/doc-en doc-en
13+
$ cd ../..
1014
```
11-
cd doc
12-
svn co https://svn.php.net/repository/phpdoc/modules/doc-en doc-en
13-
cd ..
14-
```
15-
16-
Generating the documentation is a 2 pass process.
1715

18-
### First pass: generating the function list
16+
At any point, if you want to update the documentation to the latest version, you can use:
1917

2018
```bash
21-
php ./parse.php
19+
$ cd generator/doc/doc-en
20+
$ svn update
2221
```
2322

24-
The first pass is used to find all the functions in the documentation and to put them in a CSV file called `generated/functions.csv`
2523

26-
This CSV file is then **manually edited** to cope for the specific cases of some functions (for instance, the cURL exception
27-
messages can be fetched from `curl_strerror`).
24+
### Generating the functions
2825

29-
### Second pass: generating the function list
26+
Generating the functions can be done with a simple command line.
3027

3128
```bash
32-
php ./generate.php
29+
$ cd generator
30+
$ php ./safe.php generate
3331
```
34-
35-
The second pass uses the `generated/functions.csv` and the downloaded documentation to create the functions wrapper file
36-
in `generated/lib.php`.
37-

composer.json

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,19 @@
11
{
22
"name": "thecodingmachine/safe",
3-
"description": "Create a list of functional PHP functions which return false on error",
3+
"description": "PHP core functions that throw exceptions instead of returning FALSE on error",
44
"autoload": {
55
"psr-4": {
66
"Safe\\": ["lib/", "generated/"]
77
}
88
},
9-
"autoload-dev": {
10-
"psr-4": {
11-
"Safe\\": "src/"
12-
}
13-
},
149
"require-dev": {
1510
"php": ">=7.1",
16-
"ext-simplexml": "*",
17-
"phpunit/phpunit": "^7",
1811
"phpstan/phpstan": "^0.10.3",
1912
"thecodingmachine/phpstan-strict-rules": "^0.10.3",
20-
"phpoffice/phpspreadsheet": "^1.4",
21-
"ext-json": "^1.5",
22-
"symfony/console": "^4.1.4",
23-
"squizlabs/php_codesniffer": "^3.2",
24-
"php-coveralls/php-coveralls": "^2.1"
13+
"squizlabs/php_codesniffer": "^3.2"
2514
},
2615
"scripts": {
27-
"phpstan": "phpstan analyse src -c phpstan.neon --level=7 --no-progress -vvv",
16+
"phpstan": "phpstan analyse lib -c phpstan.neon --level=7 --no-progress -vvv",
2817
"cs-fix": "phpcbf",
2918
"cs-check": "phpcs"
3019
},

doc/entities/.gitkeep

Whitespace-only changes.

generator/composer.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "thecodingmachine/safe-generator",
3+
"description": "Generated the files for thecodingmachine/safe",
4+
"autoload-dev": {
5+
"psr-4": {
6+
"Safe\\": "src/"
7+
}
8+
},
9+
"require-dev": {
10+
"php": ">=7.1",
11+
"ext-simplexml": "*",
12+
"phpunit/phpunit": "^7",
13+
"phpstan/phpstan": "^0.10.3",
14+
"thecodingmachine/phpstan-strict-rules": "^0.10.3",
15+
"phpoffice/phpspreadsheet": "^1.4",
16+
"ext-json": "^1.5",
17+
"symfony/console": "^4.1.4",
18+
"squizlabs/php_codesniffer": "^3.2",
19+
"php-coveralls/php-coveralls": "^2.1"
20+
},
21+
"scripts": {
22+
"phpstan": "phpstan analyse src -c phpstan.neon --level=7 --no-progress -vvv",
23+
"cs-fix": "phpcbf",
24+
"cs-check": "phpcs"
25+
},
26+
"extra": {
27+
"branch-alias": {
28+
"dev-master": "0.1-dev"
29+
}
30+
}
31+
}

composer.lock renamed to generator/composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

generator/phpcs.xml.dist

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Expressive Skeleton coding standard">
3+
<description>Expressive Skeleton coding standard</description>
4+
5+
<!-- display progress -->
6+
<arg value="p"/>
7+
<arg name="colors"/>
8+
9+
<!-- inherit rules from: -->
10+
<rule ref="PSR2"/>
11+
12+
<!-- Paths to check -->
13+
<file>src</file>
14+
15+
<rule ref="Generic.Files.LineLength">
16+
<properties>
17+
<property name="lineLimit" value="300"/>
18+
<property name="absoluteLineLimit" value="500"/>
19+
</properties>
20+
</rule>
21+
</ruleset>

generator/phpstan.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
ignoreErrors:
3+
- "#subject of function str_replace expects array|string, string|true given#"
4+
- "#createExceptionFile\\(\\) expects string, int|string given#"
5+
includes:
6+
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon

0 commit comments

Comments
 (0)