Skip to content

Commit

Permalink
Merge 1347725 into b129251
Browse files Browse the repository at this point in the history
  • Loading branch information
crynobone committed Oct 28, 2022
2 parents b129251 + 1347725 commit 03d6fa2
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
/.scrutinizer.yml export-ignore
/.travis.yml export-ignore
/canvas.yaml export-ignore
/phpstan-baseline.neon export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml export-ignore
/sync.sh export-ignore
/CHANGELOG-*.md export-ignore
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/analyse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: analyse

on:
push:
pull_request:

jobs:
analyse:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
os:
- "ubuntu-latest"
php:
- "8.0"
experimental:
- true

name: PHP${{ matrix.php }} on ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, intl, fileinfo
coverage: none

- name: Install dependencies
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"
composer-options: "--prefer-dist --no-cache"

- name: Installed dependencies
run: composer show -D

- name: Execute Static Code Analysis
run: vendor/bin/phpstan analyse
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"require-dev": {
"laravel/laravel": "9.x-dev",
"laravel/pint": "^1.1",
"orchestra/canvas": "^7.0"
"orchestra/canvas": "^7.0",
"phpstan/phpstan": "^1.8"
},
"extra": {
"branch-alias": {
Expand Down
2 changes: 2 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
ignoreErrors: []
16 changes: 16 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
includes:
# - ./phpstan-baseline.neon

parameters:
paths:
- src

# The level 8 is the highest level
level: 6

ignoreErrors:
- '#Unsafe usage of new static#'

checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
treatPhpDocTypesAsCertain: false
4 changes: 2 additions & 2 deletions src/Concerns/CanServeSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trait CanServeSite
/**
* The server implementation.
*
* @var \Orchestra\Testbench\Dusk\DuskServer
* @var \Orchestra\Testbench\Dusk\DuskServer|null
*/
protected static $server;

Expand Down Expand Up @@ -81,7 +81,7 @@ public static function reloadServing(): void
/**
* Make tweaks to the application, both inside the test and on the test server.
*
* @param \Closure(\Illuminate\Foundation\Application):void $closure
* @param \Closure(\Illuminate\Foundation\Application, \Illuminate\Contracts\Config\Repository):void $closure
* @return void
*/
public function beforeServingApplication(Closure $closure): void
Expand Down
5 changes: 3 additions & 2 deletions src/DuskServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DuskServer
/**
* Process pointer reference.
*
* @var Process
* @var \Symfony\Component\Process\Process|null
*/
protected $process;

Expand Down Expand Up @@ -157,6 +157,8 @@ protected function startServer(): void
* that we want to use. Sometimes a server can be left oped when
* PHP drops out, or the user may have another service running.
*
* @return void
*
* @throws \Orchestra\Testbench\Dusk\Exceptions\UnableToStartServer
*/
protected function guardServerStarting()
Expand Down Expand Up @@ -196,7 +198,6 @@ protected function prepareCommand(): string
* For testbench purposes, this exists in the
* core package.
*
* @param string|null $root
* @return string
*/
public function laravelPublicPath(): string
Expand Down
7 changes: 7 additions & 0 deletions src/Exceptions/UnableToStartServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

class UnableToStartServer extends Exception
{
/**
* Create new "Unable to start server" exception.
*
* @param string $message
* @param int $code
* @param \Throwable|null $previous
*/
public function __construct($message = '', $code = 0, Throwable $previous = null)
{
$fullMessage = "A server is already running on {$message}. Please stop it before proceeding. \n".
Expand Down
24 changes: 14 additions & 10 deletions src/Foundation/Console/DuskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,17 @@ protected function phpunitArguments($options)
return ! Str::startsWith($option, '--env=');
}));

/** @phpstan-ignore-next-line */
$workingPath = TESTBENCH_WORKING_PATH;

$file = Collection::make([
'phpunit.dusk.xml',
'phpunit.dusk.xml.dist',
'phpunit.xml',
'phpunit.xml.dist',
])->map(static function ($file) {
return TESTBENCH_WORKING_PATH."/{$file}";
})->filter(static function ($file) {
return file_exists($file);
})->first();
])->map(fn ($file) => "{$workingPath}/{$file}")
->filter(fn ($file) => file_exists($file))
->first();

return ! \is_null($file) ? array_merge(['-c', $file], $options) : $options;
}
Expand All @@ -82,18 +83,20 @@ protected function phpunitArguments($options)
*/
protected function writeConfiguration()
{
/** @phpstan-ignore-next-line */
$workingPath = TESTBENCH_WORKING_PATH;

$file = Collection::make([
'phpunit.dusk.xml',
'phpunit.dusk.xml.dist',
'phpunit.xml',
'phpunit.xml.dist',
])->map(static function ($file) {
return TESTBENCH_WORKING_PATH."/{$file}";
})->filter(static function ($file) {
return file_exists($file);
})->first();
])->map(fn ($file) => "{$workingPath}/{$file}")
->filter(fn ($file) => file_exists($file))
->first();

if (\is_null($file)) {
/** @phpstan-ignore-next-line */
copy(realpath(__DIR__.'/../../../stubs/phpunit.xml'), TESTBENCH_WORKING_PATH.'/phpunit.dusk.xml');

return;
Expand All @@ -109,6 +112,7 @@ protected function writeConfiguration()
*/
protected function removeConfiguration()
{
/** @phpstan-ignore-next-line */
if (! $this->hasPhpUnitConfiguration && file_exists($file = TESTBENCH_WORKING_PATH.'/phpunit.dusk.xml')) {
@unlink($file);
}
Expand Down
1 change: 1 addition & 0 deletions src/Foundation/Console/PurgeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function handle()
*/
protected function purgeDebuggingFiles(string $relativePath, string $patterns): void
{
/** @phpstan-ignore-next-line */
$path = TESTBENCH_WORKING_PATH."/{$relativePath}";

if (! is_dir($path)) {
Expand Down
4 changes: 0 additions & 4 deletions src/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ public static function applicationBasePath()
/**
* Get Application's base URL.
*
* @var string
*
* @return string
*/
public static function applicationBaseUrl()
Expand Down Expand Up @@ -180,8 +178,6 @@ protected function driver(): RemoteWebDriver
/**
* Determine the application's base URL.
*
* @var string
*
* @return string
*/
protected function baseUrl()
Expand Down

0 comments on commit 03d6fa2

Please sign in to comment.