Skip to content

Commit

Permalink
Merge pull request #136 from streakphp/php80
Browse files Browse the repository at this point in the history
upgrade to PHP 8.0
  • Loading branch information
alanbem authored Jul 3, 2021
2 parents 03ea69b + 6d2ed4f commit 6281b92
Show file tree
Hide file tree
Showing 105 changed files with 377 additions and 563 deletions.
3 changes: 3 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
'@PSR12:risky' => true,
'@PHP70Migration' => true,
'@PHP70Migration:risky' => true,
'@PHP80Migration' => true,
'@PHP80Migration:risky' => true,
'@Symfony:risky' => true,
'no_unused_imports' => true,
'ordered_imports' => true,
'ordered_class_elements' => true,
'strict_comparison' => true,
'native_constant_invocation' => false,
'php_unit_test_class_requires_covers' => true,
'php_unit_dedicate_assert_internal_type' => true,
'php_unit_mock' => true,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
]
},
"require": {
"php": ">=7.4",
"php": ">=8.0",
"ext-pdo": "*",
"ext-igbinary": "*",
"ext-redis": "*",
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ version: '3'
services:

php:
image: streakphp/php74-cli:latest
image: streakphp/php80-cli:latest
volumes:
- .:/var/www/project
- ./docker/php/etc/php/7.4/cli/php.ini:/etc/php/7.4/cli/php.ini
- ./docker/php/etc/php/8.0/cli/php.ini:/etc/php/8.0/cli/php.ini
working_dir: /var/www/project
depends_on:
- postgres
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
;;;;;;;;;;;;;;;;;;;
; Quick Reference ;
;;;;;;;;;;;;;;;;;;;

; The following are all the settings which are different in either the production
; or development versions of the INIs with respect to PHP's default behavior.
; Please see the actual settings later in the document for more details as to why
Expand All @@ -99,12 +100,12 @@
; Production Value: Off

; display_startup_errors
; Default Value: Off
; Default Value: On
; Development Value: On
; Production Value: Off

; error_reporting
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Default Value: E_ALL
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

Expand Down Expand Up @@ -153,6 +154,16 @@
; Development Value: "GPCS"
; Production Value: "GPCS"

; zend.exception_ignore_args
; Default Value: Off
; Development Value: Off
; Production Value: On

; zend.exception_string_param_max_len
; Default Value: 15
; Development Value: 15
; Production Value: 0

;;;;;;;;;;;;;;;;;;;;
; php.ini Options ;
;;;;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -352,21 +363,31 @@ zend.enable_gc = On
; If enabled, scripts may be written in encodings that are incompatible with
; the scanner. CP936, Big5, CP949 and Shift_JIS are the examples of such
; encodings. To use this feature, mbstring extension must be enabled.
; Default: Off
;zend.multibyte = Off

; Allows to set the default encoding for the scripts. This value will be used
; unless "declare(encoding=...)" directive appears at the top of the script.
; Only affects if zend.multibyte is set.
; Default: ""
;zend.script_encoding =

; Allows to include or exclude arguments from stack traces generated for exceptions.
; In production, it is recommended to turn this setting on to prohibit the output
; of sensitive information in stack traces
; Default: Off
; Default Value: Off
; Development Value: Off
; Production Value: On
zend.exception_ignore_args = On

; Allows setting the maximum string length in an argument of a stringified stack trace
; to a value between 0 and 1000000.
; This has no effect when zend.exception_ignore_args is enabled.
; Default Value: 15
; Development Value: 15
; Production Value: 0
; In production, it is recommended to set this to 0 to reduce the output
; of sensitive information in stack traces.
zend.exception_string_param_max_len = 0

;;;;;;;;;;;;;;;;;
; Miscellaneous ;
;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -458,7 +479,7 @@ memory_limit = -1
; E_ALL & ~E_NOTICE (Show all errors, except for notices)
; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.)
; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Default Value: E_ALL
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; http://php.net/error-reporting
Expand All @@ -482,11 +503,9 @@ error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off

