File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 44/.travis.yml export-ignore
55/phpunit.xml export-ignore
66/tests export-ignore
7+ /tools export-ignore
8+ /Makefile export-ignore
Original file line number Diff line number Diff line change 1+ SOURCE := https://raw.githubusercontent.com/postgres/postgres/master/src/backend/utils/errcodes.txt
2+ TARGET := $(CURDIR ) /src/PostgresError.php
3+ GENERATOR := php $(CURDIR ) /tools/generator.php
4+
5+ all : clean $(TARGET )
6+
7+ $(TARGET ) :
8+ curl -s $(SOURCE ) | $(GENERATOR ) > $@
9+
10+ clean :
11+ -$(RM ) $(TARGET )
12+
13+ .PHONY : all clean
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ $ codes = array ();
4+ $ const = array ();
5+
6+ while ($ row = fgets (STDIN )) {
7+ if (preg_match ('/^([0-9A-Z]{5}) +[SWE] +[^ ]+? +([a-z_]+)$/ ' , $ row , $ matches )) {
8+ $ key = strtoupper ($ matches [2 ]);
9+ if (isset ($ codes [$ key ])) {
10+ $ key .= '_EXCEPTION ' ;
11+ }
12+ $ codes [$ key ] = '' ;
13+ $ const [] = " const {$ key } = ' {$ matches [1 ]}'; " ;
14+ }
15+ }
16+
17+ $ const = implode (PHP_EOL , $ const );
18+
19+ echo <<<EOD
20+ <?php
21+
22+ namespace Sunaoka\PostgresError;
23+
24+ class PostgresError
25+ {
26+ $ const
27+ }
28+
29+ EOD ;
You can’t perform that action at this time.
0 commit comments