Skip to content

Commit

Permalink
Merge pull request #5 from ngmy/update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
ngmy authored Apr 3, 2021
2 parents 1655cd0 + 9f11e68 commit a24eaf0
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 21 deletions.
35 changes: 30 additions & 5 deletions .laradock/env-development
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ SHELL_OH_MY_ZSH_ALIASES=false

WORKSPACE_BASE_IMAGE_TAG_PREFIX=latest
WORKSPACE_COMPOSER_GLOBAL_INSTALL=true
WORKSPACE_COMPOSER_VERSION=2
WORKSPACE_COMPOSER_AUTH=false
WORKSPACE_COMPOSER_REPO_PACKAGIST=
WORKSPACE_NVM_NODEJS_ORG_MIRROR=
Expand All @@ -122,6 +123,7 @@ WORKSPACE_INSTALL_WORKSPACE_SSH=false
WORKSPACE_INSTALL_SUBVERSION=false
WORKSPACE_INSTALL_BZ2=false
WORKSPACE_INSTALL_GMP=false
WORKSPACE_INSTALL_GNUPG=false
WORKSPACE_INSTALL_XDEBUG=true
WORKSPACE_INSTALL_PCOV=false
WORKSPACE_INSTALL_PHPDBG=false
Expand All @@ -137,7 +139,7 @@ WORKSPACE_INSTALL_CASSANDRA=false
WORKSPACE_INSTALL_GEARMAN=false
WORKSPACE_INSTALL_MSSQL=false
WORKSPACE_INSTALL_DRUSH=false
WORKSPACE_DRUSH_VERSION=8.1.17
WORKSPACE_DRUSH_VERSION=8.4.6
WORKSPACE_INSTALL_DRUPAL_CONSOLE=false
WORKSPACE_INSTALL_WP_CLI=false
WORKSPACE_INSTALL_AEROSPIKE=false
Expand All @@ -156,6 +158,7 @@ WORKSPACE_INSTALL_POWERLINE=false
WORKSPACE_INSTALL_SUPERVISOR=false
WORKSPACE_INSTALL_IMAGE_OPTIMIZERS=false
WORKSPACE_INSTALL_IMAGEMAGICK=false
WORKSPACE_IMAGEMAGICK_VERSION=latest
WORKSPACE_INSTALL_TERRAFORM=false
WORKSPACE_INSTALL_DUSK_DEPS=false
WORKSPACE_INSTALL_PG_CLIENT=false
Expand All @@ -164,7 +167,7 @@ WORKSPACE_INSTALL_SWOOLE=false
WORKSPACE_INSTALL_TAINT=false
WORKSPACE_INSTALL_LIBPNG=false
WORKSPACE_INSTALL_GRAPHVIZ=false
WORKSPACE_INSTALL_IONCUBE=false
WORKSPACE_INSTALL_IONCUBE=false # PHP 8.0 is not supported yet. Reference: https://forum.ioncube.com/viewtopic.php?t=4592
WORKSPACE_INSTALL_MYSQL_CLIENT=false
WORKSPACE_INSTALL_PING=false
WORKSPACE_INSTALL_SSHPASS=false
Expand All @@ -184,7 +187,7 @@ WORKSPACE_INSTALL_AUDIOWAVEFORM=false
WORKSPACE_INSTALL_WKHTMLTOPDF=false
WORKSPACE_INSTALL_GNU_PARALLEL=false
WORKSPACE_INSTALL_AST=true
WORKSPACE_AST_VERSION=1.0.3
WORKSPACE_AST_VERSION=1.0.10
WORKSPACE_BROWSERSYNC_HOST_PORT=3000
WORKSPACE_BROWSERSYNC_UI_HOST_PORT=3001
WORKSPACE_VUE_CLI_SERVE_HOST_PORT=8080
Expand All @@ -194,6 +197,7 @@ WORKSPACE_INSTALL_GIT_PROMPT=false
WORKSPACE_INSTALL_DOCKER_CLIENT=false
WORKSPACE_INSTALL_LNAV=false
WORKSPACE_INSTALL_PROTOC=false
WORKSPACE_INSTALL_PHPDECIMAL=false
WORKSPACE_PROTOC_VERSION=latest

