Slide 1

Slide 1 text

PHP 7 Not for kids

Slide 2

Slide 2 text

*/omarkdev

Slide 3

Slide 3 text

“ Performance

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

“ Mudanças para o usuário

Slide 9

Slide 9 text

Tags

Slide 10

Slide 10 text

Static calls to non-static methods

Slide 11

Slide 11 text

PHP 4 style constructors

Slide 12

Slide 12 text

Removed Extensions and SAPIs Extensions: ereg, mssql, mysql, sybase_ct. Servers APIs: aolserver, apache, apache_hooks, apache2filter, caudium, continuity, isapi, milter, nsapi, phttpd, pi3web, roxen, thttpd, tux, webjames.

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Null coalesce operator

Slide 15

Slide 15 text

Null coalesce operator

Slide 16

Slide 16 text

Spaceship operator

Slide 17

Slide 17 text

Spaceship operator

Slide 18

Slide 18 text

Spaceship operator

Slide 19

Slide 19 text

Nullable types

Slide 20

Slide 20 text

“ 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.

Slide 30

Slide 30 text

“ AST PHP 5 PHP 7 PHP Parser Opcodes Execution PHP Parser AST Opcodes Execution

Slide 31

Slide 31 text

“ Hashtable [0]: empty [1]: empty [2]: empty [3]: empty “foo” hash Credits: Nikita Popov

Slide 32

Slide 32 text

“ Hashtable [0]: empty [1]: [2]: empty [3]: empty “foo” hash data key: “foo” zval Credits: Nikita Popov

Slide 33

Slide 33 text

“ Hashtable [0]: empty [1]: [2]: empty [3]: empty “foo” hash data key: “foo” zval “bar” Credits: Nikita Popov

Slide 34

Slide 34 text

“ 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.

Slide 55

Slide 55 text

No content