Type hinting in PHPStorm for transfer object collections
Hello community!
Recently on our project we've updated the `spryker/transfer` module, including this version:
In the changelog, it says:
- Adjusted docblock type hint for the collection using generic syntax
ArrayObject<Object>
insteadArrayObject|Object[]
.
This improvement makes sense to me, but PHPStorm does not support this properly.
With the new annotation, many of our tests no longer have type hinting. This happens in the case when we try to access ArrayObject
element by index [0]
, [1]
, etc
I've tried different settings in PHPStorm (or even plugins), but couldn't find a solution. offsetGet
or getArrayCopy
don't work as well.
So my question here: am I missing something in PHPStorm? Or if the problem exists for all projects, maybe it makes sense to rollback the PHPDoc for collections in spryker/transfer
module to the old logic?
Comments
-
Hi, Vasily!
It seems to me that this inconvenience is affecting only a very limited amount of developers, since we hear about it for the first time, although many of our customers are using this version of Transfer module.
Semantically, we now define more accurate type for the properties of type ArrayObject.
Though it seems to me as well - PhpStorm is not working correctly with PHP Generics.
We will look into this issue as soon as possible.
Meanwhile, I'm happy to support your report to PhpStorm in order to start supporting PHP Generics.
I found that the support is very limited around 2 months ago, although PHP Stan supports them very well, what was our primary goal.
1
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