### PHP_FPM ###############################################
Expand All @@ -203,12 +207,14 @@ PHP_FPM_INSTALL_BCMATH=true
PHP_FPM_INSTALL_MYSQLI=true
PHP_FPM_INSTALL_INTL=true
PHP_FPM_INSTALL_IMAGEMAGICK=true
PHP_FPM_IMAGEMAGICK_VERSION=latest
PHP_FPM_INSTALL_OPCACHE=true
PHP_FPM_INSTALL_IMAGE_OPTIMIZERS=true
PHP_FPM_INSTALL_PHPREDIS=true
PHP_FPM_INSTALL_MEMCACHED=false
PHP_FPM_INSTALL_BZ2=false
PHP_FPM_INSTALL_GMP=false
PHP_FPM_INSTALL_GNUPG=false
PHP_FPM_INSTALL_XDEBUG=false
PHP_FPM_INSTALL_PCOV=false
PHP_FPM_INSTALL_XHPROF=false
Expand Down Expand Up @@ -237,7 +243,7 @@ PHP_FPM_INSTALL_POSTGIS=false
PHP_FPM_INSTALL_PCNTL=false
PHP_FPM_INSTALL_CALENDAR=false
PHP_FPM_INSTALL_FAKETIME=false
PHP_FPM_INSTALL_IONCUBE=false
PHP_FPM_INSTALL_IONCUBE=false # PHP 8.0 is not supported yet. Reference: https://forum.ioncube.com/viewtopic.php?t=4592
PHP_FPM_INSTALL_RDKAFKA=false
PHP_FPM_INSTALL_GETTEXT=false
PHP_FPM_INSTALL_XMLRPC=false
Expand All @@ -251,11 +257,13 @@ PHP_FPM_INSTALL_PING=false
PHP_FPM_INSTALL_SSHPASS=false
PHP_FPM_INSTALL_MAILPARSE=false
PHP_FPM_INSTALL_WKHTMLTOPDF=false
PHP_FPM_INSTALL_PHPDECIMAL=false
PHP_FPM_FFMPEG=false
PHP_FPM_AUDIOWAVEFORM=false
PHP_FPM_ADDITIONAL_LOCALES="en_US.UTF-8 es_ES.UTF-8 fr_FR.UTF-8"
PHP_FPM_INSTALL_DOCKER_CLIENT=false
PHP_FPM_DEFAULT_LOCALE=POSIX
PHP_FPM_XDEBUG_PORT=9003

