syntaxseed,
@syntaxseed@phpc.social avatar

So I have a User entity in a project with an int type $id property. And something deep in the framework is trying to assign a string value to the $id which is throwing critical type errors.

WTH. Am I supposed to make User::$id a string|int type? No thanks. It's in the framework so out of my hands. Some token unserializing step.

Bizarre.

thgs,
@thgs@phpc.social avatar

@syntaxseed what was it?

syntaxseed,
@syntaxseed@phpc.social avatar

@thgs I added a setId() method to the User class that takes an int or string & casts it. Hoping that will get called automatically by whatever caused that error.

thgs,
@thgs@phpc.social avatar

@syntaxseed Callstack doesn't help? Xdebug helps me a lot with those. I've been doing mappings like that all day today. I break early and go step by step

thgs, (edited )
@thgs@phpc.social avatar

@syntaxseed oh just realized it's not a mapping. I've put a break in index.php before and jump in. Always fun to see it all!

syntaxseed,
@syntaxseed@phpc.social avatar

@thgs I can't reproduce it, it's very rare. 🤷‍♀️

thgs,
@thgs@phpc.social avatar

@syntaxseed a rare gem, it is. May the force be with you

Or luck, so that it doesn't appear again!

thomastospace,
@thomastospace@phpc.social avatar

@syntaxseed My guess: Your getUserIdentifier() method inside of your User returns the $id. However, the getUserIdentifier method should return something like email or username.

syntaxseed,
@syntaxseed@phpc.social avatar

@thomastospace Hmm... I'll check on that. Pretty sure it returns email, but I'll make sure.

thomastospace,
@thomastospace@phpc.social avatar

@syntaxseed If it's not that, feel free to share some code. It could also be a problem inside the Authenticator.

syntaxseed,
@syntaxseed@phpc.social avatar

Uncaught PHP Exception TypeError: "Cannot assign string to property App\Entity\User::$id of type ?int" at /vendor/symfony/security-http/Firewall/ContextListener.php line 267

Symfony 6.2.

🤔

lewiscowles1986,
@lewiscowles1986@phpc.social avatar

@syntaxseed cant you treat it as a string, and unmarshall yourself?

There are so many reasons I'd want app code to treat a primary key as a string; and only want the nitty gritty of int etc at the outer layer & storage.

Not all strings are ints, but I've never seen a primary key without a string representation available.

I've also never seen anyone represent a uuid, snowflake id, or other primary key as a single int successfully.

devnix,

@syntaxseed Maybe the problem is in the mapping. Shut up and show us the code 😄

  • All
  • Subscribed
  • Moderated
  • Favorites
  • Symfony
  • kavyap
  • InstantRegret
  • ethstaker
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • thenastyranch
  • Youngstown
  • tacticalgear
  • slotface
  • Durango
  • khanakhh
  • rosin
  • everett
  • Leos
  • vwfavf
  • normalnudes
  • osvaldo12
  • cubers
  • GTA5RPClips
  • cisconetworking
  • ngwrru68w68
  • anitta
  • provamag3
  • tester
  • modclub
  • megavids
  • JUstTest
  • All magazines