Skip to content

Commit

Permalink
refactor: Use prettier.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Aug 27, 2022
1 parent 38ecf4b commit 4a6a853
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 70 deletions.
20 changes: 10 additions & 10 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Expand Down
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# CONTRIBUTING

We're using [GitHub Actions](https://docs.github.com/en/actions) as a continuous integration system.
For details, see the workflows in [.github/workflows](../.github/workflows).

For details, see the workflows in [.github/workflows](../.github/workflows).

## Tests

We're using [`grumphp/grumphp`](https://github.com/phpro/grumphp) to drive the development.
Expand Down
10 changes: 5 additions & 5 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
## Steps required to reproduce the problem

1.
2.
3.
1.
2.
3.

## Expected Result

*
-

## Actual Result

*
-
14 changes: 7 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
This PR:

* [ ] Fix ...
* [ ] Provide ...
* [ ] It breaks backward compatibility
* [ ] Has unit tests (phpspec)
* [ ] Has static analysis tests (psalm, phpstan)
* [ ] Has documentation
* [ ] Is an experimental thing
- [ ] Fix ...
- [ ] Provide ...
- [ ] It breaks backward compatibility
- [ ] Has unit tests (phpspec)
- [ ] Has static analysis tests (psalm, phpstan)
- [ ] Has documentation
- [ ] Is an experimental thing

Follows #.
Related to #.
Expand Down
20 changes: 10 additions & 10 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
6 changes: 3 additions & 3 deletions .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ daysUntilClose: 7
staleLabel: stale

markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
4 changes: 2 additions & 2 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4']
php-versions: ["7.4"]

steps:
- name: Set git to use LF
Expand Down Expand Up @@ -53,4 +53,4 @@ jobs:
- name: Send feedback on Github
if: ${{ failure() }}
run: |
vendor/bin/php-cs-fixer --allow-risky=yes --config=.php_cs.dist fix --dry-run --format=checkstyle | cs2pr
vendor/bin/php-cs-fixer --allow-risky=yes --config=.php_cs.dist fix --dry-run --format=checkstyle | cs2pr
22 changes: 22 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Prettier checks

# This action works with pull requests and pushes
on:
pull_request:
push:
branches:
- master

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install the Nix package manager
uses: cachix/install-nix-action@v17

- name: Checks
run: nix run nixpkgs#nodePackages.prettier -- --check .
2 changes: 1 addition & 1 deletion .github/workflows/prune.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
stale-pr-label: "stale"
stale-pr-message: |
Since this pull request has not had any activity within the last ${{ env.DAYS_BEFORE_STALE }} days, I have marked it as stale.
I will close it if no further activity occurs within the next ${{ env.DAYS_BEFORE_CLOSE }} days.
I will close it if no further activity occurs within the next ${{ env.DAYS_BEFORE_CLOSE }} days.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
tag_name: "${{ steps.tag_name.outputs.current_version }}"
body: ${{ steps.changelog_reader.outputs.changes }}
prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }}
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
6 changes: 3 additions & 3 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['7.4']
php-versions: ["7.4"]

steps:
- name: Set git to use LF
Expand Down Expand Up @@ -54,8 +54,8 @@ jobs:
- name: Send feedback on Github
if: ${{ failure() }}
run: |
vendor/bin/phpstan analyse -l max --error-format=checkstyle src/ | cs2pr
vendor/bin/psalm --output-format=github | cs2pr
vendor/bin/phpstan analyse -l max --error-format=checkstyle src/ | cs2pr
vendor/bin/psalm --output-format=github | cs2pr
- name: Send PSALM data
run: vendor/bin/psalm --shepherd --stats src/
Expand Down
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.direnv/
/.idea/
/vendor/
/docs/
/CHANGELOG.md
62 changes: 37 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[![Latest Stable Version][latest stable version]][1]
[![GitHub stars][github stars]][1]
[![Total Downloads][total downloads]][1]
[![Type Coverage][type coverage]][4]
[![License][license]][1]
[![Donate!][donate github]][5]
[![GitHub stars][github stars]][1]
[![Total Downloads][total downloads]][1]
[![Type Coverage][type coverage]][4]
[![License][license]][1]
[![Donate!][donate github]][github sponsors link]

# Doctrine Repository Monadic Helper

Expand All @@ -24,7 +24,7 @@ When using properly typed monads and callbacks, types inconsistencies will
be instantly detected by static analysis tools. This provides a safer and
better way to design functions and data transformation methods.

The monad in use in this project is the *Either* monad, provided
The monad in use in this project is the _Either_ monad, provided
by the contrib package [Lamphpda][51] from [Marco Perone][52].

