Skip to content

Tweak the feature that links to Symfony repository URLs #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2022
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
6 changes: 3 additions & 3 deletions src/BuildConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class BuildConfig
{
private const PHP_DOC_URL = 'https://secure.php.net/manual/en';
private const GITHUB_URL = 'https://github.com/symfony/symfony/blob/{symfonyVersion}/src';
private const SYMFONY_REPOSITORY_URL = 'https://github.com/symfony/symfony/blob/{symfonyVersion}/src';
private const SYMFONY_DOC_URL = 'https://symfony.com/doc/{symfonyVersion}';

private $useBuildCache;
Expand Down Expand Up @@ -78,9 +78,9 @@ public function getPhpDocUrl(): string
return self::PHP_DOC_URL;
}

public function getGithubUrl(): string
public function getSymfonyRepositoryUrl(): string
{
return str_replace('{symfonyVersion}', $this->getSymfonyVersion(), self::GITHUB_URL);
return str_replace('{symfonyVersion}', $this->getSymfonyVersion(), self::SYMFONY_REPOSITORY_URL);
}

public function getSymfonyDocUrl(): string
Expand Down
6 changes: 3 additions & 3 deletions src/KernelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ private static function getDirectives(): array
private static function getReferences(BuildConfig $buildConfig): array
{
return [
new SymfonyReferences\ClassReference($buildConfig->getGithubUrl()),
new SymfonyReferences\MethodReference($buildConfig->getGithubUrl()),
new SymfonyReferences\NamespaceReference($buildConfig->getGithubUrl()),
new SymfonyReferences\ClassReference($buildConfig->getSymfonyRepositoryUrl()),
new SymfonyReferences\MethodReference($buildConfig->getSymfonyRepositoryUrl()),
new SymfonyReferences\NamespaceReference($buildConfig->getSymfonyRepositoryUrl()),
new SymfonyReferences\PhpFunctionReference($buildConfig->getPhpDocUrl()),
new SymfonyReferences\PhpMethodReference($buildConfig->getPhpDocUrl()),
new SymfonyReferences\PhpClassReference($buildConfig->getPhpDocUrl()),
Expand Down
8 changes: 4 additions & 4 deletions src/Reference/ClassReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

class ClassReference extends Reference
{
private $githubUrl;
private $symfonyRepositoryUrl;

public function __construct(string $githubUrl)
public function __construct(string $symfonyRepositoryUrl)
{
$this->githubUrl = $githubUrl;
$this->symfonyRepositoryUrl = $symfonyRepositoryUrl;
}

public function getName(): string
Expand All @@ -35,7 +35,7 @@ public function resolve(Environment $environment, string $data): ResolvedReferen
return new ResolvedReference(
$environment->getCurrentFileName(),
$className->afterLast('\\'),
sprintf('%s/%s.php', $this->githubUrl, $className->replace('\\', '/')),
sprintf('%s/%s.php', $this->symfonyRepositoryUrl, $className->replace('\\', '/')),
[],
[
'title' => $className,
Expand Down
8 changes: 4 additions & 4 deletions src/Reference/MethodReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

class MethodReference extends Reference
{
private $githubUrl;
private $symfonyRepositoryUrl;

public function __construct(string $githubUrl)
public function __construct(string $symfonyRepositoryUrl)
{
$this->githubUrl = $githubUrl;
$this->symfonyRepositoryUrl = $symfonyRepositoryUrl;
}

public function getName(): string
Expand All @@ -42,7 +42,7 @@ public function resolve(Environment $environment, string $data): ResolvedReferen
return new ResolvedReference(
$environment->getCurrentFileName(),
$methodName.'()',
sprintf('%s/%s.php#method_%s', $this->githubUrl, str_replace('\\', '/', $className), $methodName),
sprintf('%s/%s.php#method_%s', $this->symfonyRepositoryUrl, str_replace('\\', '/', $className), $methodName),
[],
[
'title' => sprintf('%s::%s()', $className, $methodName),
Expand Down
8 changes: 4 additions & 4 deletions src/Reference/NamespaceReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

class NamespaceReference extends Reference
{
private $githubUrl;
private $symfonyRepositoryUrl;

public function __construct(string $githubUrl)
public function __construct(string $symfonyRepositoryUrl)
{
$this->githubUrl = $githubUrl;
$this->symfonyRepositoryUrl = $symfonyRepositoryUrl;
}

public function getName(): string
Expand All @@ -35,7 +35,7 @@ public function resolve(Environment $environment, string $data): ResolvedReferen
return new ResolvedReference(
$environment->getCurrentFileName(),
$className->afterLast('\\'),
sprintf('%s/%s', $this->githubUrl, $className->replace('\\', '/')),
sprintf('%s/%s', $this->symfonyRepositoryUrl, $className->replace('\\', '/')),
[],
[
'title' => $className,
Expand Down