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

Enhancement: Allow creating ContainerBuilder with definitions for default extensions #732

Merged
merged 1 commit into from Sep 5, 2023

Conversation

localheinz
Copy link
Member

@localheinz localheinz commented Sep 5, 2023

What is the reason for this PR?

  • allows creating a ContainerBuilder with definitions for default extensions

Related to #719.

Author's checklist

Summary of changes

Review checklist

  • All checks have passed
  • Changes are approved by maintainer

@localheinz localheinz added the enhancement New feature or request label Sep 5, 2023
@localheinz localheinz self-assigned this Sep 5, 2023
src/Faker/Container/ContainerBuilder.php Outdated Show resolved Hide resolved
src/Faker/Container/ContainerBuilder.php Outdated Show resolved Hide resolved
@localheinz localheinz marked this pull request as ready for review September 5, 2023 08:36
@localheinz localheinz removed their assignment Sep 5, 2023
Comment on lines +62 to +71
public static function withDefaultExtensions(): self
{
$instance = new self();

foreach (self::defaultExtensions() as $id => $definition) {
$instance->add($id, $definition);
}

return $instance;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method can provide an extension point for people who want to

  • add extensions
  • override default extensions
<?php

declare(strict_types=1);

use Faker\Container;
use Faker\Extension;
use Faker\Generator;

require_once __DIR__ . '/../vendor/autoload.php';

$container = Container\ContainerBuilder::withDefaultExtensions()
    ->add(Extension\FileExtension::class, static function (): Extension\FileExtension {
        return new CustomFileExtension();
    })
    ->build();

$faker = new Generator($container);

This method is similar to the method simplified in #720, but returns the ContainerBuilder instead of the built Container.

Comment on lines 73 to 76
public static function getDefault(): ContainerInterface
{
return new Container(self::defaultExtensions());
return self::withDefaultExtensions()->build();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably remove this method - I don't see any use for it (also see changes below).

@bram-pkg
Copy link
Member

bram-pkg commented Sep 5, 2023

One conflict to resolve, @localheinz

Otherwise LGTM

@localheinz localheinz merged commit bf42220 into FakerPHP:main Sep 5, 2023
12 checks passed
@localheinz
Copy link
Member Author

Thank you, @bram-pkg!

@localheinz localheinz deleted the feature/default branch September 5, 2023 14:42
@localheinz localheinz mentioned this pull request Sep 5, 2023
5 tasks
@localheinz localheinz assigned localheinz and bram-pkg and unassigned localheinz and bram-pkg Sep 5, 2023
renovate bot added a commit to RadioRoster/backend that referenced this pull request Jan 7, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [fakerphp/faker](https://togithub.com/FakerPHP/Faker) | `1.23.0` ->
`1.23.1` |
[![age](https://developer.mend.io/api/mc/badges/age/packagist/fakerphp%2ffaker/1.23.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/fakerphp%2ffaker/1.23.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/fakerphp%2ffaker/1.23.0/1.23.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/fakerphp%2ffaker/1.23.0/1.23.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>FakerPHP/Faker (fakerphp/faker)</summary>

###
[`v1.23.1`](https://togithub.com/FakerPHP/Faker/releases/tag/v1.23.1)

[Compare
Source](https://togithub.com/FakerPHP/Faker/compare/v1.23.0...v1.23.1)

#### What's Changed

- fix typos: "assymetric" -> asymmetric by
[@&#8203;ivastly](https://togithub.com/ivastly) in
[FakerPHP/Faker#660
- Fix: lv_LV postcode format by
[@&#8203;edgarsn](https://togithub.com/edgarsn) in
[FakerPHP/Faker#661
- composer(deps): bump vimeo/psalm from 5.12.0 to 5.13.1 in
/vendor-bin/psalm by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#669
- composer(deps): bump rector/rector from 0.17.0 to 0.17.2 in
/vendor-bin/rector by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#667
- composer(deps): bump phpstan/phpstan from 1.10.15 to 1.10.22 in
/vendor-bin/phpstan by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#666
- composer(deps): bump friendsofphp/php-cs-fixer from 3.17.0 to 3.20.0
in /vendor-bin/php-cs-fixer by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#668
- Add `$format` to `image` DocBlock by
[@&#8203;vintagesucks](https://togithub.com/vintagesucks) in
[FakerPHP/Faker#670
- Fix: lv_LV generating invalid personal identity numbers by
[@&#8203;edgarsn](https://togithub.com/edgarsn) in
[FakerPHP/Faker#663
- Fix for polish street names + more polish TLDs by
[@&#8203;tomaszklim](https://togithub.com/tomaszklim) in
[FakerPHP/Faker#664
- Fix psalm baseline in .gitattributes by
[@&#8203;VincentLanglet](https://togithub.com/VincentLanglet) in
[FakerPHP/Faker#674
- composer(deps): bump rector/rector from 0.17.2 to 0.17.7 in
/vendor-bin/rector by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#676
- composer(deps): bump phpstan/phpstan from 1.10.22 to 1.10.26 in
/vendor-bin/phpstan by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#677
- composer(deps): bump friendsofphp/php-cs-fixer from 3.20.0 to 3.22.0
in /vendor-bin/php-cs-fixer by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#679
- composer(deps): bump vimeo/psalm from 5.13.1 to 5.14.1 in
/vendor-bin/psalm by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#678
- chore: ensure php 8.3 compatibility by
[@&#8203;Chris53897](https://togithub.com/Chris53897) in
[FakerPHP/Faker#684
- Remove invalid postcode pattern for France by
[@&#8203;ker0x](https://togithub.com/ker0x) in
[FakerPHP/Faker#683
- Fix: Allow tests to fail on PHP 8.3 by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#693
- Fix: Test does not perform any assertions by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#695
- Fix: Operator by [@&#8203;localheinz](https://togithub.com/localheinz)
in
[FakerPHP/Faker#696
- Fix: Use boolean expressions by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#697
- composer(deps): bump rector/rector from 0.17.7 to 0.18.1 in
/vendor-bin/rector by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#688
- composer(deps): bump phpstan/phpstan from 1.10.26 to 1.10.32 in
/vendor-bin/phpstan by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#689
- composer(deps): bump vimeo/psalm from 5.14.1 to 5.15.0 in
/vendor-bin/psalm by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#687
- composer(deps): bump phpstan/phpstan-deprecation-rules from 1.1.3 to
1.1.4 in /vendor-bin/phpstan by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#690
- composer(deps): bump friendsofphp/php-cs-fixer from 3.22.0 to 3.25.0
in /vendor-bin/php-cs-fixer by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#686
- Fix: Require to pass name to `ContainerBuilder::add()` by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#702
- Enhancement: Run tests in random order by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#701
- Fix: Add property type declarations by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#699
- Fix: Enable and configure `type_declaration_spaces` instead of
deprecated `function_typehint_space` fixer by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#698
- composer(deps): bump phpstan/phpstan from 1.10.32 to 1.10.33 in
/vendor-bin/phpstan by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#704
- composer(deps): bump friendsofphp/php-cs-fixer from 3.25.0 to 3.25.1
in /vendor-bin/php-cs-fixer by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#705
- github-actions(deps): bump actions/checkout from 3 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[FakerPHP/Faker#706
- Fix: Switch order of parameters by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#703
- Fix: Remove unused method by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#711
- Fix: Rename parameter by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#707
- Fix: Add parameter type declaration by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#710
- Fix: Order by [@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#712
- Enhancement: Reuse `NumberExtension` by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#715
- Fix: Methods are instance methods by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#708
- Fix: Add property type declarations by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#713
- Fix: Reduce visibility by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#714
- Fix: Do not memoize invalid service by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#709
- Fix: Consistently describe experimental status by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#717
- Fix: Mark classes as experimental by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#716
- Fix: Mark class as `final` by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#718
- Fix: Return string by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#726
- Fix: Order by [@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#722
- Fix: Avoid unnecessary imports by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#721
- Enhancement: Enable `self_static_accessor` fixer by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#728
- Fix: Cache for `friendsofphp/php-cs-fixer` by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#729
- Fix: Add parameter type declarations by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#724
- Fix: Add tests for `Container` by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#727
- Fix: Simplify by [@&#8203;localheinz](https://togithub.com/localheinz)
in
[FakerPHP/Faker#720
- updated polish license plates by
[@&#8203;scybulski](https://togithub.com/scybulski) in
[FakerPHP/Faker#685
- Fix: Update `CHANGELOG.md` by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#734
- Fix: Avoid useless tests for `ContainerBuilder` by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#730
- Fix: Rename parameter by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#731
- Add changelog mention in review checklist by
[@&#8203;bram-pkg](https://togithub.com/bram-pkg) in
[FakerPHP/Faker#735
- Enhancement: Allow creating `ContainerBuilder` with definitions for
default extensions by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#732
- Fix: Reduce visibility by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#719
- Fix: Remove unused method by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#736
- Enhancement: Add `SECURITY.md` by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#739
- Fix: Do not use `static` in callables by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#785
- Fixed incorrect female name among male names
([#&#8203;794](https://togithub.com/FakerPHP/Faker/issues/794)) by
[@&#8203;pimjansen](https://togithub.com/pimjansen) in
[FakerPHP/Faker#795
- Removed suppressed State from it_IT by
[@&#8203;BoGnY](https://togithub.com/BoGnY) in
[FakerPHP/Faker#802
- Update Address.php to fix country name errors by
[@&#8203;supgeek-rod](https://togithub.com/supgeek-rod) in
[FakerPHP/Faker#809
- fix [#&#8203;832](https://togithub.com/FakerPHP/Faker/issues/832) by
[@&#8203;gam6itko](https://togithub.com/gam6itko) in
[FakerPHP/Faker#836
- Fix: Do not use deprecated `MT_RAND_PHP` constant on PHP 8.3 by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#844
- Enhancement: Prepare release for `1.23.1` by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#788
- Fix: Remove branch alias for `1.23` by
[@&#8203;localheinz](https://togithub.com/localheinz) in
[FakerPHP/Faker#843

#### New Contributors

- [@&#8203;ivastly](https://togithub.com/ivastly) made their first
contribution in
[FakerPHP/Faker#660
- [@&#8203;edgarsn](https://togithub.com/edgarsn) made their first
contribution in
[FakerPHP/Faker#661
- [@&#8203;vintagesucks](https://togithub.com/vintagesucks) made their
first contribution in
[FakerPHP/Faker#670
- [@&#8203;tomaszklim](https://togithub.com/tomaszklim) made their first
contribution in
[FakerPHP/Faker#664
- [@&#8203;VincentLanglet](https://togithub.com/VincentLanglet) made
their first contribution in
[FakerPHP/Faker#674
- [@&#8203;Chris53897](https://togithub.com/Chris53897) made their first
contribution in
[FakerPHP/Faker#684
- [@&#8203;BoGnY](https://togithub.com/BoGnY) made their first
contribution in
[FakerPHP/Faker#802
- [@&#8203;supgeek-rod](https://togithub.com/supgeek-rod) made their
first contribution in
[FakerPHP/Faker#809
- [@&#8203;gam6itko](https://togithub.com/gam6itko) made their first
contribution in
[FakerPHP/Faker#836

**Full Changelog**:
FakerPHP/Faker@v1.23.0...v1.23.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/RadioRoster/backend).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjEuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEyMS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants