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

⭐ Isolate settings in factories #2345

Closed
kylekatarnls opened this issue May 31, 2021 · 0 comments
Closed

⭐ Isolate settings in factories #2345

kylekatarnls opened this issue May 31, 2021 · 0 comments
Assignees
Milestone

Comments

@kylekatarnls
Copy link
Collaborator

Global setters like setTestNow, serializeUsing, setTranslator etc. are not isolated when called from factories:

CarbonImmutable::setTestNow('1990-07-31 23:59:59');

$libAFactory = new FactoryImmutable();
$libAFactory->setTestNow('2000-02-05 15:20:00');

$libBFactory = new FactoryImmutable();
$libBFactory->setTestNow('2050-12-01 00:00:00');

echo $libAFactory->now() . "\n"; // 2000-02-05 15:20:00
echo $libBFactory->now() . "\n"; // 2050-12-01 00:00:00
echo CarbonImmutable::now() . "\n"; // 1990-07-31 23:59:59

Carbon version: 2.84.1

PHP version: 8.0.0

Expected output:

2000-02-05 15:20:00
2050-12-01 00:00:00
1990-07-31 23:59:59

Current output:

2050-12-01 00:00:00
2050-12-01 00:00:00
2050-12-01 00:00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant