Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ tests/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
CONTRIBUTING.md export-ignore
phpunit.xml.dist export-ignore
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
open-pull-requests-limit: 5
- package-ecosystem: composer
directory: /
schedule:
interval: monthly
open-pull-requests-limit: 5
versioning-strategy: widen
61 changes: 61 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

permissions:
contents: read

jobs:
test:
strategy:
fail-fast: false
matrix:
php-versions: [ '8.2', '8.3', '8.4', '8.5' ]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
tools: composer:v2
extensions: pdo_sqlite

- name: Validate Composer metadata
run: |
if [ -f composer.lock ]; then
composer validate --strict --no-interaction
else
composer validate --strict --no-check-lock --no-interaction
fi

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache Composer packages
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php-versions }}-${{ hashFiles('**/composer.json', '**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.php-versions }}-

- name: Install dependencies
run: |
if [ -f composer.lock ]; then
composer install --prefer-dist --no-progress --no-interaction
else
composer update --prefer-dist --no-progress --no-interaction
fi

- name: Run test suite
run: vendor/bin/phpunit
7 changes: 0 additions & 7 deletions .scrutinizer.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Port PDO adapter

[![Latest Version](https://img.shields.io/github/release/portphp/pdo.svg?style=flat-square)](https://github.com/portphp/pdo/releases)
[![Build Status](https://travis-ci.org/portphp/pdo.svg)](https://travis-ci.org/portphp/pdo)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/portphp/pdo/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/portphp/pdo/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/portphp/pdo/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/portphp/pdo/?branch=master)
[![CI](https://github.com/portphp/pdo/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/portphp/pdo/actions/workflows/test.yml)
[![PHP Version](https://img.shields.io/packagist/php-v/portphp/pdo.svg?style=flat-square)](https://packagist.org/packages/portphp/pdo)

**Requirements:** PHP ^8.2 (tested on 8.2–8.5). Requires `portphp/portphp` ^2.0.

PDO adapter for [Port](https://github.com/portphp).

Expand All @@ -22,7 +23,7 @@ of the Composer documentation.

## Documentation

Documentation is available at http://docs.portphp.org.
Documentation is available at https://portphp.readthedocs.io.

## Issues and feature requests

Expand All @@ -34,11 +35,6 @@ Contributions are very welcome. Please see [CONTRIBUTING.md](CONTRIBUTING.md) fo
details. Thanks to [everyone who has contributed](https://github.com/portphp/pdo/graphs/contributors)
already.

## Security

If you discover any security-related issues, please contact us at
[security@portphp.org](mailto:security@portphp.org).

## License

This package is licensed under the [MIT license](LICENSE).
5 changes: 5 additions & 0 deletions UPGRADE-2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Upgrade from 1.x to 2.0

- Minimum PHP is **8.2** (`^8.2`).
- Requires `portphp/portphp` **^2.0**.
- CI is GitHub Actions (Travis/Scrutinizer removed).
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
},
{
"name": "Community contributors",
"homepage": "https://github.com/portphp/dbal-adapter/graphs/contributors"
"homepage": "https://github.com/portphp/pdo/graphs/contributors"
}
],
"support": {
"issues": "https://github.com/portphp/portphp/issues",
"source": "https://github.com/portphp/dbal-adapter",
"docs": "https://docs.portphp.org"
"source": "https://github.com/portphp/pdo",
"docs": "https://portphp.readthedocs.io"
},
"require": {
"php": ">=5.4.0",
"php": "^8.2",
"ext-pdo": "*",
"portphp/portphp": "^1.0.0"
"portphp/portphp": "^2.0"
},
"autoload": {
"psr-4": {
"Port\\Pdo\\": "src/"
}
},
"require-dev": {
"ext-sqlite3": "*",
"phpunit/phpunit": "^4.0"
"ext-pdo_sqlite": "*",
"phpunit/phpunit": "^9.6"
},
"autoload-dev": {
"psr-4": {
Expand Down
20 changes: 7 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
verbose="true"
>
beStrictAboutOutputDuringTests="true"
failOnRisky="false"
failOnWarning="true">
<testsuites>
<testsuite name="portphp/pdo-adapter">
<directory suffix=".php">./tests/</directory>
<testsuite name="portphp/pdo">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
14 changes: 7 additions & 7 deletions src/PdoWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(\PDO $pdo, $tableName)
}
}

public function prepare()
public function prepare(): void
{
$this->stack = [];
$this->statement = null;
Expand All @@ -64,7 +64,7 @@ public function prepare()
/**
* {@inheritdoc}
*/
public function writeItem(array $item)
public function writeItem(array $item): void
{
if (null === $this->statement) {
try {
Expand All @@ -75,21 +75,21 @@ public function writeItem(array $item)
substr(str_repeat('?,', count($item)), 0, -1)
));
} catch (\PDOException $e) {
throw new WriterException('Failed to send query', null, $e);
throw new WriterException('Failed to send query', 0, $e);
}
}

$this->stack[] = array_values($item);
}

public function finish()
public function finish(): void
{
$this->flush();

return $this;

}

public function flush()
public function flush(): void
{
$this->pdo->beginTransaction();

Expand All @@ -102,7 +102,7 @@ public function flush()
$this->pdo->commit();
} catch (\PDOException $e) {
$this->pdo->rollBack();
throw new WriterException('Failed to write to database', null, $e);
throw new WriterException('Failed to write to database', 0, $e);
}
}
}
11 changes: 9 additions & 2 deletions tests/PdoReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Port\Pdo\PdoReader;

class PdoReaderTest extends \PHPUnit_Framework_TestCase
class PdoReaderTest extends \PHPUnit\Framework\TestCase
{
public function testCount()
{
Expand All @@ -15,7 +15,7 @@ public function testIterate()
{
$i=1;
foreach ($this->getReader() as $row) {
$this->assertInternalType('array', $row);
$this->assertIsArray( $row);
$this->assertEquals('user-'.$i, $row['username']);
$i++;
}
Expand All @@ -24,11 +24,18 @@ public function testIterate()
public function testReaderRewindWorksCorrectly()
{
$reader = $this->getReader();
$count1 = 0;
foreach ($reader as $row) {
$count1++;
}

$count2 = 0;
foreach ($reader as $row) {
$count2++;
}

$this->assertSame($count1, $count2);
$this->assertSame(100, $count1);
}

public function getConnection()
Expand Down
Loading
Loading