Skip to content

Commit

Permalink
Merge branch '9.x' into 10.x
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>

# Conflicts:
#	composer.json
  • Loading branch information
crynobone committed Jan 7, 2025
2 parents f5795b4 + 1c7603f commit c2e49b0
Show file tree
Hide file tree
Showing 30 changed files with 457 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: crynobone
liberapay: # crynobone
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # ["https://paypal.me/crynobone"]
24 changes: 7 additions & 17 deletions .github/workflows/analyse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,15 @@ on:

jobs:
analyse:
runs-on: ${{ matrix.os }}
runs-on: "ubuntu-latest"
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
os:
- "ubuntu-latest"
php:
- 8.2
dependencies:
- "highest"
php: [8.3]
experimental:
- false

name: PHP${{ matrix.php }} PHPStan & Pint
name: PHP:${{ matrix.php }} Code Analysis

steps:
- name: Checkout code
Expand All @@ -36,23 +31,18 @@ jobs:
- name: Install dependencies
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"
dependency-versions: "highest"
composer-options: "--prefer-dist --no-cache"

- name: Execute Static Code Analysis
run: vendor/bin/phpstan analyse

lint:
runs-on: ${{ matrix.os }}
runs-on: "ubuntu-latest"
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
os:
- "ubuntu-latest"
php:
- 8.3
dependencies:
- "highest"
php: [8.3]
experimental:
- false

Expand All @@ -72,7 +62,7 @@ jobs:
- name: Install dependencies
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"
dependency-versions: "highest"
composer-options: "--prefer-dist --no-cache"

- name: PHP Lint
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/audits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ on:

jobs:
audit-dependencies:
runs-on: ${{ matrix.os }}
runs-on: "ubuntu-latest"
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
os:
- "ubuntu-latest"
php:
- 8.2
- 8.3
- 8.4
experimental:
- true

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

steps:
- name: Checkout code
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/coveralls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@ on:

jobs:
tests:
runs-on: ${{ matrix.os }}
runs-on: "ubuntu-latest"
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
os:
- "ubuntu-latest"
php:
- 8.2
dependencies:
- "highest"
php: [8.3]
experimental:
- false

name: PHP${{ matrix.php }} on ${{ matrix.os }} (${{ matrix.dependencies }})
name: PHP:${{ matrix.php }} Code Coverage

steps:
- name: Checkout code
Expand All @@ -35,7 +30,7 @@ jobs:
- name: Install dependencies
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"
dependency-versions: "highest"
composer-options: "--prefer-dist --no-cache"

- name: Execute tests
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ jobs:
php:
- 8.2
- 8.3
- 8.4
dependencies:
- "highest"
- "lowest"
experimental:
- false

name: PHP${{ matrix.php }} on ${{ matrix.os }} (${{ matrix.dependencies }})
name: PHP:${{ matrix.php }} / OS:${{ matrix.os }} ${{ matrix.dependencies == 'highest' && '⬆️' || '⬇️' }}

steps:
- name: Checkout code
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-stubs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, intl, fileinfo, :php-psr
coverage: none

Expand All @@ -32,7 +32,7 @@ jobs:
php bin/sync
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update Stubs

