Skip to content

Commit

Permalink
Upgrade to squirrelphp/queries v2.0
Browse files Browse the repository at this point in the history
Only a small change was needed for the LargeObject usage.
Otherwise it restructures the project in line with our other packages.
  • Loading branch information
iquito committed Sep 29, 2024
1 parent 58716a3 commit 7185a7d
Show file tree
Hide file tree
Showing 19 changed files with 344 additions and 211 deletions.
12 changes: 4 additions & 8 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
/bin/vendorbin export-ignore
/build export-ignore
/tests export-ignore
/tools export-ignore
/examples export-ignore
/docker export-ignore
/vendor-bin export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/captainhook.json export-ignore
/phpstan.neon export-ignore
/phpstan-baseline.neon export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml export-ignore
/psalm-baseline.xml export-ignore
/ruleset.xml export-ignore
/.travis.yml export-ignore
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/vendor
/vendor-bin/**/vendor
/vendor-bin/**/composer.lock
/.phpunit.result.cache
/.phpcs-cache
/tests/_output
/tests/_reports
/build
/build
/tools/cache/*
!/tools/cache/.gitkeep
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ env:
- XDEBUG_MODE=coverage
language: php
php:
- '8.0'
- '8.2'
- '8.3'

before_script:
- composer self-update
Expand All @@ -20,7 +21,7 @@ script:
- composer phpstan
- composer psalm
- composer phpcs
- if [ "$TRAVIS_PULL_REQUEST" == "false" -a "${TRAVIS_PHP_VERSION:0:1}" == "8" ]; then ./cc-test-reporter after-build -t clover --exit-code $TRAVIS_TEST_RESULT; fi
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build -t clover --exit-code $TRAVIS_TEST_RESULT; fi

notifications:
email: false
48 changes: 48 additions & 0 deletions bin/vendorbin
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env php
<?php
error_reporting(E_ALL); // Report everything, even notices
set_time_limit(0); // No time limit for console commands

$projectDir = dirname(__DIR__);

$composerRunType = $_SERVER['argv'][1] ?? 'outdated';

require $projectDir.'/vendor/autoload.php';

$sourceFinder = new \Symfony\Component\Finder\Finder();
$sourceFinder->in($projectDir . '/vendor-bin')->directories()->depth(0)->sortByName();

/** @var array<string, \Symfony\Component\Process\Process> $tools */
$tools = [];

