Skip to content

Commit 82f6aa5

Browse files
committed
Refrain from using deprecated annotation key/value pairs
1 parent 632c01d commit 82f6aa5

File tree

9 files changed

+45
-30
lines changed

9 files changed

+45
-30
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ RDBMS support for the XP Framework: MySQL, Sybase, MSSQL, PostgreSQL, SQLite3, I
33

44
## ?.?.? / ????-??-??
55

6+
## 12.0.3 / 2020-04-05
7+
8+
* Implemented RFC #335: Remove deprecated key/value pair annotation syntax
9+
(@thekid)
10+
611
## 12.0.2 / 2019-12-01
712

813
* Made compatible with XP 10 - @thekid

src/main/php/rdbms/finder/Finder.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
* return Job::getPeer();
1616
* }
1717
*
18-
* #[@finder(kind= ENTITY)]
18+
* #[@finder(['kind' => ENTITY])]
1919
* public function byPrimary($pk) {
2020
* return new Criteria(array('job_id', $pk, EQUAL));
2121
* }
2222
*
23-
* #[@finder(kind= COLLECTION)]
23+
* #[@finder(['kind' => COLLECTION])]
2424
* public function expiredJobs() {
2525
* return new Criteria(array('expire_at', Date::now(), GREATER_EQUAL));
2626
* }

