Giter Club home page Giter Club logo

Comments (17)

pimjansen avatar pimjansen commented on June 17, 2024 1

I've created the issue to track the bug so others who encounter it as well can subscribe. You've closed my PR that fixes it already. So the version&roadmap this should be fixed in is your decision ofc.

Yeah that is fine. In the future these will be final so we can control it a bit better

from faker.

pimjansen avatar pimjansen commented on June 17, 2024

What is the codesnippet to reproduce behaviour that is not expected.

It is not initialized which means initially it is null?

from faker.

simPod avatar simPod commented on June 17, 2024

It is not initialized which means initially it is null?

Yes, how could it be something else?

final class Ooof extends Base
{
    public function readUnique() : UniqueGenerator
    {
        return $this->unique;
    }
}


$ooof = new Ooof(new Generator());
$ooof->readUnique(); // 🎶

from faker.

stale avatar stale commented on June 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 1 week if no further activity occurs. Thank you for your contributions.

from faker.

bram-pkg avatar bram-pkg commented on June 17, 2024

It is not initialized which means initially it is null?

Yes, how could it be something else?

final class Ooof extends Base
{
    public function readUnique() : UniqueGenerator
    {
        return $this->unique;
    }
}


$ooof = new Ooof(new Generator());
$ooof->readUnique(); // 🎶

Is the the full code snippet, @simPod ?

from faker.

simPod avatar simPod commented on June 17, 2024

@bramceulemans yes I guess? What are you asking exactly?

from faker.

bram-pkg avatar bram-pkg commented on June 17, 2024

Where is your constructor, your field assignment to $this->unique?

from faker.

simPod avatar simPod commented on June 17, 2024

Those are your classes as stated in the issue summary

use Faker\Generator;
use Faker\Provider\Base;
use Faker\UniqueGenerator;

final class Ooof extends Base
{
    public function readUnique() : UniqueGenerator
    {
        return $this->unique;
    }
}

$ooof = new Ooof(new Generator());
$ooof->readUnique(); // 🎶

from faker.

bram-pkg avatar bram-pkg commented on June 17, 2024

You are missing the constructor in your Ooof class, or am I misunderstanding you?

In order to initialize the unique property on our Base class, you need to call unique().

from faker.

simPod avatar simPod commented on June 17, 2024

If there's missing constructor, Base is the one missing it.

Either the unique property should be nullable or should be set some default value in Base.

from faker.

pimjansen avatar pimjansen commented on June 17, 2024

I do not think we can do an easy fix here without it being a breaking change.

Since we have a 2.x roadmap we can not just push these breaking changes (since this class is not final).

So i think we should live with it for now

from faker.

simPod avatar simPod commented on June 17, 2024

I've created the issue to track the bug so others who encounter it as well can subscribe. You've closed my PR that fixes it already. So the version&roadmap this should be fixed in is your decision ofc.

from faker.

bram-pkg avatar bram-pkg commented on June 17, 2024

I'm not sure that changing a phpdoc block would cause any breaking changes?

from faker.

pimjansen avatar pimjansen commented on June 17, 2024

I'm not sure that changing a phpdoc block would cause any breaking changes?

It will not but initialising it as null will. At this point it has no value.

The main issue is that it can cause an error that the value is used before initialising.

from faker.

stale avatar stale commented on June 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 1 week if no further activity occurs. Thank you for your contributions.

from faker.

simPod avatar simPod commented on June 17, 2024

387

from faker.

pimjansen avatar pimjansen commented on June 17, 2024

I am closing this since this can not be fixed without a breaking change we do not allow at this point (see contribution guide). For Faker 2.x we will take this into account. Probably those classes will be final to start with so that this can not be extended and only decorated or something like that.

from faker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.