Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: VitexSoftware
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
43 changes: 43 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!-- Use this file to provide workspace-specific custom instructions to Copilot. For more details, visit https://code.visualstudio.com/docs/copilot/copilot-customization#_use-a-githubcopilotinstructionsmd-file -->

All code comments should be written in English.

All messages, including error messages, should be written in English.

All code should be written in PHP 8.4 or later.

All code should follow the PSR-12 coding standard.

When writing code, always include a docblock for functions and classes, describing their purpose, parameters, and return types.

When writing tests, use PHPUnit and follow the PSR-12 coding standard.

When writing documentation, use MarkDown format.

When writing commit messages, use the imperative mood and keep them concise.

When writing code comments, use complete sentences and proper grammar.

When writing code, always use meaningful variable names that describe their purpose.

When writing code, avoid using magic numbers or strings; instead, define constants for them.

When writing code, always handle exceptions properly and provide meaningful error messages.

When writing code, always include type hints for function parameters and return types.

We are using the i18n library for internationalization, so always use the _() functions for strings that need to be translated.

When writing code, always ensure that it is secure and does not expose any sensitive information.

When writing code, always consider performance and optimize where necessary.

When writing code, always ensure that it is compatible with the latest version of PHP and the libraries we are using.

When writing code, always ensure that it is well-tested and includes unit tests where applicable.

When writing code, always ensure that it is maintainable and follows best practices.

When create new class or update existing class, always create or update its phpunit test files.

After every single edit to a PHP file, always run `php -l` on the edited file to lint it and ensure code sanity before proceeding further. This is mandatory for all PHP code changes.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
versioning-strategy: increase
commit-message:
prefix: "composer"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
21 changes: 21 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: PHPUnit

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
env:
DEBIAN_FRONTEND: "noninteractive"
LC_ALL: "en_US.UTF-8"
LANG: "en_US.UTF-8"
- name: Prepare Environment
run: |
sudo apt-get install -y composer exim4
composer update
- name: Run tests
run: make phpunit
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
/.idea/
/vendor/
debian/php-vitexsoftware-fluentpdo.debhelper.log
debian/.debhelper/
debian/php-vitexsoftware-fluentpdo/
debian/debhelper-build-stamp
debian/php-vitexsoftware-fluentpdo.substvars
nbproject/
.build/
122 changes: 122 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php

declare(strict_types=1);

