Skip to content

Commit 05bfc5a

Browse files
committed
Merge branch 'feature/php-8' into develop
2 parents 5ac97cc + 35ac3be commit 05bfc5a

47 files changed

Lines changed: 5642 additions & 6501 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
fail-fast: false
99
matrix:
1010
operating-system: [ubuntu-latest, windows-latest, macos-latest]
11-
php-versions: ['7.2', '7.3', '7.4']
11+
php-versions: ['7.2', '7.3', '7.4', '8.0']
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v2
@@ -18,6 +18,7 @@ jobs:
1818
php-version: ${{ matrix.php-versions }}
1919
extensions: mbstring, dom, fileinfo, pdo_sqlite
2020
coverage: xdebug #optional
21+
tools: phpunit
2122
- name: Get composer cache directory
2223
id: composer-cache
2324
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
@@ -33,4 +34,4 @@ jobs:
3334
run: composer install --no-progress --prefer-dist --optimize-autoloader
3435

3536
- name: Test with phpunit
36-
run: vendor/bin/phpunit --coverage-text
37+
run: ./vendor/bin/phpunit --coverage-text || phpunit --coverage-text

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ Lexer.phpbak
22
vendor
33
composer.lock
44
Parser.out
5+
.php_cs.cache
6+
.phpunit.result.cache

.php_cs.dist

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
The MIT License (MIT)
5+
6+
Copyright (c) 2015-2021 César Rodas
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy
9+
of this software and associated documentation files (the "Software"), to deal
10+
in the Software without restriction, including without limitation the rights
11+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
copies of the Software, and to permit persons to whom the Software is
13+
furnished to do so, subject to the following conditions:
14+
-
15+
The above copyright notice and this permission notice shall be included in
16+
all copies or substantial portions of the Software.
17+
-
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
THE SOFTWARE.
25+
EOF;
26+
27+
$finder = PhpCsFixer\Finder::create()
28+
->exclude('tests/Fixtures')
29+
->in(__DIR__);
30+
31+
$config = new PhpCsFixer\Config();
32+
$config
33+
->setRiskyAllowed(true)
34+
->setRules([
35+
'@PHP56Migration' => true,
36+
'@PHPUnit75Migration:risky' => true,
37+
'@PhpCsFixer' => true,
38+
'@PhpCsFixer:risky' => true,
39+
'header_comment' => ['header' => $header],
40+
'list_syntax' => ['syntax' => 'long'],
41+
])
42+
->setFinder($finder)
43+
;
44+
45+
return $config;

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
all: build test
2+
3+
setup:
4+
composer install
5+
6+
build:
7+
./vendor/bin/phplemon src/SQLParser/Parser.y || exit 0
8+
php build.php
9+
./vendor/bin/php-cs-fixer fix src
10+
test:
11+
phpunit --coverage-html coverage

build.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@
22

33
require __DIR__ . '/vendor/autoload.php';
44

5-
$generator = new Autoloader\Generator("src/");
6-
$generator->IncludePSR0Autoloader(false)
7-
->relativePaths()
8-
->generate("src/autoload.php");
5+
use SQLParser\Lexer;
6+
7+
$constants = '';
8+
9+
foreach (Lexer::getKeywords() as $code => $id) {
10+
$constants .= 'const T_' . strtoupper($code) . ' = ' . var_export($code, true) . ";\n\n";
11+
}
12+
13+
$code = '<?php
14+
15+
namespace SQL;
16+
17+
class ReservedWords
18+
{
19+
' . $constants . '
20+
public static $words = ' . var_export(Lexer::getKeywords(), true) . ';
21+
}';
22+
23+
24+
file_put_contents(__DIR__ . '/src/SQL/ReservedWords.php', $code);

build.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

composer.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
}
1111
],
1212
"version": "v0.1.5",
13+
"minimum-stability": "stable",
1314
"autoload": {
14-
"files": ["src/autoload.php"]
15+
"classmap": [
16+
"src/"
17+
]
1518
},
16-
"minimum-stability": "stable",
1719
"require-dev": {
18-
"crodas/autoloader": "^0.1.16",
1920
"crodas/phpunit-compat": "^1.7",
20-
"fpoirotte/php_parsergenerator": "^0.2.4"
21+
"fpoirotte/php_parsergenerator": "^0.2.4",
22+
"friendsofphp/php-cs-fixer": "^2.18"
2123
}
2224
}

src/SQL/AlterTable/AddColumn.php

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
<?php
2-
/*
3-
The MIT License (MIT)
4-
5-
Copyright (c) 2015 César Rodas
62

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

17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23-
THE SOFTWARE.
24-
*/
2527
namespace SQL\AlterTable;
2628

2729
use SQLParser\Stmt\Column;
@@ -30,7 +32,7 @@ class AddColumn extends AlterTable
3032
{
3133
public function __construct(Column $column, $position)
3234
{
33-
$this->column = $column;
35+
$this->column = $column;
3436
$this->position = $position;
3537
}
3638
}

src/SQL/AlterTable/AddIndex.php

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

2729
use SQLParser\Stmt\ExprList;
@@ -36,14 +38,14 @@ public function __construct($type, $name, ExprList $columns)
3638
{
3739
$this->indexType = $type;
3840
$this->indexName = $name;
39-
$this->columns = $columns;
41+
$this->columns = $columns;
4042
}
4143

4244
public function getIndexName()
4345
{
4446
return $this->indexName;
4547
}
46-
48+
4749
public function getIndexType()
4850
{
4951
return $this->indexType;

src/SQL/AlterTable/AlterTable.php

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

2729
use SQL\Statement;
@@ -39,7 +41,7 @@ public function getTableName()
3941

4042
public function isFirst()
4143
{
42-
return $this->position === TRUE;
44+
return true === $this->position;
4345
}
4446

4547
public function getPosition()
@@ -55,6 +57,7 @@ public function getColumn()
5557
public function setTableName($table)
5658
{
5759
$this->table = $table;
60+
5861
return $this;
5962
}
6063
}

0 commit comments

Comments
 (0)