## History
Expand All @@ -44,14 +44,15 @@ of programming and adopt a more functional programming style.
And lastly, willing to learn more about the monads which are some kind of
"design patterns" for functional programming, I started to write this package.

This package does not have the pretention to become a *de-facto* standard on how to use
Doctrine repositories, but it might help people understanding what monads are,
how to use them, and hopefully reduce the amount of conditions in their code.
This package does not have the pretention to become a _de-facto_ standard on how
to use Doctrine repositories, but it might help people understanding what monads
are, how to use them, and hopefully reduce the amount of conditions in their
code.

The monad package in use here is an arbitrary choice. I could have used
some other packages, but [marcosh/lamphpda][51] seems to be the best option,
especially when you analyse your code with static analysis tools to detect issues
upfront, without running their unit tests.
especially when you analyse your code with static analysis tools to detect
issues upfront, without running their unit tests.

## Installation

Expand All @@ -64,15 +65,15 @@ composer require loophp/repository-monadic-helper
To use this package and have monadic repositories, there are
3 options available:

* Without alteration of existing Doctrine repositories
* **Options 1**: By using a service which is
- Without alteration of existing Doctrine repositories
- **Options 1**: By using a service which is
creating a monadic repository from an entity class
name or an existing repository.
* With alteration of existing Doctrine repositories
* **Option 2**: By adding an interface, a trait and relevant
- With alteration of existing Doctrine repositories
- **Option 2**: By adding an interface, a trait and relevant
typing information like:
`@implements MonadicServiceEntityRepositoryInterface<EntityClassName>`
* **Option 3**: By replacing `extends ServiceEntityRepository`
- **Option 3**: By replacing `extends ServiceEntityRepository`
with `extends MonadicServiceEntityRepository`
and add relevant typing information like:
`@extends MonadicServiceEntityRepository<EntityClassName>`
Expand Down Expand Up @@ -224,7 +225,8 @@ Signature:
eitherFind(int|string $id): Either<Throwable, MyCustomEntity>
```

An exception is generated and wrapped in the monad when the returned result is `null`.
An exception is generated and wrapped in the monad when the returned result is
`null`.

### eitherFindAll

Expand All @@ -234,7 +236,8 @@ Signature:
eitherFindAll(): Either<Throwable, list<MyCustomEntity>>
```

An exception is generated and wrapped in the monad when the returned result is empty.
An exception is generated and wrapped in the monad when the returned result is
empty.

### eitherFindBy

Expand All @@ -244,7 +247,8 @@ Signature:
eitherFindBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): Either<Throwable, list<MyCustomEntity>>
```

An exception is generated and wrapped in the monad when the returned result is empty.
An exception is generated and wrapped in the monad when the returned result is
empty.

### eitherFindOneBy

Expand All @@ -254,17 +258,25 @@ Signature:
eitherFindOneBy(array $criteria): Either<Throwable, MyCustomEntity>
```

An exception is generated and wrapped in the monad when the returned result is `null`.
An exception is generated and wrapped in the monad when the returned result is
`null`.

## Todo

* Improve documentation and code examples.
- Improve documentation and code examples.

## Contributing

Feel free to contribute by sending Github pull requests.
Feel free to contribute by sending pull requests. We are a usually very
responsive team and we will help you going through your pull request from the
beginning to the end.

If you can't contribute to the code, you can also sponsor me on [Github][5].
For some reasons, if you can't contribute to the code and willing to help,
sponsoring is a good, sound and safe way to show us some gratitude for the hours
we invested in this package.

Sponsor me on [Github][github sponsors link] and/or any of [the
contributors][contributors].

## Changelog

Expand All @@ -287,8 +299,7 @@ For more detailed changelogs, please check [the release changelogs][45].
[37]: https://github.com/infection/infection
[38]: https://github.com/phpstan/phpstan
[39]: https://github.com/vimeo/psalm
[5]: https://github.com/sponsors/drupol
[6]: https://www.paypal.me/drupol
[github sponsors link]: https://github.com/sponsors/drupol
[40]: https://packagist.org/packages/doctrine/doctrine-bundle
[41]: https://en.wikipedia.org/wiki/SOLID
[42]: https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle
Expand All @@ -305,3 +316,4 @@ For more detailed changelogs, please check [the release changelogs][45].
[53]: https://github.com/doctrine/persistence/pull/213
[54]: https://github.com/phpstan/phpstan/issues/6143
[55]: https://github.com/doctrine/persistence/issues/23
[contributors]: https://github.com/loophp/repository-monadic-helper/graphs/contributors

0 comments on commit 4a6a853

Please sign in to comment.