; The display of errors which occur during PHP's startup sequence are handled
; separately from display_errors. PHP's default behavior is to suppress those
; errors from clients. Turning the display of startup errors on can be useful in
; debugging configuration problems. We strongly recommend you
; set this to 'off' for production servers.
; Default Value: Off
; separately from display_errors. We strongly recommend you set this to 'off'
; for production servers to avoid leaking configuration details.
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-startup-errors
Expand Down Expand Up @@ -524,19 +543,9 @@ ignore_repeated_source = Off
; http://php.net/report-memleaks
report_memleaks = On

; This setting is on by default.
; This setting is off by default.
;report_zend_debug = 0

; Store the last error/warning message in $php_errormsg (boolean). Setting this value
; to On can assist in debugging and is appropriate for development servers. It should
; however be disabled on production servers.
; This directive is DEPRECATED.
; Default Value: Off
; Development Value: Off
; Production Value: Off
; http://php.net/track-errors
;track_errors = Off

; Turn off normal error reporting and emit XML-RPC error XML
; http://php.net/xmlrpc-errors
;xmlrpc_errors = 0
Expand Down Expand Up @@ -915,7 +924,7 @@ default_socket_timeout = 60
;extension=ffi
;extension=ftp
;extension=fileinfo
;extension=gd2
;extension=gd
;extension=gettext
;extension=gmp
;extension=intl
Expand All @@ -925,6 +934,7 @@ default_socket_timeout = 60
;extension=exif ; Must be after mbstring as it depends on it
;extension=mysqli
;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
;extension=oci8_19 ; Use with Oracle Database 19 Instant Client
;extension=odbc
;extension=openssl
;extension=pdo_firebird
Expand All @@ -945,9 +955,10 @@ default_socket_timeout = 60
;extension=sodium
;extension=sqlite3
;extension=tidy
;extension=xmlrpc
;extension=xsl

;zend_extension=opcache

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
Expand All @@ -968,10 +979,10 @@ date.timezone = "Europe/London"
;date.default_longitude = 35.2333

; http://php.net/date.sunrise-zenith
;date.sunrise_zenith = 90.583333
;date.sunrise_zenith = 90.833333

; http://php.net/date.sunset-zenith
;date.sunset_zenith = 90.583333
;date.sunset_zenith = 90.833333

[filter]
; http://php.net/filter.default
Expand Down Expand Up @@ -1048,8 +1059,6 @@ date.timezone = "Europe/London"
; http://php.net/pdo-odbc.connection-pooling
;pdo_odbc.connection_pooling=strict

;pdo_odbc.db2_instance_name

[Pdo_mysql]
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
Expand Down Expand Up @@ -1585,11 +1594,6 @@ zend.assertions = -1
; http://php.net/assert.callback
;assert.callback = 0

; Eval the expression with current error_reporting(). Set to true if you want
; error_reporting(0) around the eval().
; http://php.net/assert.quiet-eval
;assert.quiet_eval = 0

[COM]
; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs
; http://php.net/com.typelib-file
Expand All @@ -1615,6 +1619,10 @@ zend.assertions = -1
; Default: system ANSI code page
;com.code_page=

; The version of the .NET framework to use. The value of the setting are the first three parts
; of the framework's version number, separated by dots, and prefixed with "v", e.g. "v4.0.30319".
;com.dotnet_version=

[mbstring]
; language for internal character representation.
; This affects mb_send_mail() and mbstring.detect_order.
Expand Down Expand Up @@ -1664,20 +1672,8 @@ zend.assertions = -1
; http://php.net/mbstring.substitute-character
;mbstring.substitute_character = none

; overload(replace) single byte functions by mbstring functions.
; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(),
; etc. Possible values are 0,1,2,4 or combination of them.
; For example, 7 for overload everything.
; 0: No overload
; 1: Overload mail() function
; 2: Overload str*() functions
; 4: Overload ereg*() functions
; http://php.net/mbstring.func-overload
;mbstring.func_overload = 0

; enable strict encoding detection.
; Default: Off
;mbstring.strict_detection = On
; Enable strict encoding detection.
;mbstring.strict_detection = Off