PHP_FPM_PUID=1000
PHP_FPM_PGID=1000
Expand All @@ -271,8 +279,11 @@ PHP_FPM_NEW_RELIC_APP_NAME=app_name
PHP_WORKER_INSTALL_BZ2=false
PHP_WORKER_INSTALL_GD=false
PHP_WORKER_INSTALL_IMAGEMAGICK=false
PHP_WORKER_IMAGEMAGICK_VERSION=latest
PHP_WORKER_INSTALL_GMP=false
PHP_WORKER_INSTALL_GNUPG=false
PHP_WORKER_INSTALL_PGSQL=false
PHP_WORKER_INSTALL_MONGO=false
PHP_WORKER_INSTALL_BCMATH=false
# PHP_WORKER_INSTALL_OCI8 Does not work in php5.6 version
PHP_WORKER_INSTALL_OCI8=false
Expand Down Expand Up @@ -310,12 +321,15 @@ NGINX_SSL_PATH=./nginx/ssl/
LARAVEL_HORIZON_INSTALL_BZ2=false
LARAVEL_HORIZON_INSTALL_GD=false
LARAVEL_HORIZON_INSTALL_GMP=false
LARAVEL_HORIZON_INSTALL_GNUPG=false
LARAVEL_HORIZON_INSTALL_IMAGEMAGICK=false
LARAVEL_HORIZON_IMAGEMAGICK_VERSION=latest
LARAVEL_HORIZON_INSTALL_SOCKETS=false
LARAVEL_HORIZON_INSTALL_YAML=false
LARAVEL_HORIZON_INSTALL_ZIP_ARCHIVE=false
LARAVEL_HORIZON_INSTALL_PHPREDIS=true
LARAVEL_HORIZON_INSTALL_PHPREDIS=false
LARAVEL_HORIZON_INSTALL_MONGO=false
LARAVEL_HORIZON_INSTALL_CASSANDRA=false
LARAVEL_HORIZON_INSTALL_FFMPEG=false
LARAVEL_HORIZON_INSTALL_AUDIOWAVEFORM=false
LARAVEL_HORIZON_PGID=1000
Expand All @@ -327,10 +341,12 @@ APACHE_HOST_HTTP_PORT=80
APACHE_HOST_HTTPS_PORT=443
APACHE_HOST_LOG_PATH=./logs/apache2
APACHE_SITES_PATH=./apache2/sites
APACHE_SSL_PATH=./apache2/ssl
APACHE_PHP_UPSTREAM_CONTAINER=php-fpm
APACHE_PHP_UPSTREAM_PORT=9000
APACHE_PHP_UPSTREAM_TIMEOUT=60
APACHE_DOCUMENT_ROOT=/var/www/
APACHE_SSL_PATH=./apache2/ssl/
APACHE_INSTALL_HTTP2=false

### MYSQL #################################################
Expand Down Expand Up @@ -868,6 +884,15 @@ PGADMIN_PORT=5050
PGADMIN_DEFAULT_EMAIL=pgadmin4@pgadmin.org
PGADMIN_DEFAULT_PASSWORD=admin

### SWAGGER EDITOR ###########################################

SWAGGER_EDITOR_PORT=5151

### SWAGGER UI ###############################################

SWAGGER_API_URL=http://generator.swagger.io/api/swagger.json
SWAGGER_UI_PORT=5555

