GitHub Actions execute in Docker containers. An action can use an existing publicly available Docker image, or you can create your own Docker image by including a Dockerfile with your code.
「masterブランチでフィルタ」をしているのは、 Masterのactionですね。
ついでにというか、さっき疑問だった「どうやって外部のイメージをactionに定義するのか」もこれで解消しました。 use に指定するんですね。そして、依存関係にあるactionは前ステップにあたるあactionをneedsとして宣言する、と。
<?phpnamespace App;
use GuzzleHttp\Client;
use Psr\Http\Message\ResponseInterface;
/** * Class HogeService * @package App */class HogeService
{/** * HogeService constructor */publicfunction__construct(){$this->http =new Client();
}/** * Request user object to Hoge * * @param int $id user id to request * @return ResponseInterface */publicfunction getUser(int$id){return$this->http->get("/user/{$id}");
}}
<?phpnamespace App;
use GuzzleHttp\Client;
use Psr\Http\Message\ResponseInterface;
/** * Class HogeService * @package App */class HogeService
{/** * HogeService constructor */publicfunction__construct($client=null){$this->http =$client??new Client();
}/** * Request user object to Hoge * * @param int $id user id to requestc * @return ResponseInterface */publicfunction getUser(int$id){return$this->http->get("/user/{$id}");
}}
ここに、説明用にいろいろとテストケースを追加していきます。
1. PHPUnit MockObjectのpartial mockを用いた例
まずは、以下の内容で検査をできると考えました。
HogeService::getUser($userId)の呼び出し実行時に
Client::get()に対して
/user/:user_id を引数として
呼び出しが1回行われている
これをもって、「ちゃんとHogeをキックできている」と判断することとします
素直に書いてしまえば、この様になりました。
<?php/** * test to get() */publicfunction testGet(){$userId=100;
/** @var MockObject|HogeService $mock */$httpMock=$this->createPartialMock(Client::class, ['get']);
$httpMock->expects($this->once())->method('get')->with("/user/{$userId}");
$this->subject->http =$httpMock;
$this->subject->getUser($userId);
}
例えばPSR-0 autoloading standard *1などは、「PHP5.3で名前空間が入って、便利だけど、命名規則とかばらけちゃうとね」「もっとポテンシャル生かしてちゃんと使いたいよね」といった問題意識に端を発している訳です。
今では後継のPSR-4がPHPの「スタンダード」ですが、composerを含む「多種多様なライブラリを気軽に使える」エコシステムは、こうした提案力を持った存在により成立・推進されている面は大いにあると思います。ライブラリの作者からしても、より汎用性の高いものを作る上で、明確に「よくある」といえる実装やパターンがあると助かることもあるのではないでしょうか。そして、ライブラリの作成に関わる人数が増え、手が増えていくことで質の高いソフトウェアも生まれ・・・というサイクルがあると思います。
[Q] Do voting members have to comply to the standards?
[A] No. Becoming a voting member on the PHP-FIG in no way forces a member or project to implement every - or any - accepted PSRs. Projects have to consider backwards-compatibility issues when upgrading and make the changes at the right time, so it is assumed most projects will eventually adopt, but it is not a requirement.
Exactly. Instead of getting the common denominator from actual current frameworks, a whole new interface was built from nowhere. That's not how you get interop.
Laravel, Doctrine and now Symfony are out. What's the point of a "framework interoperability group" with most big players leaving because they cannot change the state of affairs, and cannot implement the new "standards".
&& ./configure \
--build="$gnuArch" \
--with-config-file-path="$PHP_INI_DIR" \
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \
\
# make sure invalid --configure-flags are fatal errors intead of just warnings
--enable-option-checking=fatal \
\
# https://github.com/docker-library/php/issues/439
--with-mhash \
\
# --enable-ftp is included here because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236)
--enable-ftp \
# --enable-mbstring is included here because otherwise there's no way to get pecl to use it properly (see https://github.com/docker-library/php/issues/195)
--enable-mbstring \
# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself)
--enable-mysqlnd \
# https://wiki.php.net/rfc/argon2_password_hash (7.2+)
--with-password-argon2 \
# https://wiki.php.net/rfc/libsodium
--with-sodium=shared \
\
--with-curl \
--with-libedit \
--with-openssl \
--with-zlib \
「his variant contains the PHP CLI tool with default mods」であり「Note that all variants of php contain the PHP CLI (/usr/local/bin/php).」であると。
「使い捨てコンテナ、もしくは他の何かを作るときのベースイメージとして使ってね〜」ということ