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

Deprecate property access #164

Merged
merged 1 commit into from
Dec 22, 2020
Merged

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Dec 20, 2020

This PR deprecates access to $faker->name. One should always use $faker->name() instead.

I also add @group legacy to all tests for the providers. This is too many, I know, but I'll soon deprecate all providers too. =)

Why we should use trigger_deprecation() and not writing the deprecations ourselves? Some benefits are described in the readme. But the major thing for me is that deprecations will be easier to write (and eventually remove).

This is just the first of the many deprecations we will add the next few weeks.

@Nyholm Nyholm force-pushed the deprecate-property branch from 651ad18 to 29bc1ec Compare December 20, 2020 13:46
@@ -6,12 +6,18 @@

final class DefaultGeneratorTest extends TestCase
{
/**
* @group legacy
Copy link
Member

Choose a reason for hiding this comment

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

As far as I can see, we do not run different groups of tests at the moment.

What is the benefit of adding this annotation, then?

Copy link
Member Author

Choose a reason for hiding this comment

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

The symfony/phpunit-bridge has a super power, its default configuration (which we use) will fail the test if we use deprecated code... unless we mark the test as legacy.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds more like magic to me, to be honest!

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds more like magic to me, to be honest!

Maybe it is. ¯_(ツ)_/¯

Here are some related docs: https://symfony.com/doc/current/components/phpunit_bridge.html#mark-tests-as-legacy

No matter if it is magic or not, it is an excellent feature. It can help us to be sure that we never use code that is deprecated. So, if our code is tested, a user may always be able to use Faker without triggering a deprecation notice.

This will also help us to to know what code and tests we should remove before tagging 2.0

Copy link
Member

Choose a reason for hiding this comment

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

@Nyholm

I'm sure we would find out via static code analysis, so I think we do not need this.

Copy link
Member

Choose a reason for hiding this comment

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

But since you added it and we can easily remove it with the general_phpdoc_annotation_remove fixer, I think we can keep it in for now.

@pimjansen pimjansen added the enhancement New feature or request label Dec 21, 2020
@Nyholm Nyholm force-pushed the deprecate-property branch from 29bc1ec to 369975c Compare December 21, 2020 19:30
@Nyholm Nyholm force-pushed the deprecate-property branch from 369975c to 959f5ae Compare December 22, 2020 09:35
@localheinz localheinz merged commit 7e98a68 into FakerPHP:main Dec 22, 2020
@localheinz
Copy link
Member

Thank you, @Nyholm and @pimjansen!

@Nyholm
Copy link
Member Author

Nyholm commented Dec 22, 2020

Thank you for merging.

@Nyholm Nyholm deleted the deprecate-property branch December 22, 2020 10:33
krsriq pushed a commit to krsriq/Faker that referenced this pull request Jan 7, 2021
JuanDMeGon added a commit to JuanDMeGon/docs that referenced this pull request Apr 12, 2021
In concordance with [laravel#5583](laravel/laravel#5583), as after Faker PHP 1.14, using properties is deprecated, and it is recommended to use methods instead.

See [laravel#164](FakerPHP/Faker#164) for details.
JuanDMeGon added a commit to JuanDMeGon/docs that referenced this pull request Apr 12, 2021
In concordance with [laravel#5583](laravel/laravel#5583), as after Faker PHP 1.14, using properties is deprecated, and it is recommended to use methods instead.

See [laravel#164](FakerPHP/Faker#164) for details.
taylorotwell pushed a commit to laravel/docs that referenced this pull request Apr 13, 2021
* [8.x] Using faker methods instead of properties

In concordance with [#5583](laravel/laravel#5583), as after Faker PHP 1.14, using properties is deprecated, and it is recommended to use methods instead.

See [#164](FakerPHP/Faker#164) for details.

* [8.x] Using faker method instead of properties

In concordance with [#5583](laravel/laravel#5583), as after Faker PHP 1.14, using properties is deprecated, and it is recommended to use methods instead.

See [#164](FakerPHP/Faker#164) for details.
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.

3 participants