Skip to content

Commit

Permalink
Merge pull request #201 from kitloong/feature/v7
Browse files Browse the repository at this point in the history
Add Laravel v11 support
  • Loading branch information
kitloong authored Mar 3, 2024
2 parents 0f007e8 + 5bbe6c1 commit 44e070f
Show file tree
Hide file tree
Showing 236 changed files with 4,525 additions and 5,870 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@
/phpcs.xml export-ignore
/phpstan.neon export-ignore
/phpunit.xml.dist export-ignore
/phpunit8.xml export-ignore
/testbench.yaml export-ignore
8 changes: 5 additions & 3 deletions .github/workflows/check.yml → .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.3
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis, memcached
tools: composer:v2
coverage: none

- name: Install dependencies
run: composer install --prefer-dist --no-interaction
run: |
composer require "laravel/framework:^11.0" --no-interaction --no-update
composer update --prefer-stable --prefer-dist --no-interaction --no-progress
- name: phpcs
run: composer run phpcs

- name: phpstan
run: composer run phpstan
run: ./vendor/bin/phpstan analyse --memory-limit=2G

- name: phpmd
run: composer run phpmd
37 changes: 7 additions & 30 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,14 @@ jobs:
strategy:
matrix:
php: [ 8.1, 8.2, 8.3 ]
laravel: [ 9.*, 10.* ]
dbal: [ 3.* ]
php: [ 8.2, 8.3 ]
laravel: [ 11.* ]
sqlsrv_extension: [ pdo_sqlsrv ]
include:
- php: 7.1
laravel: 5.7.*
dbal: 2.*
- php: 7.2
laravel: 5.8.*
dbal: 2.*
- php: 7.3
laravel: 6.*
dbal: 2.*
- php: 7.4
laravel: 7.*
dbal: 2.*
- php: 8.0
laravel: 8.*
dbal: 2.*
- php: 8.1
laravel: 10.43.*
- php: 8.1
laravel: 10.*

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}

Expand Down Expand Up @@ -125,26 +113,15 @@ jobs:
- name: Install dependencies
run: |
composer config --no-plugins allow-plugins.kylekatarnls/update-helper true
composer require "laravel/framework:${{ matrix.laravel }}" "doctrine/dbal:${{ matrix.dbal }}" --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --prefer-stable --prefer-dist --no-interaction --no-progress
- name: Setup PCOV
if: ${{ matrix.laravel == '5.7.*' }}
run: |
composer require pcov/clobber
vendor/bin/pcov clobber
- name: Setup .env
run: |
mkdir ./database
composer run action-env-setup
- name: Execute tests with PHPUnit 8 or below
if: ${{ matrix.laravel == '5.7.*' || matrix.laravel == '5.8.*' }}
run: vendor/bin/phpunit -c ./phpunit8.xml --coverage-clover=coverage.xml

- name: Execute tests
if: ${{ matrix.laravel != '5.7.*' && matrix.laravel != '5.8.*' }}
run: vendor/bin/phpunit --coverage-clover=coverage.xml

- name: Upload to codecov
Expand Down
10 changes: 8 additions & 2 deletions .phpmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
<exclude name="CyclomaticComplexity"/>
<exclude name="ExcessiveClassComplexity"/>
<exclude name="ExcessiveParameterList"/>
<exclude name="NPathComplexity"/>
<exclude name="TooManyFields"/>
<exclude name="TooManyPublicMethods"/>
</rule>
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<properties>
<property name="reportLevel" value="15"/>
<property name="reportLevel" value="25"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity">
Expand All @@ -36,9 +37,14 @@
<property name="minimum" value="15"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/NPathComplexity">
<properties>
<property name="minimum" value="300"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/TooManyFields">
<properties>
<property name="maxfields" value="20"/>
<property name="maxfields" value="25"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/TooManyPublicMethods">
Expand Down
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ Laravel Migrations Generator supports all five Laravel first-party support datab

## Version Compatibility

| Laravel | Version |
|---------------|-------------------------------------------------|
| 10.x | 6.x |
| 9.x | 6.x |
| 8.x | 6.x |
| 7.x | 6.x |
| 6.x | 6.x |
| 5.8.x | 6.x |
| 5.7.x | 6.x |
| 5.6.x | 6.x |
| 5.5 and below | https://github.com/Xethron/migrations-generator |
| Laravel | Version |
|--------------------|-------------------------------------------------|
| 11.x | 7.x |
| \>= 10.43.x | 7.x |
| 10.x \| <= 10.42.x | 6.x |
| 9.x | 6.x |
| 8.x | 6.x |
| 7.x | 6.x |
| 6.x | 6.x |
| 5.8.x | 6.x |
| 5.7.x | 6.x |
| 5.6.x | 6.x |
| <= 5.5.x | https://github.com/Xethron/migrations-generator |

