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

chore: update bundle structure to the latest version #52

Merged
merged 7 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.yaml]
[*.{json,yaml,yml}]
indent_size = 2

[*.neon]
indent_style = tab

[*.md]
trim_trailing_whitespace = false

[*.neon]
indent_style = tab
9 changes: 5 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/.github/ export-ignore
/bin/ export-ignore
/docs/ export-ignore
/tests/ export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.github/ export-ignore
/.gitignore export-ignore
/.php-cs-fixer.php export-ignore
/bin/ export-ignore
/compose.yaml export-ignore
/depfile.yaml export-ignore
/docs/ export-ignore
/phpstan.neon export-ignore
/phpunit.xml.dist export-ignore
/tests/ export-ignore
1 change: 1 addition & 0 deletions .github/workflows/test-and-qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read
Expand Down
13 changes: 9 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/.idea/

/vendor/
# Composer
/composer.lock
/vendor/

# PHP-CS-Fixer
/.php-cs-fixer.cache

# PHPUnit
/.phpunit.result.cache
/.phpunit.cache/
/phpunit.xml
/reports/

# IDE project files
/.idea/
53 changes: 32 additions & 21 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
<?php

/*
* This document has been generated with
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.13.1|configurator
* you can change this configuration by importing this file.
* This document has been initially generated with
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.5.0|configurator
* and then adapted to our needs
*/
$config = new PhpCsFixer\Config();
$finder = PhpCsFixer\Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->exclude([
'var/',
]);

return $config
return (new PhpCsFixer\Config)
->setFinder((new PhpCsFixer\Finder)
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->notPath(['DependencyInjection/Configuration.php', 'app/var'])
)
->setRiskyAllowed(true)
->setRules([
'align_multiline_comment' => true,
'array_indentation' => true,
'blank_line_after_opening_tag' => true,
'concat_space' => ['spacing' => 'one'],
'declare_strict_types' => true,
'linebreak_after_opening_tag' => true,
])
->setFinder($finder);
'@Symfony' => true,
'@Symfony:risky' => true,

// declare strict types must be on first line after opening tag
'blank_line_after_opening_tag' => false, // overwrite @Symfony
'linebreak_after_opening_tag' => false, // overwrite @Symfony
'declare_strict_types' => true, // custom

// allow throw's in multiple lines, so message can be a long string
'single_line_throw' => false, // overwrite @Symfony

// we want spaces
'concat_space' => ['spacing' => 'one'], // overwrite @Symfony

// we want to leave the choice to the developer,
// because some people have their own style of naming test methods
'php_unit_method_casing' => false, // overwrite @Symfony

// we want to leave the choice to the developer
'php_unit_test_annotation' => false, // overwrite @Symfony:risky
]);
47 changes: 34 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,43 @@ A default implementation of the Converter & Populator design pattern.

## Installation

Run `composer require teamneusta/converter-bundle` to install the bundle.
1. **Require the bundle**

Add the following line into your `bundles.php` file to activate it:
```shell
composer require teamneusta/converter-bundle
```

```php
...
return [
...
Neusta\ConverterBundle\NeustaConverterBundle::class => ['all' => true],
...
];
```
2. **Enable the bundle**

Add the Bundle to your `config/bundles.php`:

```php
Neusta\ConverterBundle\NeustaConverterBundle::class => ['all' => true],
```

This is important for preloading the default configuration of provided converter implementations which can be reused
and simplify your code and further updates.
This is important for preloading the default configuration of provided converter implementations which can be reused
and simplify your code and further updates.

## [Usage](docs/usage.md)

## [Development](docs/development.md)
## Contribution

Feel free to open issues for any bug, feature request, or other ideas.

Please remember to create an issue before creating large pull requests.

### Local Development

To develop on local machine, the vendor dependencies are required.

```shell
bin/composer install
```

We use composer scripts for our main quality tools. They can be executed via the `bin/composer` file as well.

```shell
bin/composer cs:fix
bin/composer phpstan
bin/composer tests
```
3 changes: 3 additions & 0 deletions bin/composer
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

exec docker compose run --rm --user "$(id -u):$(id -g)" --no-deps php composer "$@"
4 changes: 4 additions & 0 deletions bin/run-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

docker compose run --rm --user "$(id -u):$(id -g)" php composer tests
docker compose down
27 changes: 27 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
services:
database:
image: mariadb:10.11.4
command: [ "mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci" ]
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: pimcore
MYSQL_PASSWORD: pimcore
MYSQL_USER: pimcore
tmpfs:
- /tmp/
- /var/lib/mysql/
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
interval: 5s
timeout: 10s