18 changes: 10 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
"illuminate/support": "^12.0",
"orchestra/canvas-core": "^10.0",
"orchestra/testbench-core": "^10.0",
"symfony/polyfill-php83": "^1.28",
"symfony/yaml": "^7.0"
"symfony/polyfill-php83": "^1.31",
"symfony/yaml": "^7.0.3"
},
"require-dev": {
"laravel/framework": "^12.0",
"laravel/pint": "^1.17",
"mockery/mockery": "^1.6",
"mockery/mockery": "^1.6.10",
"phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^11.0"
"phpunit/phpunit": "^11.5"
},
"config": {
"preferred-install": {
Expand All @@ -55,9 +55,6 @@
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "9.0-dev"
},
"laravel": {
"providers": [
"Orchestra\\Canvas\\LaravelServiceProvider"
Expand All @@ -75,7 +72,12 @@
"@php vendor/bin/pint",
"@php vendor/bin/phpstan analyse --verbose"
],
"test": "@php vendor/bin/phpunit -c ./ --color",
"test": [
"@composer dump-autoload",
"@php vendor/bin/phpunit --no-coverage --no-configuration --bootstrap vendor/autoload.php --color tests",
"@php vendor/bin/phpunit --no-coverage --no-configuration --bootstrap vendor/autoload.php --color workbench/tests"
],
"sync": "@php bin/sync",
"ci": [
"@composer audit",
"@prepare",
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ parameters:
level: 8

ignoreErrors:
# - identifier: missingType.generics
- identifier: missingType.iterableValue

treatPhpDocTypesAsCertain: false
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
processIsolation="false"
stopOnFailure="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false">
<coverage includeUncoveredFiles="false" />
<coverage />
<testsuites>
<testsuite name="Canvas Test Suite">
<directory suffix="Test.php">tests/Feature/</directory>
Expand Down
6 changes: 3 additions & 3 deletions src/CanvasServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public function register(): void
$manager->setDefaultDriver('canvas');
});

$this->app->singleton('orchestra.canvas', function (Application $app) {
$workingPath = \defined('CANVAS_WORKING_PATH') ? CANVAS_WORKING_PATH : $this->app->basePath();
$this->app->singleton('orchestra.canvas', static function (Application $app) {
$workingPath = \defined('CANVAS_WORKING_PATH') ? CANVAS_WORKING_PATH : $app->basePath();

$filesystem = $app->make('files');

Expand All @@ -39,7 +39,7 @@ public function register(): void
'feature' => 'Tests\TestCase',
]);

$config['namespace'] = rescue(fn () => rtrim($this->app->getNamespace(), '\\'), null, false);
$config['namespace'] = rescue(fn () => rtrim($app->getNamespace(), '\\'), null, false);
}

return Canvas::preset($config, $workingPath);
Expand Down
33 changes: 15 additions & 18 deletions src/Console/Commander.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,29 @@
use Illuminate\Contracts\Console\Kernel as ConsoleKernel;
use Illuminate\Foundation\Application as LaravelApplication;
use Illuminate\Support\Collection;
use Orchestra\Canvas\CanvasServiceProvider;
use Orchestra\Canvas\Core\Concerns\CreatesUsingGeneratorPreset;
use Orchestra\Canvas\LaravelServiceProvider;
use Symfony\Component\Console\Command\Command as SymfonyCommand;

class Commander extends \Orchestra\Testbench\Console\Commander
{
/**
* The environment file name.
*/
/** {@inheritDoc} */
protected string $environmentFile = '.env';

/**
* List of providers.
*
* @var array<int, class-string<\Illuminate\Support\ServiceProvider>>
*/
protected array $providers = [
\Orchestra\Canvas\Core\LaravelServiceProvider::class,
\Orchestra\Canvas\CanvasServiceProvider::class,
];

/**
* Create Laravel application.
*
* @return \Illuminate\Foundation\Application
*/
/** {@inheritDoc} */
protected array $providers = [];

/** {@inheritDoc} */
#[\Override]
protected function resolveApplicationCallback()
{
return static function ($app) {
$app->register(CanvasServiceProvider::class);
};
}

/** {@inheritDoc} */
#[\Override]
public function laravel()
{
Expand Down
69 changes: 69 additions & 0 deletions src/Console/JobMiddlewareMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace Orchestra\Canvas\Console;

use Orchestra\Canvas\Core\Concerns\CodeGenerator;
use Orchestra\Canvas\Core\Concerns\TestGenerator;
use Orchestra\Canvas\Core\Concerns\UsesGeneratorOverrides;
use Symfony\Component\Console\Attribute\AsCommand;

/**
* @see https://github.com/laravel/framework/blob/11.x/src/Illuminate/Foundation/Console/JobMiddlewareMakeCommand.php
*/
#[AsCommand(name: 'make:job-middleware', description: 'Create a new job middleware class')]
class JobMiddlewareMakeCommand extends \Illuminate\Foundation\Console\JobMiddlewareMakeCommand
{
use CodeGenerator;
use TestGenerator;
use UsesGeneratorOverrides;

/**
* Configures the current command.
*
* @return void
*/
#[\Override]
protected function configure()
{
parent::configure();

$this->addGeneratorPresetOptions();
}

/**
* Execute the console command.
*
* @return bool|null
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
#[\Override]
public function handle()
{
/** @phpstan-ignore return.type */
return $this->generateCode() ? self::SUCCESS : self::FAILURE;
}

/**
* Get the destination class path.
*
* @param string $name
* @return string
*/
#[\Override]
protected function getPath($name)
{
return $this->getPathUsingCanvas($name);
}

/**
* Get the root namespace for the class.
*
* @return string
*/
#[\Override]
protected function rootNamespace()
{
return $this->rootNamespaceUsingCanvas();
}
}
6 changes: 5 additions & 1 deletion src/Console/MailMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ public function handle()
*/
public function afterCodeHasBeenGenerated(string $className, string $path): void
{
if ($this->option('markdown')) {
if ($this->option('markdown') !== false) {
$this->writeMarkdownTemplate();
}

if ($this->option('view') !== false) {
$this->writeView();
}
}

/**
Expand Down
Loading

0 comments on commit c2e49b0

Please sign in to comment.