Skip to content

Commit 63f1ce5

Browse files
authored
Use a PHP object's method as the query (#372)
* ci: upgrade workflow * feature: split query collection into directory/class subclasses for #84 * wip: break Query into SqlQuery and PhpQuery * feature: php object query for #84 * build: php 8.1 compatibility * tweak: remove non-existant test * tweak: import DateTimeInterface * tweak: remove superfluous typehint * tweak: ignore complexity of abstract query class
1 parent 01fe449 commit 63f1ce5

18 files changed

+780
-476
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: CI
22

3-
on: [push]
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
actions: read
8+
id-token: none
49

510
jobs:
611
composer:
@@ -24,7 +29,7 @@ jobs:
2429
php_version: ${{ matrix.php }}
2530

2631
- name: Archive build
27-
run: mkdir /tmp/github-actions/ && tar -cvf /tmp/github-actions/build.tar ./
32+
run: mkdir /tmp/github-actions/ && tar --exclude=".git" -cvf /tmp/github-actions/build.tar ./
2833

2934
- name: Upload build archive for test runners
3035
uses: actions/upload-artifact@v4
@@ -127,7 +132,7 @@ jobs:
127132
run: tar -xvf /tmp/github-actions/build.tar ./
128133

129134
- name: PHP Mess Detector
130-
uses: php-actions/phpmd@v1
135+
uses: php-actions/phpmd@v2
131136
with:
132137
php_version: ${{ matrix.php }}
133138
path: src/
@@ -160,12 +165,15 @@ jobs:
160165
remove_old_artifacts:
161166
runs-on: ubuntu-latest
162167

168+
permissions:
169+
actions: write
170+
163171
steps:
164172
- name: Remove old artifacts for prior workflow runs on this repository
165173
env:
166174
GH_TOKEN: ${{ github.token }}
167175
run: |
168-
gh api "/repos/${{ github.repository }}/actions/artifacts?name=build-artifact" | jq ".artifacts[] | select(.name | startswith(\"build-artifact\")) | .id" > artifact-id-list.txt
176+
gh api "/repos/${{ github.repository }}/actions/artifacts" | jq ".artifacts[] | select(.name | startswith(\"build-artifact\")) | .id" > artifact-id-list.txt
169177
while read id
170178
do
171179
echo -n "Deleting artifact ID $id ... "

composer.lock

Lines changed: 53 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpcs.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
<rule ref="Generic.Files.OneObjectStructurePerFile" />
3131
<rule ref="Generic.Files.OneTraitPerFile" />
3232
<rule ref="Generic.Formatting.DisallowMultipleStatements" />
33-
<rule ref="Generic.Formatting.NoSpaceAfterCast" />
3433
<rule ref="Generic.Functions.FunctionCallArgumentSpacing" />
3534
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />
3635
<rule ref="Generic.Metrics.CyclomaticComplexity" />

src/Database.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Database {
2525
/** @var array<Driver> */
2626
protected array $driverArray;
2727
protected Connection $currentConnectionName;
28+
protected string $appNamespace = "\\App";
2829

2930
public function __construct(SettingsInterface...$connectionSettings) {
3031
if(empty($connectionSettings)) {
@@ -36,6 +37,14 @@ public function __construct(SettingsInterface...$connectionSettings) {
3637
$this->storeQueryCollectionFactoryFromSettings($connectionSettings);
3738
}
3839

40+
public function setAppNameSpace(string $namespace):void {
41+
if(!str_starts_with($namespace, "\\")) {
42+
$namespace = "\\$namespace";
43+
}
44+
45+
$this->appNamespace = $namespace;
46+
}
47+
3948
public function insert(string $queryName, mixed...$bindings):string {
4049
$result = $this->query($queryName, $bindings);
4150
return $result->lastInsertId();

0 commit comments

Comments
 (0)