Skip to content

Commit 3c26edd

Browse files
authored
Merge pull request #582 from TomHAnderson/feature/doctrine-coding-standard
[FEATURE] Doctrine ORM 3.0 & DBAL 4.0 & Doctrine Coding Standard
2 parents ee9f2e8 + d5b54bb commit 3c26edd

File tree

152 files changed

+1630
-2791
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+1630
-2791
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: "Coding Standards"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "*.x"
7+
- "main"
8+
push:
9+
branches:
10+
- "*.x"
11+
- "main"
12+
13+
jobs:
14+
coding-standards:
15+
name: "Coding Standards"
16+
uses: "doctrine/.github/.github/workflows/[email protected]"
17+
with:
18+
php-version: '8.1'
19+
composer-options: '--prefer-dist --ignore-platform-req=php'
20+
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: "Continuous Integration"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "*.x"
7+
- "main"
8+
push:
9+
branches:
10+
- "*.x"
11+
- "main"
12+
13+
jobs:
14+
phpunit:
15+
name: "PHPUnit"
16+
runs-on: "ubuntu-20.04"
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
php-version:
22+
- "8.1"
23+
- "8.2"
24+
- "8.3"
25+
dependencies:
26+
- "highest"
27+
- "lowest"
28+
optional-dependencies:
29+
- true
30+
- false
31+
32+
steps:
33+
- name: "Checkout"
34+
uses: "actions/checkout@v2"
35+
with:
36+
fetch-depth: 2
37+
38+
- name: "Install PHP"
39+
uses: "shivammathur/setup-php@v2"
40+
with:
41+
php-version: "${{ matrix.php-version }}"
42+
coverage: "pcov"
43+
ini-values: "zend.assertions=1"
44+
extensions: "pdo_mysql"
45+
46+
- name: "Install dependencies with Composer"
47+
uses: "ramsey/composer-install@v1"
48+
with:
49+
dependency-versions: "${{ matrix.dependencies }}"
50+
composer-options: "--prefer-dist"
51+
52+
- name: "Show Composer packages"
53+
run: "composer show"
54+
55+
- name: "Run PHPUnit"
56+
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"
57+
58+
- name: "Upload coverage file"
59+
uses: "codecov/codecov-action@v4"
60+
with:
61+
name: "phpunit-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ matrix.dbal-version }}.coverage"
62+
files: "./coverage.xml"
63+
64+
upload_coverage:
65+
name: "Upload coverage to Codecov"
66+
runs-on: "ubuntu-20.04"
67+
needs:
68+
- "phpunit"
69+
70+
steps:
71+
- name: "Checkout"
72+
uses: "actions/checkout@v2"
73+
with:
74+
fetch-depth: 2
75+
76+
- name: "Download coverage files"
77+
uses: "actions/download-artifact@v4"
78+
with:
79+
path: "reports"
80+
81+
- name: "Upload to Codecov"
82+
uses: "codecov/codecov-action@v2"
83+
with:
84+
directory: "reports"

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
/coverage
12
/vendor
23
composer.phar
34
composer.lock
45
.DS_Store
5-
.php_cs.cache
6-
.php-cs-fixer.cache
6+
.phpcs-cache
77
.phpunit.result.cache
88