php:
image: pimcore/pimcore:php8.2-latest
volumes:
- ./:/var/www/html/
- /home/ldschaak/.cache/composer:/.cache/composer
environment:
MYSQL_SERVER_VERSION: mariadb-10.11.4
depends_on:
database:
condition: service_healthy
31 changes: 18 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
"role": "Developer"
}
],
"config": {
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"require": {
"php": "^8.0",
"symfony/config": "^5.4 || ^6.2",
Expand All @@ -39,13 +45,6 @@
"symfony/test-pack": "^1.0",
"symfony/yaml": "^5.4 || ^6.2"
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"autoload": {
"psr-4": {
"Neusta\\ConverterBundle\\": "src/"
Expand All @@ -60,18 +59,24 @@
]
},
"scripts": {
"cs:check": "php-cs-fixer fix -v --diff --dry-run",
"cs:fix": "php-cs-fixer fix -v --diff",
"phpstan": "phpstan analyse --level=${PHPSTAN_LEVEL:-8} -c phpstan.neon",
"cs:check": "@cs:fix --dry-run",
"cs:check:gitlab-ci": "php-cs-fixer fix --dry-run --ansi --verbose --diff --format=gitlab > php-cs-fixer.json",
"cs:fix": "php-cs-fixer fix --ansi --verbose --diff",
"phpstan": "phpstan analyse --ansi",
"phpstan:gitlab-ci": "phpstan analyse --ansi --no-interaction --no-progress --error-format=gitlab > phpstan-report.json",
"tests": "phpunit",
"tests:coverage:gitlab-ci": "phpunit --colors=never --coverage-text --coverage-cobertura .coverage/cobertura.xml --log-junit .coverage/junit.xml",
"deptrac:analyse": "deptrac --config-file=depfile.yaml",
"deptrac:analyse:visual": "deptrac --formatter=graphviz-html --output=deptrac.analyse-result.html --config-file=depfile.yaml"
},
"scripts-descriptions": {
"cs:check": "Checks code style (but doesn't fix anything)",
"cs:fix": "Fixes code style",
"phpstan": "PHPstan - find bugs and lacks in your type safety",
"tests": "Phpunit - write tests before you implement. That helps.",
"cs:check:gitlab-ci": "Checks code style and redirects the output into a GitLab readable file",
"cs:fix": "Checks and fixes code style",
"phpstan": "Checks for code smells",
"phpstan:gitlab-ci": "Checks for code smells and redirects the output into a GitLab readable file",
"tests": "Run all phpunit tests",
"tests:coverage:gitlab-ci": "Run all phpunit tests and create coverage reports",
"deptrac:analyse": "Analyse your dependencies and follow the pre-defined rules and layers",
"deptrac:analyse:visual": "Visualize your dependencies and follow the pre-defined rules and layers"
}
Expand Down
60 changes: 30 additions & 30 deletions config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
services:
_defaults:
autowire: false
autoconfigure: false
_defaults:
autowire: false
autoconfigure: false

############################################################
# Generic Converter
############################################################
neusta_converter.generic_converter:
abstract: true
class: Neusta\ConverterBundle\Converter\GenericConverter
############################################################
# Generic Converter
############################################################
neusta_converter.generic_converter:
abstract: true
class: Neusta\ConverterBundle\Converter\GenericConverter

############################################################
# Strategic Converter
############################################################
neusta_converter.strategic_converter:
abstract: true
class: Neusta\ConverterBundle\Converter\StrategicConverter
############################################################
# Strategic Converter
############################################################
neusta_converter.strategic_converter:
abstract: true
class: Neusta\ConverterBundle\Converter\StrategicConverter

############################################################
# Populators
############################################################
neusta_converter.property_mapping_populator:
abstract: true
class: Neusta\ConverterBundle\Populator\PropertyMappingPopulator
############################################################
# Populators
############################################################
neusta_converter.property_mapping_populator:
abstract: true
class: Neusta\ConverterBundle\Populator\PropertyMappingPopulator

neusta_converter.converting_populator:
abstract: true
class: Neusta\ConverterBundle\Populator\ConvertingPopulator
neusta_converter.converting_populator:
abstract: true
class: Neusta\ConverterBundle\Populator\ConvertingPopulator

neusta_converter.array_property_mapping_populator:
abstract: true
class: Neusta\ConverterBundle\Populator\ArrayPropertyMappingPopulator
neusta_converter.array_property_mapping_populator:
abstract: true
class: Neusta\ConverterBundle\Populator\ArrayPropertyMappingPopulator

neusta_converter.array_converting_populator:
abstract: true
class: Neusta\ConverterBundle\Populator\ArrayConvertingPopulator
neusta_converter.array_converting_populator:
abstract: true
class: Neusta\ConverterBundle\Populator\ArrayConvertingPopulator
11 changes: 0 additions & 11 deletions docs/development.md

This file was deleted.

Binary file removed docs/images/phpstorm-run-configuration.png
Binary file not shown.
Binary file removed docs/images/phpstorm-settings.png
Binary file not shown.