src/main/php/rdbms/finder/package-info.xp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
* return News::getPeer();
2020
* }
2121
*
22-
* #[@finder(kind= ENTITY)]
22+
* #[@finder(['kind' => ENTITY])]
2323
* public function byPrimary($pk) {
2424
* return new Criteria(array('news_id', $pk, EQUAL));
2525
* }
2626
*
27-
* #[@finder(kind= COLLECTION)]
27+
* #[@finder(['kind' => COLLECTION])]
2828
* public function allNews() {
2929
* return new Criteria();
3030
* }
3131
*
32-
* #[@finder(kind= COLLECTION)]
32+
* #[@finder(['kind' => COLLECTION])]
3333
* public function todaysHelloNews() {
3434
* return new Criteria(Restrictions::allOf(
3535
* Restrictions::like('title', 'Hello%'),

src/test/php/rdbms/unittest/FinderTest.class.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
<?php namespace rdbms\unittest;
22

3+
use lang\IllegalArgumentException;
4+
use lang\MethodNotImplementedException;
5+
use rdbms\DriverManager;
36
use rdbms\Peer;
4-
use rdbms\finder\FinderMethod;
57
use rdbms\SQLExpression;
6-
use lang\MethodNotImplementedException;
7-
use lang\IllegalArgumentException;
88
use rdbms\finder\FinderException;
9-
use rdbms\finder\NoSuchEntityException;
10-
use unittest\TestCase;
11-
use rdbms\DriverManager;
9+
use rdbms\finder\FinderMethod;
1210
use rdbms\finder\GenericFinder;
11+
use rdbms\finder\NoSuchEntityException;
1312
use rdbms\unittest\dataset\Job;
1413
use rdbms\unittest\dataset\JobFinder;
1514
use rdbms\unittest\mock\MockResultSet;
15+
use rdbms\unittest\mock\RegisterMockConnection;
16+
use unittest\TestCase;
1617

1718
/**
1819
* TestCase
1920
*
2021
* @see xp://rdbms.finder.Finder
2122
*/
22-
#[@action(new \rdbms\unittest\mock\RegisterMockConnection())]
23+
#[@action(new RegisterMockConnection())]
2324
class FinderTest extends TestCase {
2425
protected $fixture = null;
2526

@@ -42,7 +43,7 @@ public function setUp() {
4243
protected function method($name) {
4344
try {
4445
return $this->fixture->method($name);
45-
} catch (\rdbms\finder\FinderException $e) {
46+
} catch (FinderException $e) {
4647
throw $e->getCause();
4748
}
4849
}
@@ -321,7 +322,7 @@ public function findAllWrapsSQLException() {
321322
$this->fixture->findAll(new \rdbms\Criteria());
322323
}
323324

324-
#[@test, @expect(class= 'rdbms.finder.FinderException', withMessage= '/No such method nonExistantMethod/')]
325+
#[@test, @expect(['class' => FinderException::class, 'withMessage' => '/No such method nonExistantMethod/'])]
325326
public function fluentNonExistantFinder() {
326327
$this->fixture->findAll()->nonExistantMethod(new \rdbms\Criteria());
327328
}

src/test/php/rdbms/unittest/integration/MsSQLIntegrationTest.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace rdbms\unittest\integration;
22

3+
use rdbms\SQLStatementFailedException;
34
use util\Date;
45

56
/**
@@ -158,7 +159,7 @@ public function selectEmptyVarBinary() {
158159
$this->assertNull($this->db()->query('select cast("" as varbinary) as value')->next('value'));
159160
}
160161

161-
#[@test, @expect(class = 'rdbms.SQLStatementFailedException', withMessage= '/More power/')]
162+
#[@test, @expect(['class' => SQLStatementFailedException::class, 'withMessage' => '/More power/'])]
162163
public function raiseError() {
163164
$this->db()->query('raiserror ("More power", 16, 1)');
164165
}

src/test/php/rdbms/unittest/integration/SybaseIntegrationTest.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php namespace rdbms\unittest\integration;
22

33
use rdbms\SQLStatementFailedException;
4+
use unittest\PrerequisitesNotMetError;
45
use util\Bytes;
56
use util\Date;
6-
use unittest\PrerequisitesNotMetError;
77

88
/**
99
* Sybase integration test
@@ -155,7 +155,7 @@ public function selectMaxUnsignedBigInt() {
155155
parent::selectMaxUnsignedBigInt();
156156
}
157157

158-
#[@test, @expect(class = 'rdbms.SQLStatementFailedException', withMessage= '/More power/')]
158+
#[@test, @expect(['class' => SQLStatementFailedException::class, 'withMessage' => '/More power/'])]
159159
public function raiseError() {
160160
$this->db()->query('raiserror 61000 "More power"');
161161
}

src/test/php/rdbms/unittest/mysql/MySqlxBufferedResultSetTest.class.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
<?php namespace rdbms\unittest\mysql;
22

3+
use lang\ClassLoader;
4+
use rdbms\SQLException;
35
use rdbms\mysqlx\MySqlxBufferedResultSet;
46
use rdbms\mysqlx\MySqlxProtocol;
7+
use unittest\TestCase;
58

69
/**
710
* TestCase
811
*
912
* @see xp://rdbms.mysqlx.MySqlxBufferedResultSet
1013
*/
11-
class MySqlxBufferedResultSetTest extends \unittest\TestCase {
14+
class MySqlxBufferedResultSetTest extends TestCase {
1215
protected static $proto;
1316

1417
#[@beforeClass]
1518
public static function mockProtocol() {
1619
$parent= class_exists('\\lang\\Object', false) ? 'lang.Object' : null;
17-
self::$proto= \lang\ClassLoader::defineClass('rdbms.unittest.mysql.MockMysqlProtocol', $parent, [], '{
20+
self::$proto= ClassLoader::defineClass('rdbms.unittest.mysql.MockMysqlProtocol', $parent, [], '{
1821
private $records= [];
1922
2023
public function __construct($records) {
@@ -161,17 +164,17 @@ public function seek_to_1() {
161164
$this->assertEquals($records[1], $fixture->next());
162165
}
163166

164-
#[@test, @expect(class= 'rdbms.SQLException', withMessage= 'Cannot seek to offset 1, out of bounds')]
167+
#[@test, @expect(['class' => SQLException::class, 'withMessage' => 'Cannot seek to offset 1, out of bounds'])]
165168
public function seek_to_offset_exceeding_length() {
166169
$fixture= $this->newResultSet([])->seek(1);
167170
}
168171

169-
#[@test, @expect(class= 'rdbms.SQLException', withMessage= 'Cannot seek to offset -1, out of bounds')]
172+
#[@test, @expect(['class' => SQLException::class, 'withMessage' => 'Cannot seek to offset -1, out of bounds'])]
170173
public function seek_to_negative_offset() {
171174
$fixture= $this->newResultSet([])->seek(-1);
172175
}
173176

174-
#[@test, @expect(class= 'rdbms.SQLException', withMessage= 'Cannot seek to offset 0, out of bounds')]
177+
#[@test, @expect(['class' => SQLException::class, 'withMessage' => 'Cannot seek to offset 0, out of bounds'])]
175178
public function seek_to_zero_offset_on_empty() {
176179
$fixture= $this->newResultSet([])->seek(0);
177180
}

src/test/php/rdbms/unittest/tds/TdsBufferedResultSetTest.class.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
<?php namespace rdbms\unittest\tds;
22

3+
use lang\ClassLoader;
4+
use rdbms\SQLException;
35
use rdbms\tds\TdsBufferedResultSet;
46
use rdbms\tds\TdsProtocol;
7+
use unittest\TestCase;
58

69
/**
710
* TestCase
811
*
912
* @see xp://rdbms.tds.TdsBufferedResultSet
1013
*/
11-
class TdsBufferedResultSetTest extends \unittest\TestCase {
14+
class TdsBufferedResultSetTest extends TestCase {
1215
protected static $proto;
1316

1417
#[@beforeClass]
1518
public static function mockProtocol() {
1619
$parent= class_exists('\\lang\\Object', false) ? 'lang.Object' : null;
17-
self::$proto= \lang\ClassLoader::defineClass('rdbms.unittest.tds.MockTdsProtocol', $parent, [], '{
20+
self::$proto= ClassLoader::defineClass('rdbms.unittest.tds.MockTdsProtocol', $parent, [], '{
1821
private $records= [];
1922
2023
public function __construct($records) {
@@ -161,17 +164,17 @@ public function seek_to_1() {
161164
$this->assertEquals($records[1], $fixture->next());
162165
}
163166

164-
#[@test, @expect(class= 'rdbms.SQLException', withMessage= 'Cannot seek to offset 1, out of bounds')]
167+
#[@test, @expect(['class' => SQLException::class, 'withMessage' => 'Cannot seek to offset 1, out of bounds'])]
165168
public function seek_to_offset_exceeding_length() {
166169
$fixture= $this->newResultSet([])->seek(1);
167170
}
168171

169-
#[@test, @expect(class= 'rdbms.SQLException', withMessage= 'Cannot seek to offset -1, out of bounds')]
172+
#[@test, @expect(['class' => SQLException::class, 'withMessage' => 'Cannot seek to offset -1, out of bounds'])]
170173
public function seek_to_negative_offset() {
171174
$fixture= $this->newResultSet([])->seek(-1);
172175
}
173176

174-
#[@test, @expect(class= 'rdbms.SQLException', withMessage= 'Cannot seek to offset 0, out of bounds')]
177+
#[@test, @expect(['class' => SQLException::class, 'withMessage' => 'Cannot seek to offset 0, out of bounds'])]
175178
public function seek_to_zero_offset_on_empty() {
176179
$fixture= $this->newResultSet([])->seek(0);
177180
}

src/test/php/rdbms/unittest/tds/TdsDataStreamTest.class.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
<?php namespace rdbms\unittest\tds;
22

33
use lang\ClassLoader;
4+
use lang\IllegalArgumentException;
45
use peer\Socket;
56
use rdbms\tds\TdsDataStream;
67
use rdbms\tds\TdsProtocolException;
8+
use unittest\TestCase;
79
use util\Bytes;
810

911
/**
1012
* TestCase
1113
*
1214
* @see xp://rdbms.tds.TdsDataStream
1315
*/
14-
class TdsDataStreamTest extends \unittest\TestCase {
16+
class TdsDataStreamTest extends TestCase {
1517
protected static $sock;
1618

1719
/**
1820
* Defines the mock socket class necessary for these tests
1921
*/
2022
#[@beforeClass]
2123
public static function mockSocket() {
22-
self::$sock= ClassLoader::defineClass('rdbms.unittest.tds.MockTdsSocket', 'peer.Socket', [], '{
24+
self::$sock= ClassLoader::defineClass('rdbms.unittest.tds.MockTdsSocket', Socket::class, [], '{
2325
public $bytes;
2426
protected $offset= 0;
2527
@@ -190,7 +192,7 @@ public function beginDoesNotDiscardFirstBytes() {
190192
$this->assertEquals("\xA2", $str->getToken());
191193
}
192194

193-
#[@test, @expect(class = 'lang.IllegalArgumentException', withMessage= '/must be at least 9/')]
195+
#[@test, @expect(['class' => IllegalArgumentException::class, 'withMessage' => '/must be at least 9/'])]
194196
public function illegalPacketSize() {
195197
$this->newDataStream('', 1);
196198
}

0 commit comments

Comments
 (0)