## Install

Expand Down Expand Up @@ -148,9 +150,9 @@ The generator first generates all tables and then adds foreign keys to existing
However, SQLite only supports foreign keys upon creation of the table and not when tables are altered.
*_add_foreign_keys_* migrations will still be generated, however will get omitted if migrate to SQLite type database.

## User Defined Custom Column Type
## User-Defined Type Columns

The generator will register custom data type from the schema, then generate migration as
The generator will recognize user-defined type from the schema, and then generate migration as

```php
public function up()
Expand All @@ -164,7 +166,7 @@ public function up()

Note that the new `column` is always added at the end of the created `table` which means the ordering of the column generated in migration will differ from what we have from the schema.

Supported database with custom types:
Supported database with user-defined types:

- [x] PostgreSQL
- [x] SQL Server
Expand Down
16 changes: 7 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@
}
],
"require": {
"php": ">=7.1.3",
"illuminate/support": "^5.6|^6.0|^7.0|^8.0|^9.0|^10.0",
"doctrine/dbal": "^2.4|^3.0",
"myclabs/php-enum": "^1.6|^1.7|^1.8",
"php": "^8.1",
"illuminate/support": "^10.43|^11.0",
"ext-pdo": "*"
},
"require-dev": {
"orchestra/testbench": "^3.6|^4.0|^5.0|^6.0|^7.0|^8.0",
"orchestra/testbench": "^8.0|^9.0",
"squizlabs/php_codesniffer": "^3.5",
"mockery/mockery": "^1.0",
"friendsofphp/php-cs-fixer": "^2.19.0|^3.1",
"larastan/larastan": "^0.4|^0.5|^0.6|^0.7|^1.0|^2.0",
"friendsofphp/php-cs-fixer": "^3.1",
"larastan/larastan": "^1.0|^2.0",
"slevomat/coding-standard": "^8.0",
"phpmd/phpmd": "^2.10",
"barryvdh/laravel-ide-helper": "^2.5",
"slevomat/coding-standard": "^6.0|^7.0|^8.5"
"barryvdh/laravel-ide-helper": "^2.0|^3.0"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 3 additions & 4 deletions config/migrations-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

return [
// Where the templates for the generators are stored.
'migration_template_path' => __DIR__ . '/../stubs/migration.generate.stub',
'migration_anonymous_template_path' => __DIR__ . '/../stubs/migration.generate.anonymous.stub',
'migration_template_path' => __DIR__ . '/../stubs/migration.generate.stub',

// Where the generated files will be saved.
'migration_target_path' => base_path('database/migrations'),
'migration_target_path' => base_path('database/migrations'),

// Migration filename pattern.
'filename_pattern' => [
'filename_pattern' => [
'table' => '[datetime]_create_[name]_table.php',
'view' => '[datetime]_create_[name]_view.php',
'procedure' => '[datetime]_create_[name]_proc.php',
Expand Down
92 changes: 19 additions & 73 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
<!--<rule ref="SlevomatCodingStandard.Classes.ClassLength"/>-->
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing"/>
<!--<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>-->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing"/>
<!--<rule ref="SlevomatCodingStandard.Classes.DisallowConstructorPropertyPromotion"/>-->
<!-- <rule ref="SlevomatCodingStandard.Classes.DisallowConstructorPropertyPromotion"/>-->
<!--<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>-->
<!--<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>-->
<!--<rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition"/>-->
Expand All @@ -47,17 +47,12 @@
<rule ref="SlevomatCodingStandard.Classes.EnumCaseSpacing"/>
<!--<rule ref="SlevomatCodingStandard.Classes.ForbiddenPublicProperty"/>-->
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing"/>
<!--<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>-->
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<!--<rule ref="SlevomatCodingStandard.Classes.RequireAbstractOrFinal"/>-->
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion">
<!--Disabled to support PHP 7.1-->
<properties>
<property name="enable" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion"/>
<!--<rule ref="SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature"/>-->
<rule ref="SlevomatCodingStandard.Classes.RequireSelfReference"/>
<rule ref="SlevomatCodingStandard.Classes.RequireSingleLineMethodSignature"/>
Expand All @@ -72,7 +67,7 @@
<rule ref="SlevomatCodingStandard.Commenting.AnnotationName"/>
<rule ref="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration"/>
<!--<rule ref="SlevomatCodingStandard.Commenting.DisallowCommentAfterCode"/>-->
<!--<rule ref="SlevomatCodingStandard.Commenting.DisallowOneLinePropertyDocComment"/>-->
<rule ref="SlevomatCodingStandard.Commenting.DisallowOneLinePropertyDocComment"/>
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing"/>
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations"/>
Expand All @@ -91,10 +86,10 @@
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!--<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEmpty"/>-->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEmpty"/>
<!--<rule ref="SlevomatCodingStandard.ControlStructures.DisallowNullSafeObjectOperator"/>-->
<!--<rule ref="SlevomatCodingStandard.ControlStructures.DisallowShortTernaryOperator"/>-->
<!--<rule ref="SlevomatCodingStandard.ControlStructures.DisallowTrailingMultiLineTernaryOperatorSniff"/>-->
<!--<rule ref="SlevomatCodingStandard.ControlStructures.DisallowTrailingMultiLineTernaryOperator"/>-->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/>
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!--<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing"/>-->
Expand All @@ -105,12 +100,7 @@
<!--<rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineTernaryOperator"/>-->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullSafeObjectOperator">
<!--Disabled to support PHP 7.1-->
<properties>
<property name="enable" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullSafeObjectOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator"/>
<!--<rule ref="SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition"/>-->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireTernaryOperator"/>
Expand All @@ -120,12 +110,7 @@
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!--<rule ref="SlevomatCodingStandard.Exceptions.DisallowNonCapturingCatch"/>-->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch">
<!--Disabled to support PHP 7.1-->
<properties>
<property name="enable" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch"/>
<!--<rule ref="SlevomatCodingStandard.Files.FileLength"/>-->
<!--<rule ref="SlevomatCodingStandard.Files.LineLength"/>-->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
Expand All @@ -145,23 +130,13 @@
<!--<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInDeclaration"/>-->
<!--<rule ref="SlevomatCodingStandard.Functions.FunctionLength"/>-->
<rule ref="SlevomatCodingStandard.Functions.NamedArgumentSpacing"/>
<!--<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction"/>-->
<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction"/>
<!--<rule ref="SlevomatCodingStandard.Functions.RequireMultiLineCall"/>-->
<!--<rule ref="SlevomatCodingStandard.Functions.RequireSingleLineCall"/>-->
<!--<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>-->
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse">
<!--Disabled to support PHP 7.1-->
<properties>
<property name="enable" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration">
<!--Disabled to support PHP 7.1-->
<properties>
<property name="enable" value="false"/>
</properties>
</rule>
<!--<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>-->
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/>
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!--<rule ref="SlevomatCodingStandard.Functions.StrictCall"/>-->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!--<rule ref="SlevomatCodingStandard.Functions.UnusedParameter"/>-->
Expand All @@ -183,8 +158,8 @@
<!--<rule ref="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces"/>-->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing"/>
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<rule ref="SlevomatCodingStandard.Numbers.DisallowNumericLiteralSeparator"/>
<rule ref="SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparator"/>
<!--<rule ref="SlevomatCodingStandard.Numbers.DisallowNumericLiteralSeparator"/>-->
<!--<rule ref="SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparator"/>-->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!--<rule ref="SlevomatCodingStandard.Operators.DisallowIncrementAndDecrementOperators"/>-->
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
Expand All @@ -209,39 +184,10 @@
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<!--Disabled to support PHP 7.1-->
<properties>
<property name="enableObjectTypeHint" value="false"/>
<property name="enableMixedTypeHint" value="false"/>
<property name="enableUnionTypeHint" value="false"/>
<property name="enableIntersectionTypeHint" value="false"/>
<property name="enableStandaloneNullTrueFalseTypeHints" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint"/>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<!--Disabled to support PHP 7.1-->
<properties>
<property name="enableNativeTypeHint" value="false"/>
<property name="enableMixedTypeHint" value="false"/>
<property name="enableUnionTypeHint" value="false"/>
<property name="enableIntersectionTypeHint" value="false"/>
<property name="enableStandaloneNullTrueFalseTypeHints" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<!--Disabled to support PHP 7.1-->
<properties>
<property name="enableObjectTypeHint" value="false"/>
<property name="enableStaticTypeHint" value="false"/>
<property name="enableMixedTypeHint" value="false"/>
<property name="enableUnionTypeHint" value="false"/>
<property name="enableIntersectionTypeHint" value="false"/>
<property name="enableNeverTypeHint" value="false"/>
<property name="enableStandaloneNullTrueFalseTypeHints" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat"/>
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
Expand Down
Loading

0 comments on commit 44e070f

Please sign in to comment.