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

PHP ^7.4 Compatibility (Including 8.1) #1805

Merged
merged 42 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f7c7578
Make compatible with Interator interface
oojacoboo Nov 30, 2021
d091876
Typo
oojacoboo Nov 30, 2021
fe3c0db
Typo
oojacoboo Nov 30, 2021
269ad0f
Additional interface compatibility fixes
oojacoboo Nov 30, 2021
5540c66
More php8 fixes
oojacoboo Nov 30, 2021
179921e
php8
oojacoboo Nov 30, 2021
ca4d2c9
php8
oojacoboo Nov 30, 2021
7240494
Add missing use statement
oojacoboo Nov 30, 2021
28f1590
php8
oojacoboo Nov 30, 2021
625e4a1
php8
oojacoboo Nov 30, 2021
3e29a5a
php8
oojacoboo Nov 30, 2021
eb501f5
Support up to version 3 of PSR log interface
oojacoboo Dec 1, 2021
551009e
Reorder requires
oojacoboo Dec 1, 2021
1fc7034
All tests passing
oojacoboo Dec 5, 2021
f22efcc
Merge branch 'master' into php8
oojacoboo Dec 5, 2021
0d033bb
Update github workflows
oojacoboo Dec 5, 2021
c876657
Add manual workflow execution
oojacoboo Dec 5, 2021
503dbca
Run static analysis on 8.1
oojacoboo Dec 5, 2021
03370a3
CS fixes
oojacoboo Dec 5, 2021
073d2bc
Only support >8.0 for CI
oojacoboo Dec 5, 2021
18ab6fd
Upgrade PHPStan
oojacoboo Dec 5, 2021
d34786d
SQLite default value error
oojacoboo Dec 5, 2021
d4e3418
Target > 8.0
oojacoboo Dec 5, 2021
88f1834
PHPStan and phpcs fixes
oojacoboo Dec 5, 2021
d110752
Merge branch 'master'
oojacoboo Dec 6, 2021
09a72be
Added BC support for 7.4
oojacoboo Dec 7, 2021
7631399
Remove PHPStan ignore annotations
oojacoboo Dec 7, 2021
2d2d278
CS fixes
oojacoboo Dec 7, 2021
d371202
Removed psalm-suppress InvalidArgument
oojacoboo Dec 8, 2021
32ab619
Merge branch 'master'
oojacoboo Dec 8, 2021
3f3d7ed
Removed phpstan ignores and resolved other phpstan issues
oojacoboo Dec 8, 2021
6c9ceb5
Moved config option to main config
oojacoboo Dec 8, 2021
594c207
Remove unused use statement
oojacoboo Dec 8, 2021
f3a62e7
Don't exclude tests
oojacoboo Dec 9, 2021
c7a60e4
Exclude checks on Symfony 4 for PHP ^8
oojacoboo Dec 9, 2021
5e89932
Exclude all Syfony 4 versions with PHP ^8
oojacoboo Dec 9, 2021
f268ce5
Job matrix syntax update
oojacoboo Dec 9, 2021
2aa8bc6
Remove polyfill for PHP 7.3
oojacoboo Dec 10, 2021
26b0cbe
Fixed typing issues with strict declarations
oojacoboo Dec 10, 2021
b83466d
Incorrect phpdoc
oojacoboo Dec 10, 2021
7430e1c
Add testsuite command
oojacoboo Dec 10, 2021
3663163
Reorder annotations
oojacoboo Dec 10, 2021
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
14 changes: 9 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@ on:
branches:
- 'master'
pull_request:
workflow_dispatch:

jobs:
testsuite:
name: "Test Suite"
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
php-version: [ '7.3', '7.4', '8.1' ]
php-version: [ '7.4', '8.0', '8.1' ]
db-type: [ sqlite, mysql, pgsql, agnostic ]
symfony-version: [ '4-min', '4-max', '5-min', '5-max' ]
exclude:
- php-version: '8.1'
oojacoboo marked this conversation as resolved.
Show resolved Hide resolved
symfony-version: '4-min'
- symfony-version: '4-min'
php-version: '8.0'
- symfony-version: '4-min'
php-version: '8.1'
steps:
- name: Install PostgreSQL latest
if: matrix.db-type == 'pgsql' && matrix.php-version != '7.3'
Expand Down Expand Up @@ -120,10 +124,10 @@ jobs:
code-style-and-static-analysis:
runs-on: ubuntu-18.04
steps:
- name: Setup PHP 7.4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.1
extensions: json, libxml, pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, sqlite3
coverage: pcov

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@
}
],
"require": {
"php": ">=7.3",
"php": ">=7.4",
"psr/log": "^1.0||^2.0||^3.0",
"symfony/yaml": "^3.4.0||^4.0.0||^5.0.0",
"symfony/config": "^3.4.0||^4.0.0||^5.0.0",
"symfony/console": "^3.4.0||^4.0.0||^5.0.0",
"symfony/filesystem": "^3.4.0||^4.0.0||^5.0.0",
"symfony/finder": "^3.4.0||^4.0.0||^5.0.0",
"symfony/translation": "^3.4.0||^4.0.0||^5.0.0",
"symfony/validator": "^3.4.0||^4.0.0||^5.0.0",
"symfony/polyfill-php73": "^1.8",
"psr/log": "^1.0"
"symfony/polyfill-php73": "^1.8"
oojacoboo marked this conversation as resolved.
Show resolved Hide resolved
},
"require-dev": {
"ext-pdo": "*",
"ext-json": "*",
"monolog/monolog": "^1.3",
"phpstan/phpstan": "^1.0.0",
"phpstan/phpstan": "^1.2",
"phpunit/phpunit": "^9.5.0",
"spryker/code-sniffer": "^0.17.2",
"psalm/phar": "4.9.3",
"psalm/phar": "^4.14",
"mikey179/vfsstream": "^1.6"
},
"suggest": {
Expand Down
1 change: 0 additions & 1 deletion phpstan-baseline.neon

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ parameters:
level: 6
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false
paths:
- '%rootDir%/../../../src/'
excludePaths:
oojacoboo marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 1 addition & 1 deletion src/Propel/Common/Config/Loader/IniFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class IniFileLoader extends FileLoader
*
* @var string
*/
private $nestSeparator = '.';
private string $nestSeparator = '.';
dereuromark marked this conversation as resolved.
Show resolved Hide resolved

/**
* Returns true if this class supports the given resource.
Expand Down
4 changes: 2 additions & 2 deletions src/Propel/Common/Config/XmlToArrayConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected static function simpleXmlToArray(SimpleXMLElement $xml): array

// if it's not an array, then it was empty, thus a value/string
if ($child === []) {
$child = static::getConvertedXmlValue($v);
$child = self::getConvertedXmlValue($v);
dereuromark marked this conversation as resolved.
Show resolved Hide resolved
}

// add the children attributes as if they where children
Expand All @@ -104,7 +104,7 @@ protected static function simpleXmlToArray(SimpleXMLElement $xml): array
if (is_string($child)) {
$child = [];
}
$child[$ak] = static::getConvertedXmlValue($av);
$child[$ak] = self::getConvertedXmlValue($av);
}
}

Expand Down
73 changes: 36 additions & 37 deletions src/Propel/Generator/Builder/DataModelBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

namespace Propel\Generator\Builder;

use BadMethodCallException;
use Propel\Common\Pluralizer\PluralizerInterface;
use Propel\Generator\Builder\Om\AbstractObjectBuilder;
use Propel\Generator\Builder\Om\AbstractOMBuilder;
use Propel\Generator\Builder\Om\MultiExtendObjectBuilder;
use Propel\Generator\Builder\Om\ObjectBuilder;
use Propel\Generator\Builder\Om\TableMapBuilder;
use Propel\Generator\Config\GeneratorConfigInterface;
use Propel\Generator\Model\Inheritance;
use Propel\Generator\Model\Table;
Expand All @@ -34,84 +39,84 @@ abstract class DataModelBuilder
*
* @var \Propel\Generator\Model\Table
*/
private $table;
private Table $table;

/**
* The generator config object holding build properties, etc.
*
* @var \Propel\Generator\Config\GeneratorConfigInterface
* @var \Propel\Generator\Config\GeneratorConfigInterface|null
*/
private $generatorConfig;
private ?GeneratorConfigInterface $generatorConfig = null;

/**
* An array of warning messages that can be retrieved for display.
*
* @var array string[]
*/
private $warnings = [];
private array $warnings = [];

/**
* Object builder class for current table.
*
* @var \Propel\Generator\Builder\Om\ObjectBuilder
* @var \Propel\Generator\Builder\Om\ObjectBuilder|null
*/
private $objectBuilder;
private ?ObjectBuilder $objectBuilder = null;

/**
* Stub Object builder class for current table.
*
* @var \Propel\Generator\Builder\Om\ObjectBuilder
* @var \Propel\Generator\Builder\Om\AbstractObjectBuilder|null
*/
private $stubObjectBuilder;
private ?AbstractObjectBuilder $stubObjectBuilder = null;

/**
* Query builder class for current table.
*
* @var \Propel\Generator\Builder\Om\ObjectBuilder
* @var \Propel\Generator\Builder\Om\AbstractOMBuilder|null
*/
private $queryBuilder;
private ?AbstractOMBuilder $queryBuilder = null;

/**
* Stub Query builder class for current table.
*
* @var \Propel\Generator\Builder\Om\ObjectBuilder
* @var \Propel\Generator\Builder\Om\AbstractOMBuilder|null
*/
private $stubQueryBuilder;
private ?AbstractOMBuilder $stubQueryBuilder = null;

/**
* TableMap builder class for current table.
*
* @var \Propel\Generator\Builder\Om\TableMapBuilder
* @var \Propel\Generator\Builder\Om\TableMapBuilder|null
*/
protected $tablemapBuilder;
protected ?TableMapBuilder $tablemapBuilder = null;

/**
* Stub Interface builder class for current table.
*
* @var \Propel\Generator\Builder\Om\ObjectBuilder
* @var \Propel\Generator\Builder\Om\AbstractOMBuilder|null
*/
private $interfaceBuilder;
private ?AbstractOMBuilder $interfaceBuilder = null;

/**
* Stub child object for current table.
*
* @var \Propel\Generator\Builder\Om\MultiExtendObjectBuilder
* @var \Propel\Generator\Builder\Om\MultiExtendObjectBuilder|null
*/
private $multiExtendObjectBuilder;
private ?MultiExtendObjectBuilder $multiExtendObjectBuilder = null;

/**
* The Pluralizer class to use.
*
* @var \Propel\Common\Pluralizer\PluralizerInterface
* @var \Propel\Common\Pluralizer\PluralizerInterface|null
*/
private $pluralizer;
private ?PluralizerInterface $pluralizer = null;

/**
* The platform class
*
* @var \Propel\Generator\Platform\PlatformInterface
*/
protected $platform;
protected ?PlatformInterface $platform = null;

/**
* Creates new instance of DataModelBuilder subclass.
Expand Down Expand Up @@ -156,9 +161,9 @@ public function getObjectBuilder()
/**
* Returns new or existing stub Object builder class for this table.
*
* @return \Propel\Generator\Builder\Om\ObjectBuilder
* @return \Propel\Generator\Builder\Om\AbstractObjectBuilder|null
*/
public function getStubObjectBuilder()
public function getStubObjectBuilder(): ?AbstractObjectBuilder
{
if ($this->stubObjectBuilder === null) {
/** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */
Expand All @@ -172,9 +177,9 @@ public function getStubObjectBuilder()
/**
* Returns new or existing Query builder class for this table.
*
* @return \Propel\Generator\Builder\Om\ObjectBuilder
* @return \Propel\Generator\Builder\Om\AbstractOMBuilder|null
*/
public function getQueryBuilder()
public function getQueryBuilder(): ?AbstractOMBuilder
{
if ($this->queryBuilder === null) {
/** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */
Expand All @@ -188,9 +193,9 @@ public function getQueryBuilder()
/**
* Returns new or existing stub Query builder class for this table.
*
* @return \Propel\Generator\Builder\Om\ObjectBuilder
* @return \Propel\Generator\Builder\Om\AbstractOMBuilder|null
*/
public function getStubQueryBuilder()
public function getStubQueryBuilder(): ?AbstractOMBuilder
{
if ($this->stubQueryBuilder === null) {
/** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */
Expand Down Expand Up @@ -220,9 +225,9 @@ public function getTableMapBuilder()
/**
* Returns new or existing stub Interface builder class for this table.
*
* @return \Propel\Generator\Builder\Om\ObjectBuilder
* @return \Propel\Generator\Builder\Om\AbstractOMBuilder|null
*/
public function getInterfaceBuilder()
public function getInterfaceBuilder(): ?AbstractOMBuilder
{
if ($this->interfaceBuilder === null) {
/** @var \Propel\Generator\Builder\Om\ObjectBuilder $builder */
Expand Down Expand Up @@ -444,16 +449,10 @@ public function setTable(Table $table)
/**
* Returns the current Table object.
*
* @throws \BadMethodCallException
*
* @return \Propel\Generator\Model\Table
*/
public function getTable()
public function getTable(): Table
{
if ($this->table === null) {
throw new BadMethodCallException('No $table set to return.');
}

return $this->table;
}

Expand Down
9 changes: 7 additions & 2 deletions src/Propel/Generator/Builder/Om/AbstractOMBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ public function getPackagePath()
* Returns the user-defined namespace for this table,
* or the database namespace otherwise.
*
* @return string
* @return string|null Currently returns null in some cases - should be fixed
*/
public function getNamespace()
public function getNamespace(): ?string
{
return $this->getTable()->getNamespace();
}
Expand Down Expand Up @@ -367,6 +367,11 @@ public function declareClassNamespace($class, $namespace = '', $alias = false)
*/
protected function needAliasForClassName($class, $classNamespace)
{
// Should remove this check by not allowing nullable return values in getNamespace
if ($this->getNamespace() === null) {
return false;
}

$builderNamespace = trim($this->getNamespace(), '\\');

if ($classNamespace == $builderNamespace) {
Expand Down
10 changes: 7 additions & 3 deletions src/Propel/Generator/Builder/Om/ClassTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ class ClassTools
/**
* Gets just classname, given a dot-path to class.
*
* @param string $qualifiedName
* @param string|null $qualifiedName
*
* @return string
* @return string|null
*/
public static function classname($qualifiedName)
public static function classname(?string $qualifiedName): ?string
{
if ($qualifiedName === null) {
return null;
}

if (false !== $pos = strrpos($qualifiedName, '.')) {
return substr($qualifiedName, $pos + 1); // start just after '.'
} elseif (false !== $pos = strrpos($qualifiedName, '\\')) {
Expand Down
6 changes: 3 additions & 3 deletions src/Propel/Generator/Builder/Om/ObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public function getPackage()
*
* @see Propel\Generator\Builder\Om.AbstractOMBuilder::getNamespace()
*
* @return string
* @return string|null
*/
public function getNamespace()
public function getNamespace(): ?string
{
if ($namespace = parent::getNamespace()) {
return $namespace . '\\Base';
Expand Down Expand Up @@ -317,7 +317,7 @@ protected function addClassBody(&$script)
);

$baseClass = $this->getBaseClass();
if (strrpos($baseClass, '\\') !== false) {
if ($baseClass && strrpos($baseClass, '\\') !== false) {
$this->declareClasses($baseClass);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Propel/Generator/Builder/Om/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public function getPackage()
/**
* Returns the namepace for the query object classes.
*
* @return string
* @return string|null
*/
public function getNamespace()
public function getNamespace(): ?string
{
if ($namespace = parent::getNamespace()) {
return $namespace . '\\Base';
Expand Down
4 changes: 2 additions & 2 deletions src/Propel/Generator/Builder/Om/QueryInheritanceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function getPackage()
/**
* Gets the namespace for the [base] object classes.
*
* @return string
* @return string|null
*/
public function getNamespace()
public function getNamespace(): ?string
{
if ($namespace = parent::getNamespace()) {
return $namespace . '\\Base';
Expand Down
4 changes: 2 additions & 2 deletions src/Propel/Generator/Builder/Om/TableMapBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public function getPackage()
}

/**
* @return string
* @return string|null
*/
public function getNamespace()
public function getNamespace(): ?string
{
if (!$namespace = parent::getNamespace()) {
return 'Map';
Expand Down
Loading