foreach ($sourceFinder as $directory) {
$toolName = $directory->getFilename();

$options = [
'--ansi',
];

if ($composerRunType === 'update') {
$options[] = '--no-progress';
}

$process = new \Symfony\Component\Process\Process(['composer', $composerRunType, ...$options]);
if (isset($_SERVER['COMPOSER_CACHE_DIR'])) {
$process->setEnv(['COMPOSER_CACHE_DIR' => $_SERVER['COMPOSER_CACHE_DIR']]);
}
$process->setWorkingDirectory($projectDir . '/vendor-bin/' . $toolName);
$process->start();
$process->wait();

echo 'Running composer ' . $composerRunType . ' for ' . $toolName . ' ...' . "\n";

$processOutput = \trim($process->getOutput());

if ($composerRunType === 'update') {
$processOutput = \trim($processOutput . "\n" . $process->getErrorOutput());
}

if (\strlen($processOutput) > 0) {
echo $processOutput . "\n";
}
}
50 changes: 28 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@
}
],
"require": {
"php": ">=8.0",
"php": ">=8.2",
"symfony/console": "^5.0|^6.0|^7.0",
"symfony/finder": "^5.0|^6.0|^7.0",
"squirrelphp/debug": "^2.0",
"squirrelphp/queries": "^1.2",
"squirrelphp/queries": "^2.0",
"squirrelphp/types": "^1.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8",
"captainhook/plugin-composer": "^5.0",
"phpunit/phpunit": "^10.0",
"mockery/mockery": "^1.0"
"captainhook/captainhook-phar": "^5.0",
"captainhook/hook-installer": "^1.0",
"phpunit/phpunit": "^11.2",
"mockery/mockery": "^1.0",
"symfony/process": "^7.0"
},
"suggest": {
"squirrelphp/queries-bundle": "Symfony integration of squirrel/queries - automatic assembling of decorated connections",
Expand All @@ -40,8 +41,13 @@
"config": {
"sort-packages": true,
"allow-plugins": {
"bamarni/composer-bin-plugin": true,
"captainhook/plugin-composer": true
"captainhook/captainhook-phar": true,
"captainhook/hook-installer": true
}
},
"extra": {
"captainhook": {
"config": "tools/captainhook.json"
}
},
"bin": [
Expand All @@ -58,19 +64,19 @@
}
},
"scripts": {
"phpstan": "vendor/bin/phpstan analyse",
"phpstan_full": "vendor/bin/phpstan clear-result-cache && vendor/bin/phpstan analyse",
"phpstan_base": "vendor/bin/phpstan analyse --generate-baseline",
"psalm": "vendor/bin/psalm --show-info=false",
"psalm_full": "vendor/bin/psalm --clear-cache && vendor/bin/psalm --show-info=false",
"psalm_base": "vendor/bin/psalm --set-baseline=psalm-baseline.xml",
"phpunit": "vendor/bin/phpunit --colors=always",
"phpunit_clover": "vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml",
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html tests/_reports",
"phpcs": "vendor/bin/phpcs --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --ignore=tests/TestEntities/NonRepositoryWithAttributeInUse.php,tests/TestEntities/UserNickname.php --colors src bin tests",
"phpcsd": "vendor/bin/phpcs -s --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --ignore=tests/TestEntities/NonRepositoryWithAttributeInUse.php,tests/TestEntities/UserNickname.php --colors src bin tests",
"phpcsfix": "vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --ignore=tests/TestEntities/NonRepositoryWithAttributeInUse.php,tests/TestEntities/UserNickname.php src bin tests",
"binupdate": "@composer bin all update --ansi",
"bininstall": "@composer bin all install --ansi"
"phpstan": "vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon",
"phpstan_full": "rm -Rf tools/cache/phpstan && vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon",
"phpstan_base": "vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon --generate-baseline=tools/phpstan-baseline.php",
"psalm": "vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --show-info=false",
"psalm_full": "vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --clear-cache && vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --show-info=false",
"psalm_base": "vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --set-baseline=tools/psalm-baseline.xml",
"phpunit": "vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --colors=always",
"phpunit_clover": "vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --coverage-text --coverage-clover build/logs/clover.xml",
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --coverage-html=tests/_reports",
"phpcs": "vendor-bin/phpcs/vendor/bin/phpcs --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --ignore=tests/TestEntities/NonRepositoryWithAttributeInUse.php,tests/TestEntities/UserNickname.php --colors src tests",
"phpcs_diff": "vendor-bin/phpcs/vendor/bin/phpcs -s --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --ignore=tests/TestEntities/NonRepositoryWithAttributeInUse.php,tests/TestEntities/UserNickname.php --colors src tests",
"phpcs_fix": "vendor-bin/phpcs/vendor/bin/phpcbf --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --ignore=tests/TestEntities/NonRepositoryWithAttributeInUse.php,tests/TestEntities/UserNickname.php --colors src tests",
"binupdate": "bin/vendorbin update",
"binoutdated": "bin/vendorbin outdated"
}
}
26 changes: 26 additions & 0 deletions docker/compose/composer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
services:
composer:
image: thecodingmachine/php:8.2-v4-cli
container_name: squirrel_composer
working_dir: /usr/src/app
command: [ "composer", "${COMPOSER_COMMAND}", "--ansi" ]
logging:
driver: "none"
volumes:
- .:/usr/src/app
- "$HOME/.cache/composer:/tmp/composer_cache"
environment:
COMPOSER_CACHE_DIR: "/tmp/composer_cache"
COMPOSER_ROOT_VERSION: 'dev-master'
# Basic config for CLI commands
PHP_INI_ERROR_REPORTING: "E_ALL"
PHP_INI_MEMORY_LIMIT: "1g"
PHP_INI_MAX_EXECUTION_TIME: 3600
# Enable Opcache + JIT
PHP_INI_OPCACHE__ENABLE_CLI: 1
PHP_INI_OPCACHE__MEMORY_CONSUMPTION: 256
PHP_INI_OPCACHE__VALIDATE_TIMESTAMPS: 0
PHP_INI_JIT_BUFFER_SIZE: "256m"
# For code coverage
PHP_EXTENSION_XDEBUG: 1
XDEBUG_MODE: coverage
5 changes: 5 additions & 0 deletions docker/composer
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Get directory of this script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

COMPOSER_COMMAND="$@" docker compose -f "$DIR/compose/composer.yml" --project-directory "$DIR/.." --project-name=squirrel_composer up --abort-on-container-exit --exit-code-from=composer --no-log-prefix composer 2>&1
152 changes: 0 additions & 152 deletions phpstan-baseline.neon

This file was deleted.

9 changes: 0 additions & 9 deletions phpstan.neon

This file was deleted.

2 changes: 1 addition & 1 deletion src/RepositoryReadOnly.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Squirrel\Entities;

use Squirrel\Connection\LargeObject;
use Squirrel\Debug\Debug;
use Squirrel\Queries\Builder\BuilderInterface;
use Squirrel\Queries\DBException;
use Squirrel\Queries\DBInterface;
use Squirrel\Queries\Exception\DBInvalidOptionException;
use Squirrel\Queries\LargeObject;
use Squirrel\Types\Coerce;

/**
Expand Down
Loading

0 comments on commit 7185a7d

Please sign in to comment.