为什么在转换时认为类类型是常量?
PHPStorm,将 (MyObject) 突出显示为未定义的常量?并在后面有一个突出显示的位,要求输入预期的分号(MyObject);?
$MyObject = (MyObject)(Doctrine::getTable('MyTable')->findOneById($id));
当我 Cntrl-N (MyObject) 时,它会转到 MyObject 的正确定义,因此检查有效。该表达式调用类工厂,因此我尝试对其进行强制转换,以便编辑器知道变量 $MyObject 的类型是什么。我配置错了什么?
PHPStorm, highlights (MyObject) as an undefined constant? and has a highlighted bit afterward asking for an expected semicolon (MyObject);?
$MyObject = (MyObject)(Doctrine::getTable('MyTable')->findOneById($id));
When I Cntrl-N (MyObject) it goes to the correct definition for MyObject, so the inspection works. The expression calls a class factory, so I am trying to cast it so that the rest of the time, the editor knows what the variable $MyObject's type is. What have I configured wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您正在进行强制转换以获得代码完成,还有另一种方法可以通知 PHPStorm:
您更喜欢哪种方法取决于您。
If you are doing the cast to get code completion, there is another way to inform PHPStorm:
It's on you what method you prefer.
我认为这是可能的。这只是 PHPStorm 的一个错误。转换是正确的,但您缺少
)
如果不仅仅是将问题发布到 Stackoverflow 时输入错误,这可能是错误的原因。
I think it's possible. This is just an error with PHPStorm. The cast is correct, but you're missing a
)
Which could be the cause of the error if it's not just a mistype posting the question to Stackoverflow.