99
/tests/Stubs/storage/framework/views/*

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
The MIT License (MIT)
22

33
Copyright (c) 2015 Patrick Brouwers
4+
Copyright (c) 2024 Tom H Anderson <[email protected]>
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ EntityManager::flush();
2828
* Pagination
2929
* Pre-configured metadata, connections and caching
3030
* Extendable: extend or add your own drivers for metadata, connections or cache
31-
* Fluent, Annotations, YAML, SimplifiedYAML, XML, SimplifiedXML, Config and Static PHP metadata mappings
3231
* Multiple entity managers and connections
3332
* Laravel naming strategy
3433
* Simple authentication implementation

composer.json

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,43 @@
1313
{
1414
"name": "Patrick Brouwers",
1515
"email": "[email protected]"
16+
},
17+
{
18+
"name": "Tom H Anderson",
19+
"email": "[email protected]"
1620
}
1721
],
1822
"require": {
19-
"php": "^8.0",
20-
"doctrine/annotations": "^2",
21-
"doctrine/dbal": "^3.2",
22-
"doctrine/orm": "^2.14",
23-
"doctrine/persistence": "^3",
24-
"illuminate/auth": "^9.0|^10.0|^11.0",
25-
"illuminate/console": "^9.0|^10.0|^11.0",
26-
"illuminate/container": "^9.0|^10.0|^11.0",
27-
"illuminate/contracts": "^9.0|^10.0|^11.0",
28-
"illuminate/pagination": "^9.0|^10.0|^11.0",
29-
"illuminate/routing": "^9.0|^10.0|^11.0",
30-
"illuminate/support": "^9.0|^10.0|^11.0",
31-
"illuminate/validation": "^9.0|^10.0|^11.0",
32-
"illuminate/view": "^9.0|^10.0|^11.0",
23+
"php": "^8.1",
24+
"doctrine/dbal": "^4.1",
25+
"doctrine/orm": "^3.1",
26+
"doctrine/persistence": "^3.3",
27+
"illuminate/auth": "^10.0|^11.0",
28+
"illuminate/console": "^10.0|^11.0",
29+
"illuminate/container": "^10.0|^11.0",
30+
"illuminate/contracts": "^10.0|^11.0",
31+
"illuminate/pagination": "^10.0|^11.0",
32+
"illuminate/routing": "^10.0|^11.0",
33+
"illuminate/support": "^10.0|^11.0",
34+
"illuminate/validation": "^10.0|^11.0",
35+
"illuminate/view": "^10.0|^11.0",
3336
"symfony/cache": "^6.0|^7.0",
34-
"symfony/serializer": "^5.0|^6.0|^7.0",
35-
"symfony/yaml": "^5.0|^6.0|^7.0"
37+
"symfony/serializer": "^5.0|^6.0|^7.0"
3638
},
3739
"conflict": {
3840
"laravel/lumen": "*"
3941
},
4042
"require-dev": {
4143
"phpunit/phpunit": "^9.3",
42-
"mockery/mockery": "^1.3.1",
44+
"mockery/mockery": "^1.6.12",
4345
"illuminate/log": "^9.0|^10.0|^11.0",
4446
"illuminate/notifications": "^9.0|^10.0|^11.0",
4547
"illuminate/queue": "^9.0|^10.0|^11.0",
4648
"phpstan/phpstan": "^1.9",
47-
"phpstan/phpstan-deprecation-rules": "^1.1"
49+
"phpstan/phpstan-deprecation-rules": "^1.1",
50+
"doctrine/coding-standard": "^12.0",
51+
"php-parallel-lint/php-parallel-lint": "^1.4",
52+
"vimeo/psalm": "^0.3.14"
4853
},
4954
"autoload": {
5055
"psr-4": {
@@ -78,5 +83,18 @@
7883
"EntityManager": "LaravelDoctrine\\ORM\\Facades\\EntityManager"
7984
}
8085
}
86+
},
87+
"config": {
88+
"allow-plugins": {
89+
"dealerdirect/phpcodesniffer-composer-installer": true
90+
}
91+
},
92+
"scripts": {
93+
"test": [
94+
"vendor/bin/parallel-lint src tests",
95+
"vendor/bin/phpcs",
96+
"vendor/bin/phpunit"
97+
],
98+
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html=coverage"
8199
}
82100
}

config/doctrine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
'managers' => [
2828
'default' => [
2929
'dev' => env('APP_DEBUG', false),
30-
'meta' => env('DOCTRINE_METADATA', 'annotations'),
30+
'meta' => env('DOCTRINE_METADATA', 'attributes'),
3131
'connection' => env('DB_CONNECTION', 'mysql'),
3232
'paths' => [
3333
base_path('app/Entities')

phpcs.xml.dist

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<ruleset>
3+
<arg name="basepath" value="."/>
4+
<arg name="extensions" value="php"/>
5+
<arg name="parallel" value="80"/>
6+
<arg name="cache" value=".phpcs-cache"/>
7+
<arg name="colors"/>
8+
9+
<!-- Ignore warnings, show progress of the run and show sniff names -->
10+
<arg value="nps"/>
11+
12+
<!-- Directories to be checked -->
13+
<file>src</file>
14+
15+
<!-- Include full Doctrine Coding Standard -->
16+
<rule ref="Doctrine"/>
17+
</ruleset>

src/AbstractTable.php

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,47 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace LaravelDoctrine\ORM;
46

57
use Doctrine\DBAL\Schema\Column;
68
use Doctrine\DBAL\Schema\Index;
79
use Doctrine\DBAL\Schema\Table;
810
use Doctrine\DBAL\Types\Type;
911

10-
/** @interal */
12+
// phpcs:disable SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix
1113
abstract class AbstractTable
1214
{
13-
/**
14-
* @var string
15-
*/
16-
protected string $table;
17-
18-
/**
19-
* @param string $table
20-
*/
21-
public function __construct(string $table)
15+
public function __construct(protected string $table)
2216
{
23-
$this->table = $table;
2417
}
2518

26-
/**
27-
* @return Table
28-
*/
2919
public function build(): Table
3020
{
3121
return new Table(
3222
$this->table,
3323
$this->columns(),
34-
$this->indices()
24+
$this->indices(),
3525
);
3626
}
3727

38-
/**
39-
* @param string $name
40-
* @param string $type
41-
* @param bool $autoincrement
42-
* @return Column
43-
*/
44-
protected function column($name, string $type, bool $autoincrement = false): Column
28+
protected function column(string $name, string $type, bool $autoincrement = false): Column
4529
{
4630
$column = new Column($name, Type::getType($type));
4731
$column->setAutoincrement($autoincrement);
4832

4933
return $column;
5034
}
5135

52-
/**
53-
* @param string $name
54-
* @param string[] $columns
55-
* @param bool $unique
56-
* @param bool $primary
57-
* @return Index
58-
*/
36+
/** @param string[] $columns */
5937
protected function index(string $name, array $columns, bool $unique = false, bool $primary = false): Index
6038
{
6139
return new Index($name, $columns, $unique, $primary);
6240
}
6341

64-
/**
65-
* @return Column[]
66-
*/
67-
abstract protected function columns();
42+
/** @return Column[] */
43+
abstract protected function columns(): array;
6844

69-
/**
70-
* @return Index[]
71-
*/
72-
abstract protected function indices();
45+
/** @return Index[] */
46+
abstract protected function indices(): array;
7347
}

0 commit comments

Comments
 (0)