Skip to content

Commit

Permalink
Apply fixes from StyleCI (#1511)
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Jan 10, 2024
1 parent f79d336 commit 9c0a941
Show file tree
Hide file tree
Showing 25 changed files with 122 additions and 122 deletions.
Expand Up @@ -33,17 +33,17 @@ class PublishHomepageCommand extends Command

/** @var array<string, array{name: string, description: string, group: string}> */
protected array $options = [
'welcome'=> [
'welcome' => [
'name' => 'Welcome',
'description' => 'The default welcome page.',
'group' => 'hyde-welcome-page',
],
'posts'=> [
'posts' => [
'name' => 'Posts Feed',
'description' => 'A feed of your latest posts. Perfect for a blog site!',
'group' => 'hyde-posts-page',
],
'blank'=> [
'blank' => [
'name' => 'Blank Starter',
'description' => 'A blank Blade template with just the base layout.',
'group' => 'hyde-blank-page',
Expand Down
Expand Up @@ -13,11 +13,11 @@
interface BlogPostSchema extends PageSchema
{
public const BLOG_POST_SCHEMA = [
'title' => 'string',
'description' => 'string',
'category' => 'string',
'date' => 'string',
'author' => ['string', AuthorSchema::AUTHOR_SCHEMA],
'image' => ['string', FeaturedImageSchema::FEATURED_IMAGE_SCHEMA],
'title' => 'string',
'description' => 'string',
'category' => 'string',
'date' => 'string',
'author' => ['string', AuthorSchema::AUTHOR_SCHEMA],
'image' => ['string', FeaturedImageSchema::FEATURED_IMAGE_SCHEMA],
];
}
Expand Up @@ -12,8 +12,8 @@
interface PageSchema extends FrontMatterSchema
{
public const PAGE_SCHEMA = [
'title' => 'string',
'canonicalUrl' => 'string', // While not present in the page data, it is supported as a front matter key for the accessor data source.
'navigation' => NavigationSchema::NAVIGATION_SCHEMA,
'title' => 'string',
'canonicalUrl' => 'string', // While not present in the page data, it is supported as a front matter key for the accessor data source.
'navigation' => NavigationSchema::NAVIGATION_SCHEMA,
];
}
Expand Up @@ -12,8 +12,8 @@
interface AuthorSchema extends BlogPostSchema
{
public const AUTHOR_SCHEMA = [
'name' => 'string',
'username' => 'string',
'website' => 'string',
'name' => 'string',
'username' => 'string',
'website' => 'string',
];
}
Expand Up @@ -13,13 +13,13 @@
interface FeaturedImageSchema extends BlogPostSchema
{
public const FEATURED_IMAGE_SCHEMA = [
'source' => 'string', // Name of a file in _media/ or a remote URL (required)
'altText' => 'string', // The alt text (important for accessibility) // todo: Support alt, description
'titleText' => 'string', // The title text (hover tooltip & metadata) // todo: Support title, caption
'licenseName' => 'string', // The name of the license (e.g. "CC BY 4.0")
'licenseUrl' => 'string', // The URL of the license (e.g. "https://creativecommons.org/licenses/by/4.0/")
'authorName' => 'string', // The name of the author/photographer of the image (e.g. "John Doe", Wikimedia Commons)
'authorUrl' => 'string', // The URL of the author/photographer of the image (e.g. "https://commons.wikimedia.org/wiki/User:John_Doe", Wikimedia Commons)
'copyright' => 'string', // The copyright text (e.g. "© 2023 John Doe")
'source' => 'string', // Name of a file in _media/ or a remote URL (required)
'altText' => 'string', // The alt text (important for accessibility) // todo: Support alt, description
'titleText' => 'string', // The title text (hover tooltip & metadata) // todo: Support title, caption
'licenseName' => 'string', // The name of the license (e.g. "CC BY 4.0")
'licenseUrl' => 'string', // The URL of the license (e.g. "https://creativecommons.org/licenses/by/4.0/")
'authorName' => 'string', // The name of the author/photographer of the image (e.g. "John Doe", Wikimedia Commons)
'authorUrl' => 'string', // The URL of the author/photographer of the image (e.g. "https://commons.wikimedia.org/wiki/User:John_Doe", Wikimedia Commons)
'copyright' => 'string', // The copyright text (e.g. "© 2023 John Doe")
];
}
Expand Up @@ -13,9 +13,9 @@
interface NavigationSchema extends PageSchema
{
public const NAVIGATION_SCHEMA = [
'label' => 'string', // The text to display
'priority' => 'int', // Order is also supported
'hidden' => 'bool', // Visible is also supported (but obviously invert the value)
'group' => 'string', // Category is also supported
'label' => 'string', // The text to display
'priority' => 'int', // Order is also supported
'hidden' => 'bool', // Visible is also supported (but obviously invert the value)
'group' => 'string', // Category is also supported
];
}
18 changes: 9 additions & 9 deletions packages/framework/src/Support/Filesystem/MediaFile.php
Expand Up @@ -70,18 +70,18 @@ public function getMimeType(): string
// See if we can find a mime type for the extension instead of
// having to rely on a PHP extension and filesystem lookups.
$lookup = [
'txt' => 'text/plain',
'md' => 'text/markdown',
'txt' => 'text/plain',
'md' => 'text/markdown',
'html' => 'text/html',
'css' => 'text/css',
'svg' => 'image/svg+xml',
'png' => 'image/png',
'jpg' => 'image/jpeg',
'css' => 'text/css',
'svg' => 'image/svg+xml',
'png' => 'image/png',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'gif' => 'image/gif',
'gif' => 'image/gif',
'json' => 'application/json',
'js' => 'application/javascript',
'xml' => 'application/xml',
'js' => 'application/javascript',
'xml' => 'application/xml',
];

if (isset($lookup[$extension])) {
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/src/Support/Models/RouteListItem.php
Expand Up @@ -28,10 +28,10 @@ public function __construct(Route $route)
public function toArray(): array
{
return [
'page_type' => $this->stylePageType($this->route->getPageClass()),
'page_type' => $this->stylePageType($this->route->getPageClass()),
'source_file' => $this->styleSourcePath($this->route->getSourcePath()),
'output_file' => $this->styleOutputPath($this->route->getOutputPath()),
'route_key' => $this->styleRouteKey($this->route->getRouteKey()),
'route_key' => $this->styleRouteKey($this->route->getRouteKey()),
];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/framework/tests/Feature/MarkdownServiceTest.php
Expand Up @@ -93,7 +93,7 @@ public function test_raw_html_tags_are_stripped_by_default()

public function test_raw_html_tags_are_not_stripped_when_explicitly_enabled()
{
config(['markdown.allow_html' =>true]);
config(['markdown.allow_html' => true]);
$markdown = '<p>foo</p><style>bar</style><script>hat</script>';
$service = new MarkdownService($markdown);
$html = $service->parse();
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/tests/Feature/Support/MediaFileTest.php
Expand Up @@ -75,8 +75,8 @@ public function test_to_array_returns_array_of_file_properties()
$this->file('foo.txt', 'foo bar');

$this->assertSame([
'name' => 'foo.txt',
'path' => 'foo.txt',
'name' => 'foo.txt',
'path' => 'foo.txt',
'length' => 7,
'mimeType' => 'text/plain',
], MediaFile::make('foo.txt')->toArray());
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/tests/Feature/Support/ProjectFileTest.php
Expand Up @@ -74,8 +74,8 @@ public function test_to_array_returns_array_of_file_properties()
$this->file('foo.txt', 'foo bar');

$this->assertSame([
'name' => 'foo.txt',
'path' => 'foo.txt',
'name' => 'foo.txt',
'path' => 'foo.txt',
], ProjectFileTestClass::make('foo.txt')->toArray());
}

Expand Down
4 changes: 2 additions & 2 deletions packages/framework/tests/Feature/Support/SourceFileTest.php
Expand Up @@ -93,8 +93,8 @@ public function test_to_array_returns_array_of_file_properties()
$this->file('foo.txt', 'foo bar');

$this->assertSame([
'name' => 'foo.txt',
'path' => 'foo.txt',
'name' => 'foo.txt',
'path' => 'foo.txt',
'pageClass' => HydePage::class,
], SourceFile::make('foo.txt')->toArray());
}
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/tests/Unit/BreadcrumbsComponentTest.php
Expand Up @@ -47,7 +47,7 @@ public function testCanRender()
$view = Mockery::mock(\Illuminate\View\View::class);
$mock = Mockery::mock(Factory::class);
$mock->shouldReceive('make')->once()->with('hyde::components.breadcrumbs')->andReturn($view);
app()->singleton('view', fn () =>$mock);
app()->singleton('view', fn () => $mock);
View::swap($mock);

$this->assertSame($view, (new BreadcrumbsComponent())->render());
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/tests/Unit/Pages/BaseHydePageUnitTest.php
Expand Up @@ -37,8 +37,8 @@ protected function setUp(): void
]),
'share' => null,
]));
app()->bind(\Illuminate\Contracts\View\Factory::class, fn () =>$mock);
app()->bind('view', fn () =>$mock);
app()->bind(\Illuminate\Contracts\View\Factory::class, fn () => $mock);
app()->bind('view', fn () => $mock);

Render::swap(new RenderData());
}
Expand Down
48 changes: 24 additions & 24 deletions packages/framework/tests/Unit/SchemaContractsTest.php
Expand Up @@ -45,42 +45,42 @@ class SchemaContractsTest extends UnitTestCase
public function testSchemasAreNotAccidentallyChanged()
{
$this->assertSame([
'title' => 'string',
'canonicalUrl' => 'string',
'navigation' => NavigationSchema::NAVIGATION_SCHEMA,
'title' => 'string',
'canonicalUrl' => 'string',
'navigation' => NavigationSchema::NAVIGATION_SCHEMA,
], PageSchema::PAGE_SCHEMA);

$this->assertSame([
'label' => 'string',
'priority' => 'int',
'hidden' => 'bool',
'group' => 'string',
'label' => 'string',
'priority' => 'int',
'hidden' => 'bool',
'group' => 'string',
], NavigationSchema::NAVIGATION_SCHEMA);

$this->assertSame([
'title' => 'string',
'description' => 'string',
'category' => 'string',
'date' => 'string',
'author' => ['string', AuthorSchema::AUTHOR_SCHEMA],
'image' => ['string', FeaturedImageSchema::FEATURED_IMAGE_SCHEMA],
'title' => 'string',
'description' => 'string',
'category' => 'string',
'date' => 'string',
'author' => ['string', AuthorSchema::AUTHOR_SCHEMA],
'image' => ['string', FeaturedImageSchema::FEATURED_IMAGE_SCHEMA],
], BlogPostSchema::BLOG_POST_SCHEMA);

$this->assertSame([
'name' => 'string',
'username' => 'string',
'website' => 'string',
'name' => 'string',
'username' => 'string',
'website' => 'string',
], AuthorSchema::AUTHOR_SCHEMA);

$this->assertSame([
'source' => 'string',
'altText' => 'string',
'titleText' => 'string',
'licenseName' => 'string',
'licenseUrl' => 'string',
'authorName' => 'string',
'authorUrl' => 'string',
'copyright' => 'string',
'source' => 'string',
'altText' => 'string',
'titleText' => 'string',
'licenseName' => 'string',
'licenseUrl' => 'string',
'authorName' => 'string',
'authorUrl' => 'string',
'copyright' => 'string',
], FeaturedImageSchema::FEATURED_IMAGE_SCHEMA);
}

Expand Down
Expand Up @@ -266,7 +266,7 @@ protected function stripWhitespace(string $string): string
return str_replace([' ', "\r", "\n"], '', $string);
}

protected function renderComponent(FeaturedImage|array $data = ['image.source'=>'foo']): string
protected function renderComponent(FeaturedImage|array $data = ['image.source' => 'foo']): string
{
$image = $data instanceof FeaturedImage ? $data : $this->make($data);

Expand Down
Expand Up @@ -105,9 +105,9 @@ protected function getAllRelatedPages(Collection $publicationPages, Collection $
if ($matchedTagCount) {
$allRelatedPages->add(
collect([
'count' => $matchedTagCount,
'count' => $matchedTagCount,
'identifier' => $publicationPage->identifier,
'page' => $publicationPage,
'page' => $publicationPage,
])
);
}
Expand Down
Expand Up @@ -203,7 +203,7 @@ public function testItCreatesValidYaml()
'__createdAt' => 1640995200,
'title' => 'Hello World',
'description' => "This is a description.\nIt can be multiple lines.\n",
'tags' => ['tag1', 'tag2', 'foo bar'],
'tags' => ['tag1', 'tag2', 'foo bar'],
], Yaml::parse(Str::between($contents, '---', '---')));
}

Expand Down

0 comments on commit 9c0a941

Please sign in to comment.