“
Errors and exceptions
╺ Any fatal error can be catch;
╺ E_STRICT notices have been reclassified to
E_WARN and E_NOTICE;
╺ Fatal errors are or inherit the class "Error";
╺ Syntax parsing errors generate "ParseError";
╺ "Error" and "Exception" implement interface
"Throwable".
Slide 21
Slide 21 text
“
Errors and exceptions
Slide 22
Slide 22 text
“
Errors and exceptions
Slide 23
Slide 23 text
“
Scalar type hints
╺ Weak mode;
╺ Strict mode.
Slide 24
Slide 24 text
“
Scalar type hints
Slide 25
Slide 25 text
“
Scalar type hints
* Only non-NaN floats between PHP_INT_MIN and PHP_INT_MAX accepted.
† Non-numeric strings not accepted. Numeric strings with trailing characters are accepted, but produce a
notice.
‡ Only if it has a __toString method.
Slide 26
Slide 26 text
“
Argon2
password hash
Slide 27
Slide 27 text
“
libsodium
Slide 28
Slide 28 text
“
Mudanças
internas
Slide 29
Slide 29 text
“
64-bit support
╺ Strings greater than 2³¹;
╺ Large file support (LFS);
╺ 64-bit integer support.
“
Hashtable
[0]: empty
[1]:
[2]: empty
[3]: empty
“foo”
hash
data
key: “foo”
“bar”
next
data
key: “bar”
next = NULL
Credits: Nikita Popov
Slide 35
Slide 35 text
“
Hashtable
[0]: empty
[1]:
[2]: empty
[3]: empty
“foo”
hash
data
key: “foo”
“bar”
next
data
key: “bar”
next = NULL
head
tail
Slide 36
Slide 36 text
“
Já no PHP7
Hashtable
Slide 37
Slide 37 text
“
Hashtable
[0]: empty
[1]:
[2]: empty
[3]:
“foo”
hash
data
key: “foo”
“bar”
next
data
key: “bar”
next = NULL
“baz”
data
key: “baz”
next = NULL
Credits: Nikita Popov
Slide 38
Slide 38 text
“
Hashtable
[0]: empty
[1]:
[2]: empty
[3]:
“foo”
hash
data
key: “foo”
next = NULL
TOMBSTONE
“baz”
data
key: “baz”
next = NULL
Credits: Nikita Popov
Slide 39
Slide 39 text
“
Hashtable
╺ Hashtable reduced from 72 to 56 bytes;
╺ Bucket reduced from 72 to 32 bytes.
Slide 40
Slide 40 text
“
Data structure optimization
╺ Average of 20% of the time in PHP 5 was memory
allocation;
╺ Reduced number of allocations;
╺ Reduced memory consumption;
╺ Reduced number of indirect;
╺ Strings are refcounted.
Slide 41
Slide 41 text
“
zval
Credits: Nikita Popov
ty
value
Slide 42
Slide 42 text
“
zval
Credits: Nikita Popov
ty
value (simple)
null, bool, int, float
Slide 43
Slide 43 text
“
zval
Credits: Nikita Popov
ty
value (complex)
complex data structure:
string, array, object
Slide 44
Slide 44 text
“
zval
Credits: Nikita Popov
refcount=1 ty
value (complex)
complex data structure:
string, array, object
zval*
$a
Slide 45
Slide 45 text
“
zval
Credits: Nikita Popov
refcount=1 ty
value (complex)
complex data structure:
string, array, object
zval*
$a
Slide 46
Slide 46 text
“
zval
Credits: Nikita Popov
refcount=2 ty
value (complex)
complex data structure:
string, array, object
zval*
$a
zval*
$b
Slide 47
Slide 47 text
“
zval
Nos dias de
hoje...
Slide 48
Slide 48 text
“
zval
Credits: Nikita Popov
type_info
value (complex)
zval*
$a
zval*
$b
refcount=2
complex data structure:
string, array, object
Slide 49
Slide 49 text
“
zval
Credits: Nikita Popov
type_info
value (complex)
$a
$b
refcount=2
complex data structure:
string, array, object
type_info
value (complex)
Slide 50
Slide 50 text
PHP5
Credits: Nikita Popov
zval*
refcount=1 ty
value (simple)
null, bool, int, float
╺ 1 memory allocation;
╺ 1 level of indirection;
╺ 40 bytes.
type_info
value (simple)
null, bool, int, float
PHP7
╺ no memory allocation;
╺ without indirection;
╺ 16 bytes.
Slide 51
Slide 51 text
PHP5
Credits: Nikita Popov
zval*
refcount=1 ty
value (complex)
╺ 2 memory allocation;
╺ 2 levels of indirection;
╺ 40 bytes.
type_info
value (complex)
PHP7
╺ 1 memory allocation;
╺ 1 level of indirection;
╺ 24 bytes.
complex data structure:
string, array, object
refcount=1
complex data structure:
string, array, object
Slide 52
Slide 52 text
“
zval
Slide 53
Slide 53 text
“
PHP.NEXT
Slide 54
Slide 54 text
“
PHP.NEXT
╺ Immutable classes and properties;
╺ Arrow functions;
╺ Traits with interfaces;
╺ Named parameters;
╺ Operator functions.