Comments (17)
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.
What is the codesnippet to reproduce behaviour that is not expected.
It is not initialized which means initially it is null?
from faker.
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.
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.
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.
@bramceulemans yes I guess? What are you asking exactly?
from faker.
Where is your constructor, your field assignment to $this->unique
?
from faker.
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.
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.
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.
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.
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.
I'm not sure that changing a phpdoc block would cause any breaking changes?
from faker.
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.
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.
387
from faker.
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)
- Add PHP version support policy HOT 2
- Add package version support policy HOT 1
- Discuss release schedule HOT 2
- Drop support for PHP 7.4 HOT 4
- Update docs to reflect different major versions HOT 2
- Remove functionality for populating ORM models and entities HOT 1
- The output of the md5(), sha1() and sha256() generators is misleading HOT 4
- The output of Base::randomFloat() is biased for certain inputs
- The Miscellaneous::boolean() generator could take a random float instead of an integer
- Warning DEPRECATED use of static pt_BR PhoneNumber HOT 1
- Opinions on Providing a Fake for CIDR/IP Prefixes HOT 3
- Faker images links are broken HOT 6
- Unable to get any other text but Latin HOT 4
- E-commerce Plugin - Feature HOT 1
- [ru_RU/PersonProvider] Double `а` in female lastName when using the `name()` function HOT 3
- Feature Request: Adjective Animal HOT 2
- Issue when try to use the create() function in the class_exists, throws an error when the documentation says the the function should not returns error just bool value. HOT 1
- `Generator::seed` in `Generator::__destruct` may break determinism HOT 1
- date/datetime functions not consistently seedable HOT 1
- `gmail.com.au` domain causes email validation to fail
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from faker.