### SONARQUBE ################################################
## docker-compose up -d sonarqube
## (If you encounter a database error)
Expand Down
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ return PhpCsFixer\Config::create()
'inheritDoc' => 'inheritdoc',
],
],
'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true],
'native_constant_invocation' => true,
'native_function_invocation' => true,
'no_empty_phpdoc' => true,
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"@psalm"
],
"fmt": [
"@phpcbf",
"@php-cs-fixer"
"@php-cs-fixer",
"@phpcbf"
],
"doc": [
"@phpdoc"
Expand Down
19 changes: 14 additions & 5 deletions docs/api/classes/Ngmy-Observer-Subject.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ <h2 class="phpdocumentor-content__title">
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/Subject.php"><a href="files/src-subject.html"><abbr title="src/Subject.php">Subject.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">7</span>
<span class="phpdocumentor-element-found-in__line">9</span>
</aside>


Expand Down Expand Up @@ -163,7 +163,7 @@ <h4 class="phpdocumentor-element__name" id="property_observers">
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/Subject.php"><a href="files/src-subject.html"><abbr title="src/Subject.php">Subject.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">13</span>
<span class="phpdocumentor-element-found-in__line">16</span>
</aside>


Expand All @@ -189,6 +189,15 @@ <h5 class="phpdocumentor-tag-list__heading" id="tags">
<section class="phpdocumentor-description"><p>list<Observer></p>
</section>

</dd>
<dt class="phpdocumentor-tag-list__entry">
<span class="phpdocumentor-tag__name">psalm-var</span>
</dt>
<dd class="phpdocumentor-tag-list__definition">

<section class="phpdocumentor-description"><p>list<Observer></p>
</section>

</dd>
</dl>

Expand All @@ -213,7 +222,7 @@ <h4 class="phpdocumentor-element__name" id="method_attach">
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/Subject.php"><a href="files/src-subject.html"><abbr title="src/Subject.php">Subject.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">15</span>
<span class="phpdocumentor-element-found-in__line">18</span>
</aside>


Expand Down Expand Up @@ -255,7 +264,7 @@ <h4 class="phpdocumentor-element__name" id="method_detach">
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/Subject.php"><a href="files/src-subject.html"><abbr title="src/Subject.php">Subject.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">20</span>
<span class="phpdocumentor-element-found-in__line">23</span>
</aside>


Expand Down Expand Up @@ -297,7 +306,7 @@ <h4 class="phpdocumentor-element__name" id="method_notify">
<aside class="phpdocumentor-element-found-in">
<abbr class="phpdocumentor-element-found-in__file" title="src/Subject.php"><a href="files/src-subject.html"><abbr title="src/Subject.php">Subject.php</abbr></a></abbr>
:
<span class="phpdocumentor-element-found-in__line">31</span>
<span class="phpdocumentor-element-found-in__line">34</span>
</aside>


Expand Down
4 changes: 3 additions & 1 deletion src/Subject.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Ngmy\Observer;

use function array_values;

abstract class Subject
{
/**
Expand All @@ -23,7 +25,7 @@ public function detach(Observer $observer): void
foreach ($this->observers as $i => $o) {
if ($o->equals($observer)) {
unset($this->observers[$i]);
$this->observers = \array_values($this->observers);
$this->observers = array_values($this->observers);
return;
}
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Data/ConcreteObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Ngmy\Observer\Observer;
use Ngmy\Observer\Subject;

use const PHP_EOL;

class ConcreteObserver implements Observer
{
/** @var string */
Expand All @@ -29,7 +31,7 @@ public function update(Subject $changedSubject): void
{
if ($changedSubject === $this->subject) {
$this->state = $this->subject->getState();
echo $this->state . \PHP_EOL;
echo $this->state . PHP_EOL;
}
}

Expand Down
21 changes: 15 additions & 6 deletions tests/SubjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@

use Ngmy\Observer\Observer;

use function assert;
use function count;
use function method_exists;
use function ob_get_clean;
use function ob_start;
use function str_repeat;

use const PHP_EOL;

class SubjectTest extends TestCase
{
/**
Expand Down Expand Up @@ -37,7 +46,7 @@ public function attachProvider(): array
public function testAttach(array $observerClasses): void
{
$subject = new Data\ConcreteSubject();
\assert(\method_exists($subject, 'getObservers'));
assert(method_exists($subject, 'getObservers'));
$expected = [];
foreach ($observerClasses as $observerClass) {
$expected[] = new $observerClass($subject);
Expand Down Expand Up @@ -75,7 +84,7 @@ public function detachProvider(): array
public function testDetach(array $observerClasses): void
{
$subject = new Data\ConcreteSubject();
\assert(\method_exists($subject, 'getObservers'));
assert(method_exists($subject, 'getObservers'));
$observers = [];
foreach ($observerClasses as $observerClass) {
$observers[] = new $observerClass($subject);
Expand Down Expand Up @@ -116,16 +125,16 @@ public function notifyProvider(): array
public function testNofity(array $observerClasses): void
{
$subject = new Data\ConcreteSubject();
\assert(\method_exists($subject, 'getObservers'));
assert(method_exists($subject, 'getObservers'));
$observers = [];
foreach ($observerClasses as $observerClass) {
$observers[] = new $observerClass($subject);
}
$state = 'Test the observer pattern';
$expected = \str_repeat($state . \PHP_EOL, \count($observers));
\ob_start();
$expected = str_repeat($state . PHP_EOL, count($observers));
ob_start();
$subject->setState($state);
$actual = \ob_get_clean();
$actual = ob_get_clean();
$this->assertEquals($expected, $actual);
}
}

0 comments on commit a24eaf0

Please sign in to comment.