Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/pint-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Lint PHP code style issues

on:
pull_request:
paths:
- '**.php'

jobs:
lint-php-code-styling:
runs-on: ubuntu-latest

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

- name: Check PHP code style issues
uses: aglipanci/laravel-pint-action@1.0.0
with:
testMode: true
verboseMode: true
2 changes: 0 additions & 2 deletions .styleci.yml

This file was deleted.

1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"require-dev": {
"doctrine/dbal": "^3.3",
"laravel/pint": "^1.0",
"orchestra/testbench": "^7.0 || ^8.0",
"phpunit/phpunit": "^9.4"
},
Expand Down
10 changes: 5 additions & 5 deletions src/Assets/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ public function metaExists()
{
return Blink::once('eloquent-asset-meta-exists-'.$this->id(), function () {
return app('statamic.eloquent.assets.model')::query()
->where([
'container' => $this->containerHandle(),
'folder' => $this->folder(),
'basename' => $this->basename(),
])->count() > 0;
->where([
'container' => $this->containerHandle(),
'folder' => $this->folder(),
'basename' => $this->basename(),
])->count() > 0;
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Assets/AssetContainerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function findByHandle(string $handle): ?AssetContainerContract
});
}

public function make(string $handle = null): AssetContainerContract
public function make(?string $handle = null): AssetContainerContract
{
return app(AssetContainerContract::class)->handle($handle);
}
Expand Down
3 changes: 0 additions & 3 deletions src/Database/BaseMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ public function getConnection()

/**
* Prefixes table if defined.
*
* @param string $table
* @return string
*/
protected function prefix(string $table): string
{
Expand Down
4 changes: 2 additions & 2 deletions src/Entries/EntryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static function bindings(): array
{
return [
EntryContract::class => app('statamic.eloquent.entries.entry'),
QueryBuilder::class => EntryQueryBuilder::class,
QueryBuilder::class => EntryQueryBuilder::class,
];
}

Expand All @@ -33,7 +33,7 @@ public function find($id): ?EntryContract
return $this->substitutionsById[$item->id()] ?? $item;
}

