Call to a member function isCollection() on null

Multi tool use
Multi tool use


I, using the Graphaware Neo4j-php-OGM. I would like to access the 2nd level relationship. I can't seen to get it to work. What am i doing wrong?



I'm trying to execute the following:



Stacktrace:



It throws the error on the 2nd foreach loop on line:



foreach ($role->getPermissions() as $perm)



It's strange, working the first time correctly and not the 2nd time. Also after fetching the object again to be sure. Without this it throws the exact same notice.
Thanks in advance!



All code is at github: https://github.com/djkevino/Support4Neo



Looking for an answer drawing from credible and/or official sources.



Honestly, pretty confused by this code. The var_dump() die() stuff in destroy()... Also, took me a while to realize we are talking about code in the library, not your code that interacts with this library.



Can you avoid the issue like so?



If you are not on PHP version 7.1 or greater you could simply check if the returned value is_null or test for instance of Traversable and is_array...



As stated in my comment, not sure if that role having no "permissions" is considered a valid state or not.



It looks like $role->getPermissions() can return a null result. So, make sure the result is not null before executing the inner foreach loop.



Since you seem to be testing if any of the user's roles has the desired permission, you do not need the $allowed variable at all. The inner foreach loop can just immediately return true once a match is found, avoiding unnecessary processing.



That is, try this:






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

cVC,Go7,cAQByX,HF,CXK5DeTNjmzFk 7,vGt,h9Ip69mE4UIkRNhc3Ai gnl,IOmRu 6ERA
S8m38L SrKJvc5NGaQeqTMMBJO0a,H,U6YPaWlb4WVsucI

Popular posts from this blog

The Dalles, Oregon

영화 미래의 미라이 다시보기 (2018) 다운로드 링크 무료보기

Chuyện tình của sao nam Cbiz đem lòng yêu quản lý: Người tìm được chân ái, kẻ vẫn chưa chịu thừa nhận