What are the Slack Archives?
Itβs a history of our time together in the Slack Community! Thereβs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonβt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
I am wondering why the `LoggerTrait::getLogguer()` says that it can return a null π€
I am wondering why the LoggerTrait::getLogguer()
says that it can return a null π€
https://github.com/spryker/log/blob/master/src/Spryker/Shared/Log/LoggerTrait.php#L17
/** * @return \Psr\Log\LoggerInterface|null ππππππππππ */ protected function getLogger(?LoggerConfigInterface $loggerConfig = null) { return LoggerFactory::getInstance($loggerConfig); }
when inside the LoggerFactory
you are actually creating a logger in case it doesnβt exist (see: createInstanceIfNotExists
)
https://github.com/spryker/log/blob/ad13572ac0b671bebfd64a41216719e52e7cf703/src/Spryker/Shared/Log/LoggerFactory.php#L33
/** * @return \Psr\Log\LoggerInterface|null ππππππππππ */ public static function getInstance(?LoggerConfigInterface $loggerConfig = null) { if ($loggerConfig === null) { if (!static::$loggerConfig) { static::$loggerConfig = static::createLoggerConfig(); } $loggerConfig = static::$loggerConfig; } return static::createInstanceIfNotExists($loggerConfig); ππππππππππ }
And that function explicitly says (in its PHPDoc) that it wont return a null:
https://github.com/spryker/log/blob/ad13572ac0b671bebfd64a41216719e52e7cf703/src/Spryker/Shared/Log/LoggerFactory.php#L51
/** * @return \Psr\Log\LoggerInterface ππππππππππ */ protected static function createInstanceIfNotExists(LoggerConfigInterface $loggerConfig) { $channelName = $loggerConfig->getChannelName(); if (!isset(static::$loggers[$channelName])) { $logger = new MonologLogger($channelName, $loggerConfig->getHandlers(), $loggerConfig->getProcessors()); static::$loggers[$channelName] = $logger; } return static::$loggers[$channelName]; }
========================
Why I am saying this is because PHPStan level 8 is actually complaining about this, and it does makes sense that it complains about it, because the types signature are not correct. Am I missing something here or is it just wrong?
I wanted to create a PR to fix this but the repo is
[READ ONLY] Subtree split of the Log module.
β¦ so I guess I canβt.
Comments
-
Hi @U015S0C0V29, hopefully someone from our developers will take a look into this. I just wanted to say that you are free to create an external PR to that repo. It's just that we will need to import it to our internal mono repo where Spryker develops. And from there it will be released back as a new version. You will remain as the author\who to blame for the change though. π
0 -
it's just an interface that was changed at some point https://github.com/spryker/log/commit/568bf8e82d0bcc6644bc5856a2ca4b232c472157
0 -
-
no relations to implementation
0 -
@valerii.trots thatβs good news, I didnβt know that! Thanks! π
@ULSLLNL7K I thought something like that too. I think itβs just not updated to the actual/current state. Right now it clearly not returning a
null
ever, so I think it makes sense to remove the nullable there in the signature π0 -
Here you got the PR: https://github.com/spryker/log/pull/1
0 -
Thanks! I'll proceed with it as soon as I have time.
I'll need to create an internal ticket for our developers, then I'll import it through our release app, then it will stay in the queue to be reviewed, tested and released. π0 -
Nice, thanks for your help! If I need to change or adapt something let me know π§βπ³πΌ
0 -
Thank you for your contribution! π
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random