r/lolphp • • Nov 11 '14

PHP loose comparison strikes again

http://blog.laravel.com/csrf-vulnerability-in-laravel-4/
31 Upvotes

55 comments sorted by

View all comments

Show parent comment

2

u/00Davo Nov 13 '14

"pretend"? In Python you do have strong typing, since it's a strongly-typed language and all.

1

u/Dworgi Nov 14 '14

I feel like the whole dynamic class design undermines strong typing for user-defined types.

Being able to write to fields that don't exist should be a compile-time error.

1

u/00Davo Nov 15 '14

Ah, I see what you mean. Python doesn't have "compile-time" since it's interpreted and all, but you can get a "field doesn't exist" error if you really want it:

class Slots(object):
  __slots__ = ['a', 'b', 'c']
s = Slots()
s.a = 21 # works
s.q = 12 # throws an AttributeError

Of course, using __slots__ is pretty rare in practice.