; This directive specifies the regex pattern of content types for which mb_output_handler()
; is activated.
Expand All @@ -1686,12 +1682,10 @@ zend.assertions = -1

; This directive specifies maximum stack depth for mbstring regular expressions. It is similar
; to the pcre.recursion_limit for PCRE.
; Default: 100000
;mbstring.regex_stack_limit=100000

; This directive specifies maximum retry count for mbstring regular expressions. It is similar
; to the pcre.backtrack_limit for PCRE.
; Default: 1000000
;mbstring.regex_retry_limit=1000000

[gd]
Expand Down Expand Up @@ -1806,6 +1800,11 @@ ldap.max_links = -1
; size of the optimized code.
;opcache.save_comments=1

; If enabled, compilation warnings (including notices and deprecations) will
; be recorded and replayed each time a file is included. Otherwise, compilation
; warnings will only be emitted when the file is first cached.
;opcache.record_warnings=0

; Allow file existence override (file_exists, etc.) performance feature.
;opcache.enable_file_override=0

Expand Down
2 changes: 1 addition & 1 deletion docker/redis/usr/local/etc/redis/redis.conf
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ databases 16
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.
stop-writes-on-bgsave-error yes
stop-writes-on-bgsave-error no

# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' as it's almost always a win.
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<junit outputFile="build/.phpunit/junit.xml"/>
</logging>
<php>
<ini name="error_reporting" value="-1" />
<env name="PHPUNIT_POSTGRES_HOSTNAME" value="postgres"/>
<env name="PHPUNIT_POSTGRES_PORT" value="5432"/>
<env name="PHPUNIT_POSTGRES_DATABASE" value="phpunit"/>
Expand Down
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
// $configurator->import(SetList::CODE_QUALITY);
$configurator->import(SetList::EARLY_RETURN);
$configurator->import(SetList::PHP_74);
$configurator->import(SetList::PHP_80);
// $configurator->import(SetList::PRIVATIZATION);

$parameters->set(Option::SKIP, [
Expand Down
5 changes: 1 addition & 4 deletions src/Application/CommandHandler/AggregateRootHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@
*/
class AggregateRootHandler implements CommandHandler
{
private AggregateRoot\Repository $repository;

public function __construct(AggregateRoot\Repository $repository)
public function __construct(private AggregateRoot\Repository $repository)
{
$this->repository = $repository;
}

public function handleCommand(Command $command): void
Expand Down
5 changes: 1 addition & 4 deletions src/Application/QueryHandler/EventListenerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@
*/
class EventListenerHandler implements QueryHandler
{
private Subscription\Repository $repository;

public function __construct(Subscription\Repository $repository)
public function __construct(private Subscription\Repository $repository)
{
$this->repository = $repository;
}

public function handleQuery(Query $query)
Expand Down
13 changes: 10 additions & 3 deletions src/Application/Sensor/Processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

/**
* @author Alan Gabriel Bem <[email protected]>
*
* @see \Streak\Application\Sensor\ProcessingTest
*/
trait Processing
{
Expand Down Expand Up @@ -85,17 +87,22 @@ final public function process(...$messages): void
}

$parameterType = $parameter->getType();

// ...is not an union...
if (!$parameterType instanceof \ReflectionNamedType) {
continue;
}

$parameterType = $parameterType->getName();

$messageIsClass = class_exists($parameterType);
$parameterIsClass = \is_object($message);

if (true === $messageIsClass && true === $parameterIsClass) {
$parameter = $parameter->getClass();
$target = new \ReflectionClass($message);

// .. and $message is type or subtype of defined $parameter
while ($parameter->getName() !== $target->getName()) {
while ($parameterType !== $target->getName()) {
$target = $target->getParentClass();

if (false === $target) {
Expand Down Expand Up @@ -147,7 +154,7 @@ final public function process(...$messages): void
$this->pending = [];
}

final private function addEvent(Event $event): void
private function addEvent(Event $event): void
{
$this->pending[] = Event\Envelope::new($event, $this->producerId());
}
Expand Down
Loading

0 comments on commit 6281b92

Please sign in to comment.