public function findByUri(string $uri, string $site = null): ?EntryContract
public function findByUri(string $uri, ?string $site = null): ?EntryContract
{
$blinkKey = 'eloquent-entry-'.md5(urlencode($uri)).($site ? '-'.$site : '');
$item = Blink::once($blinkKey, function () use ($uri, $site) {
Expand Down
6 changes: 3 additions & 3 deletions src/Globals/GlobalVariablesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public function all(): VariablesCollection
{
return VariablesCollection::make(
VariablesModel::all()
->each(function ($model) {
return app(Variables::class)::fromModel($model);
})
->each(function ($model) {
return app(Variables::class)::fromModel($model);
})
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Taxonomies/TaxonomyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function findByHandle($handle): ?TaxonomyContract
return $taxonomyModel ? app(TaxonomyContract::class)->fromModel($taxonomyModel) : null;
}

public function findByUri(string $uri, string $site = null): ?Taxonomy
public function findByUri(string $uri, ?string $site = null): ?Taxonomy
{
$collection = Facades\Collection::all()
->first(function ($collection) use ($uri, $site) {
Expand Down
2 changes: 1 addition & 1 deletion src/Taxonomies/TermRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function find($id): ?TermContract
return $term;
}

public function findByUri(string $uri, string $site = null): ?TermContract
public function findByUri(string $uri, ?string $site = null): ?TermContract
{
$site = $site ?? $this->stache->sites()->first();

Expand Down
1 change: 0 additions & 1 deletion tests/ConsoleKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
Expand Down
2 changes: 1 addition & 1 deletion tests/Data/Entries/EntryQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ public function entries_can_be_retrieved_on_join_table_conditions()

foreach (range(4, 6) as $index) {
EntryFactory::id($index)->slug($locations[$index]['slug'])->collection('locations')
->data(['title' => $locations[$index]['title']])->create();
->data(['title' => $locations[$index]['title']])->create();
}

$query = Entry::query()
Expand Down
82 changes: 41 additions & 41 deletions tests/Repositories/TaxonomyRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,36 @@ public function setUp(): void
}

/** @test */
// public function it_gets_all_taxonomies()
// {
// $taxonomies = $this->repo->all();
//
// $this->assertInstanceOf(IlluminateCollection::class, $taxonomies);
// $this->assertCount(2, $taxonomies);
// $this->assertEveryItemIsInstanceOf(Taxonomy::class, $taxonomies);
//
// $ordered = $taxonomies->sortBy->handle()->values();
// $this->assertEquals(['categories', 'tags'], $ordered->map->handle()->all());
// $this->assertEquals(['Categories', 'Tags'], $ordered->map->title()->all());
// }
//
// /** @test */
// public function it_gets_a_taxonomy_by_handle()
// {
// tap($this->repo->findByHandle('categories'), function ($taxonomy) {
// $this->assertInstanceOf(Taxonomy::class, $taxonomy);
// $this->assertEquals('categories', $taxonomy->handle());
// $this->assertEquals('Categories', $taxonomy->title());
// });
//
// tap($this->repo->findByHandle('tags'), function ($taxonomy) {
// $this->assertInstanceOf(Taxonomy::class, $taxonomy);
// $this->assertEquals('tags', $taxonomy->handle());
// $this->assertEquals('Tags', $taxonomy->title());
// });
//
// $this->assertNull($this->repo->findByHandle('unknown'));
// }
// public function it_gets_all_taxonomies()
// {
// $taxonomies = $this->repo->all();
//
// $this->assertInstanceOf(IlluminateCollection::class, $taxonomies);
// $this->assertCount(2, $taxonomies);
// $this->assertEveryItemIsInstanceOf(Taxonomy::class, $taxonomies);
//
// $ordered = $taxonomies->sortBy->handle()->values();
// $this->assertEquals(['categories', 'tags'], $ordered->map->handle()->all());
// $this->assertEquals(['Categories', 'Tags'], $ordered->map->title()->all());
// }
//
// /** @test */
// public function it_gets_a_taxonomy_by_handle()
// {
// tap($this->repo->findByHandle('categories'), function ($taxonomy) {
// $this->assertInstanceOf(Taxonomy::class, $taxonomy);
// $this->assertEquals('categories', $taxonomy->handle());
// $this->assertEquals('Categories', $taxonomy->title());
// });
//
// tap($this->repo->findByHandle('tags'), function ($taxonomy) {
// $this->assertInstanceOf(Taxonomy::class, $taxonomy);
// $this->assertEquals('tags', $taxonomy->handle());
// $this->assertEquals('Tags', $taxonomy->title());
// });
//
// $this->assertNull($this->repo->findByHandle('unknown'));
// }

/** @test */
public function it_gets_a_taxonomy_by_uri()
Expand All @@ -90,15 +90,15 @@ public function it_gets_a_taxonomy_by_uri_with_collection()
}

/** @test */
// public function it_saves_a_taxonomy_to_the_stache_and_to_a_file()
// {
// $taxonomy = TaxonomyAPI::make('new');
// $taxonomy->cascade(['foo' => 'bar']);
// $this->assertNull($this->repo->findByHandle('new'));
//
// $this->repo->save($taxonomy);
//
// $this->assertNotNull($item = $this->repo->findByHandle('new'));
// $this->assertEquals(['foo' => 'bar'], $item->cascade()->all());
// }
// public function it_saves_a_taxonomy_to_the_stache_and_to_a_file()
// {
// $taxonomy = TaxonomyAPI::make('new');
// $taxonomy->cascade(['foo' => 'bar']);
// $this->assertNull($this->repo->findByHandle('new'));
//
// $this->repo->save($taxonomy);
//
// $this->assertNotNull($item = $this->repo->findByHandle('new'));
// $this->assertEquals(['foo' => 'bar'], $item->cascade()->all());
// }
}
10 changes: 5 additions & 5 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function resolveApplicationConfiguration($app)
];

foreach ($configs as $config) {
$app['config']->set("statamic.$config", require(__DIR__."/../config/{$config}.php"));
$app['config']->set("statamic.$config", require (__DIR__."/../config/{$config}.php"));
}
}

Expand All @@ -84,23 +84,23 @@ protected function getEnvironmentSetUp($app)
// We changed the default sites setup but the tests assume defaults like the following.
$app['config']->set('statamic.sites', [
'default' => 'en',
'sites' => [
'sites' => [
'en' => ['name' => 'English', 'locale' => 'en_US', 'url' => 'http://localhost/'],
],
]);
$app['config']->set('auth.providers.users.driver', 'statamic');
$app['config']->set('statamic.stache.watcher', false);
$app['config']->set('statamic.users.repository', 'file');
$app['config']->set('statamic.stache.stores.users', [
'class' => \Statamic\Stache\Stores\UsersStore::class,
'class' => \Statamic\Stache\Stores\UsersStore::class,
'directory' => __DIR__.'/__fixtures__/users',
]);

$app['config']->set('statamic.editions.pro', true);

$app['config']->set('cache.stores.outpost', [
'driver' => 'file',
'path' => storage_path('framework/cache/outpost-data'),
'path' => storage_path('framework/cache/outpost-data'),
]);
}

Expand Down Expand Up @@ -152,7 +152,7 @@ public static function assertArraySubset($subset, $array, bool $checkForObjectId
}

// This method is unavailable on earlier versions of Laravel.
public function partialMock($abstract, \Closure $mock = null)
public function partialMock($abstract, ?\Closure $mock = null)
{
$mock = \Mockery::mock(...array_filter(func_get_args()))->makePartial();
$this->app->instance($abstract, $mock);
Expand Down