Skip to content

Commit 5ac97cc

Browse files
committed
Merge branch 'feature/php-74' into develop
2 parents 0b1d583 + 16e3312 commit 5ac97cc

10 files changed

Lines changed: 57 additions & 60 deletions

File tree

.github/workflows/main.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Testing
2+
on: [push, pull_request]
3+
jobs:
4+
laravel:
5+
name: (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
6+
runs-on: ${{ matrix.operating-system }}
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
operating-system: [ubuntu-latest, windows-latest, macos-latest]
11+
php-versions: ['7.2', '7.3', '7.4']
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Setup PHP, with composer and extensions
16+
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
17+
with:
18+
php-version: ${{ matrix.php-versions }}
19+
extensions: mbstring, dom, fileinfo, pdo_sqlite
20+
coverage: xdebug #optional
21+
- name: Get composer cache directory
22+
id: composer-cache
23+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
24+
- name: Cache composer dependencies
25+
uses: actions/cache@v2
26+
with:
27+
path: ${{ steps.composer-cache.outputs.dir }}
28+
# Use composer.json for key, if composer.lock is not committed.
29+
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
30+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
31+
restore-keys: ${{ runner.os }}-composer-
32+
- name: Install Composer dependencies
33+
run: composer install --no-progress --prefer-dist --optimize-autoloader
34+
35+
- name: Test with phpunit
36+
run: vendor/bin/phpunit --coverage-text

.travis.yml

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

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
"files": ["src/autoload.php"]
1515
},
1616
"minimum-stability": "stable",
17-
"require": {},
1817
"require-dev": {
1918
"crodas/autoloader": "^0.1.16",
20-
"crodas/phpunit-compat": "^1.7"
19+
"crodas/phpunit-compat": "^1.7",
20+
"fpoirotte/php_parsergenerator": "^0.2.4"
2121
}
2222
}

src/SQLParser/Lexer.lex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Lexer
5252
%matchlongest 1
5353
5454
55-
whitespace = /[ \t\n]+/
55+
whitespace = /[ \t\r\n]+/
5656
5757
comment = /\-\-[^\n]+/
5858
number = /[0-9]+(\.[0-9]+)?|0x[0-9a-fA-F]+/

src/SQLParser/Lexer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function yylex1()
7575
}
7676
do {
7777
$rules = array(
78-
'/\G[ \t\n]+/i ',
78+
'/\G[ \t\r\n]+/i ',
7979
'/\G\"/i ',
8080
'/\G\'/i ',
8181
'/\G`/i ',

src/SQLParser/Parser.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
/* Driver template for the PHP_SQLParser_rGenerator parser generator. (PHP port of LEMON)
33
*/
44

5+
// code external to the class is included here
6+
#line 2 "src/SQLParser/Parser.y"
7+
8+
use SQLParser\Stmt;
9+
#line 11 "src/SQLParser/Parser.php"
10+
511
/**
612
* This can be used to store both the string representation of
713
* a token, and any useful meta-data associated with the token.
814
*
915
* meta-data should be stored as an array
1016
*/
11-
class SQLParser_yyToken implements ArrayAccess
17+
class SQLParser_yyToken implements \ArrayAccess
1218
{
1319
public $string = '';
1420
public $metadata = array();
@@ -93,12 +99,6 @@ class SQLParser_yyStackEntry
9399
** is the value of the token */
94100
};
95101

96-
// code external to the class is included here
97-
#line 2 "src/SQLParser/Parser.y"
98-
99-
use SQLParser\Stmt;
100-
#line 102 "src/SQLParser/Parser.php"
101-
102102
// declare_class is output here
103103
#line 6 "src/SQLParser/Parser.y"
104104
class SQLParser_Parser #line 107 "src/SQLParser/Parser.php"
@@ -2519,7 +2519,7 @@ function yy_r66(){ $this->_retvalue = []; }
25192519
#line 138 "src/SQLParser/Parser.y"
25202520
function yy_r67(){
25212521
$this->_retvalue = $this->yystack[$this->yyidx + -3]->minor->setTable($this->yystack[$this->yyidx + -1]->minor[0], $this->yystack[$this->yyidx + -1]->minor[1]);
2522-
if ($this->yystack[$this->yyidx + 0]->minor[0]) {
2522+
if (is_array($this->yystack[$this->yyidx + 0]->minor) && $this->yystack[$this->yyidx + 0]->minor[0]) {
25232523
$this->_retvalue->{$this->yystack[$this->yyidx + 0]->minor[0]}($this->yystack[$this->yyidx + 0]->minor[1]);
25242524
}
25252525
}

src/SQLParser/Parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ joins(A) ::= . { A = []; }
137137

138138
join(A) ::= join_type(B) JOIN table_with_alias(C) join_condition(D). {
139139
A = B->setTable(C[0], C[1]);
140-
if (D[0]) {
140+
if (is_array(D) && D[0]) {
141141
A->{D[0]}(D[1]);
142142
}
143143
}

tests/AllTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,11 @@ public function testFeaturesGeneration($parser, $sql, $file, $engine)
178178

179179
/**
180180
* @dataProvider featuresException
181-
* @expectedException RuntimeException
182181
*/
183182
public function testFeaturesParsingErrors($sql, $parser)
184183
{
184+
$this->expectException(RuntimeException::class);
185+
185186
$parser->parse($sql);
186187
}
187188

tests/TableDiffTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ public function testTableDiff($tableDiff, $prev, $current, Array $expected)
3636
}
3737
}
3838

39-
/**
40-
* @expectedException InvalidArgumentException
41-
*/
4239
public function testTableDiffException()
4340
{
41+
$this->expectException(InvalidArgumentException::class);
4442
$diff = new SQL\TableDiff;
4543
$diff->diff("SELECT 1", "SELECT 2");
4644
}

tests/WriterTest.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,30 @@ public function testExprReturnsNull()
7777
$x = new SQLParser\Stmt\Expr('xxx');
7878
$this->assertNull($x->getMember(10));
7979
}
80-
/**
81-
* @expectedException InvalidArgumentException
82-
*/
80+
8381
public function testInvalidWriterObject()
8482
{
83+
$this->expectException(InvalidArgumentException::class);
8584
Writer::create($this);
8685
}
8786

88-
/**
89-
* @expectedException InvalidArgumentException
90-
*/
9187
public function testInvalidWriterInstance()
9288
{
89+
$this->expectException(InvalidArgumentException::class);
9390
Writer::setInstance($this);
9491
}
9592

9693
public function testWriterFromPDO()
9794
{
98-
$driver = new PDO("sqlite:memory");
95+
$driver = new PDO("sqlite::memory:");
9996
Writer::setInstance($driver);
10097

10198
$this->assertTrue(Writer::getInstance() instanceof SQL\Writer\SQLite);
10299
}
103100

104-
/**
105-
* @expectedException InvalidArgumentException
106-
*/
107101
public function testInvalidVariableValue()
108102
{
103+
$this->expectException(InvalidArgumentException::class);
109104
$parser = new SQLParser();
110105
$queries = $parser->parse("SELECT * FROM t WHERE y = :name");
111106
Writer::create($queries[0], ['name' => ['invalid value']]);

0 commit comments

Comments
 (0)