/**
* This file is part of the FluentPDO package.
*
* FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.
*
* For more information see readme.md
*
* @link https://github.com/VitexSoftware/fluentpdo
* @author Chris Bornhoft, start@env.ms
* @copyright 2012-2020 envms - Chris Bornhoft, Marek Lichtner
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License, version 3.0
*
* (G) 2025-2026 Vítězslav Dvořák <info@vitexsoftware.cz>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Ergebnis\PhpCsFixer\Config\Factory;
use Ergebnis\PhpCsFixer\Config\Rules;
use Ergebnis\PhpCsFixer\Config\RuleSet\Php81;

$header = <<<'HEADER'
This file is part of the FluentPDO package.

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

For more information see readme.md

@link https://github.com/VitexSoftware/fluentpdo
@author Chris Bornhoft, start@env.ms
@copyright 2012-2020 envms - Chris Bornhoft, Marek Lichtner
@license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License, version 3.0

(G) 2025-2026 Vítězslav Dvořák <info@vitexsoftware.cz>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
HEADER;

$ruleSet = Php81::create()->withHeader($header)->withRules(Rules::fromArray([
'blank_line_before_statement' => [
'statements' => [
'break',
'continue',
'declare',
'default',
'do',
'exit',
'for',
'foreach',
'goto',
'if',
'include',
'include_once',
'require',
'require_once',
'return',
'switch',
'throw',
'try',
'while',
],
],
'concat_space' => [
'spacing' => 'none',
],
'date_time_immutable' => false,
'error_suppression' => false,
'final_class' => false,
'mb_str_functions' => false,
'native_function_invocation' => [
'exclude' => [
'sprintf',
],
'include' => [
'@compiler_optimized',
],
'scope' => 'all',
'strict' => false,
],
'php_unit_internal_class' => false,
'php_unit_test_annotation' => [
'style' => 'prefix',
],
'php_unit_test_class_requires_covers' => false,
'return_to_yield_from' => false,
'phpdoc_array_type' => false,
'phpdoc_list_type' => false,
'attribute_empty_parentheses' => false,
'final_public_method_for_abstract_class' => false,
'class_attributes_separation' => [
'elements' => [
'const' => 'only_if_meta',
'property' => 'only_if_meta',
'trait_import' => 'none',
'case' => 'none',
],
],
'yoda_style' => false,
'php_unit_test_case_static_method_calls' => false,
]));

$config = Factory::fromRuleSet($ruleSet)->setUnsupportedPhpVersionAllowed(true);

$config->getFinder()
->append([
__DIR__.'/.php-cs-fixer.dist.php',
])
->append([
__DIR__.'/rector.php',
])
->in('src')
->in('tests');

$config->setCacheFile(__DIR__.'/.build/php-cs-fixer/.php-cs-fixer.cache');

return $config;
23 changes: 23 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"php.version": "8.2",
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#225d9c",
"activityBar.background": "#225d9c",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#dd629d",
"activityBarBadge.foreground": "#15202b",
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#225d9c",
"statusBar.background": "#194472",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#225d9c",
"statusBarItem.remoteBackground": "#194472",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#194472",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#19447299",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#194472"
}
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Changelog

All notable changes to this project will be documented in this file.

## [3.0.0] - 2025-01-21

### Added
- **PHP 8.1+ Support**: Complete modernization for PHP 8.1 and higher
- **Strict Type Declarations**: All files now use `declare(strict_types=1)`
- **Modern Type System**: Full use of PHP 8.1+ type declarations including:
- Union types (e.g., `string|null`, `array|string|null`)
- Mixed types for flexible parameters
- Proper return type declarations
- Typed properties throughout the codebase
- **Array Parameter Handling**: Automatic JSON serialization of array parameters
- **Enhanced IDE Support**: Better autocomplete and error detection with proper type hints
- **Updated Dependencies**: Modern development tools and PHPUnit 12.4+

### Changed
- **Breaking**: Minimum PHP version increased from 7.3 to 8.1
- **Package Name**: Changed from `envms/fluentpdo` to `vitexsoftware/fluentpdo`
- **Type Safety**: All method signatures updated with proper type declarations
- **Error Handling**: Improved error messages and debugging capabilities
- **Performance**: Better memory usage through strict typing

### Fixed
- **Array to String Conversion**: Fixed PHP warnings when arrays are passed as parameters
- **Type Compatibility**: Resolved all PHP 8.1+ compatibility issues
- **Method Signatures**: Updated all method signatures to match modern PHP standards

### Removed
- **PHP < 8.1 Support**: No longer supports PHP versions below 8.1

## About This Fork

This is a modernized fork of the original [envms/fluentpdo](https://github.com/envms/fluentpdo) project. The original project has been inactive since 2021, with the last commit being 3+ years old. This fork aims to:

- Provide PHP 8.1+ compatibility with modern features
- Maintain API compatibility with the original project
- Add enhanced type safety and developer experience improvements
- Keep the library up-to-date with current PHP best practices

## Migration from Original FluentPDO

If you're migrating from the original `envms/fluentpdo`, the API remains compatible, but you'll need:

1. PHP 8.1 or higher
2. Update your composer requirement to `vitexsoftware/fluentpdo`
3. Optionally add `declare(strict_types=1)` to your files for better performance

The core API and functionality remain unchanged, so your existing code should work without modifications.
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# vim: set tabstop=8 softtabstop=8 noexpandtab:
.PHONY: help
help: ## Displays this list of targets with descriptions
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: cs
cs: vendor ## Normalizes composer.json with ergebnis/composer-normalize and fixes code style issues with friendsofphp/php-cs-fixer
mkdir -p .build/php-cs-fixer
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --diff --verbose

phpdoc: clean ## Generate PHPDoc
mkdir -p docs
phpdoc --defaultpackagename=MainPackage
mv .phpdoc/build/* docs

apigen: ## Build Apigen documentation
rm -rfv docs ; mkdir docs
VERSION=`cat debian/composer.json | grep version | awk -F'"' '{print $4}'`; \
apigen generate --destination=docs --title "FluentPDO ${VERSION}" --charset UTF-8 --access-levels public --access-levels protected --php --tree -- src/
Loading