IS IT POSSIBLETO WRITE
STRICTLYTYPED PHP CODE?
Never trust accepted answer at stackoverﬂow
• Static/Dynamic typing is about when type
information is aquired (at compiletime or at
• Strong/Weak typing is about how strictly types
are distinguished (e.g. whether the language tries
to do implicit conversion from strings to
WEAKTYPING AND STRICT
• Fully strict type checking where no conversion happens (Go,
• Widening primitive type checking where “safe” conversions
happen (Java, Pascal, PHP Objects).
• Weak type checking which all conversions are allowed, with
possible warnings raised (which is used to a limited extent by C,
C#, C++ andVisual Basic, PHP scalars?)
“DESPITE THEIR PRODUCTIVITY
LANGUAGES MAY NOT BE THE BEST
CHOICES FOR ALL APPLICATIONS,
PARTICULARLY FOR VERY LARGE
CODE BASES AND HIGH-
FOR PHP 5.4+
• integer, int
• ﬂoat, double
• boolean, bool
• “Internal functions cannot use strict hints, only user
code is supported.”
• “Because the parser detects scalar hints as classes,
they cannot have default values.” This was written before we knew that
PHP7 would get strict parameter and
The best thing to do now is probably
make this a close approximation of
compatibility for PHP5 ... I'm super
busy right now and this isn't really a
“ I'm super busy right now and this isn't really a
Zephir, an open source, high-level language designed to ease the
creation and maintainability of extensions for PHP with a focus on type
and memory safety.
• boolean A boolean expresses a truth value. It can be either ‘true’ or ‘false’.
• integer Signed integers.At least 16 bits in size.
• unsigned integer Unsigned integers.At least 16 bits in size.
• char Smallest addressable unit of the machine that can contain basic character set.
• unsigned char Same size as char, but guaranteed to be unsigned.
• long Long signed integer type.At least 32 bits in size.
• unsigned long Same as long, but unsigned.
• ﬂoat/double Double precision ﬂoating-point type.The size is platform-dependent.
• string A string is series of characters, where a character is the same as a byte.
• array An structure that can be used as hash, map, dictionary, collection, stack, etc.
• StreamSelectLoop - out of the box
• LibEventLoop -This uses the libevent pecl extension with a
number of system-speciﬁc backends (epoll, kqueue).
• LibEvLoop -This uses the libev pecl extension (github). It
supports the same backends as libevent.
• ExtEventLoop -This uses the event pecl extension. It
supports the same backends as libevent
Ratchet is a loosely coupled PHP library providing developers with
tools to create real time, bi-directional applications between clients
and servers over WebSockets.
• Supports the RFC6455, HyBi-10+, and Hixie76 protocol
versions (at the same time)
• Tested on Chrome 13+, Firefox 6+, Safari 5+, iOS 4.2+, IE 8+
• Ratchet passes the Autobahn Testsuite (non-binary