Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demo #61

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

demo #61

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
56 changes: 0 additions & 56 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,11 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: "8.0"
db-image: 'mysql:8.0'
reflector: "pdo-mysql"
mode: "recording"
- php-version: "8.0"
db-image: 'mysql:8.0'
reflector: "mysqli"
mode: "recording"

- php-version: "8.1"
db-image: 'mysql:8.0'
reflector: "mysqli"
mode: "recording"
- php-version: '8.1'
db-image: 'mariadb:latest'
reflector: "mysqli"
mode: "recording"

- php-version: "8.1"
db-image: 'mysql:8.0'
reflector: "mysqli"
mode: "replay-and-recording"

env:
DBA_REFLECTOR: ${{ matrix.reflector }}
DBA_MODE: ${{ matrix.mode }}
Expand Down Expand Up @@ -75,41 +57,3 @@ jobs:
mysql -uroot -h127.0.0.1 -proot < tests/schema.sql

- run: composer phpstan

replay:
name: PHPStan (reflection replay)
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- php-version: "8.1"
reflector: "mysqli"
mode: "replay"
- php-version: "8.1"
reflector: "pdo-mysql"
mode: "replay"

env:
DBA_REFLECTOR: ${{ matrix.reflector }}
DBA_MODE: ${{ matrix.mode }}

steps:
- uses: actions/checkout@v2
with:
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}

- name: Setup PHP
id: setup-php
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none

- uses: "ramsey/composer-install@v2"
with:
composer-options: "--prefer-dist --no-progress"

- run: composer phpstan
69 changes: 0 additions & 69 deletions .github/workflows/tests-postgres.yml

This file was deleted.

126 changes: 0 additions & 126 deletions .github/workflows/tests.yml

This file was deleted.

1 change: 1 addition & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
$config = RuntimeConfiguration::create();
$config->errorMode(RuntimeConfiguration::ERROR_MODE_EXCEPTION);
// $config->debugMode(true);
$config->analyzeQueryPlans(true, 2);

if (false === getenv('GITHUB_ACTION') && false === getenv('DBA_MODE')) {
putenv('DBA_MODE=replay-and-recording');
Expand Down
41 changes: 41 additions & 0 deletions demo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

function demo(\PDO $pdo): void
{
// ---------- result-set type inference ----------
$stmt = $pdo->query('SELECT email, adaid FROM ada', PDO::FETCH_ASSOC);

foreach ($stmt as $row) {
parse_str($row['adaid'], $x);
if ($row['email'] + 25) {
$x = $row['doesnotexit'];
}
}

// ---------- query plan analysis ----------

$pdo->query("SELECT * FROM `ada` WHERE email = 'test@example.com';");

// ---------- in-depth query analysis ----------

$pdo->query('SELECT * FROM unknownTable', PDO::FETCH_ASSOC);

$pdo->query('SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada', PDO::FETCH_ASSOC);

$pdo->query('SELECT doesNotExist, adaid, gesperrt, freigabe1u1 FROM ada', PDO::FETCH_ASSOC);

$stmt = $pdo->prepare('SELECT email, adaid FROM ada WHERE adaid = :adaid');
$stmt->execute([':wrongParamName' => 1]);

$stmt = $pdo->prepare('SELECT email, adaid FROM ada WHERE adaid = :adaid');
$stmt->execute();

$stmt = $pdo->prepare('SELECT email, adaid FROM ada WHERE adaid = ? and email = ?');
$stmt->execute([1]);

$stmt = $pdo->prepare('SELECT email, adaid FROM ada WHERE adaid = :adaid and email = :email');
$stmt->execute(['adaid' => 1]);

$stmt = $pdo->prepare('SELECT email, adaid FROM ada WHERE adaid = :adaid and email = :email');
$stmt->execute([':email' => 'email@example.org']);
}
5 changes: 2 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
includes:
- config/stubFiles.neon
- config/extensions.neon
- config/dba.neon

parameters:
level: max

paths:
- src/
- demo.php

bootstrapFiles:
- bootstrap.php