Skip to content

Commit

Permalink
make more classes final or abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmajor committed May 28, 2021
1 parent e461044 commit b8d4a46
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 76 deletions.
34 changes: 17 additions & 17 deletions src/Bundle/FluentBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@
use Major\Fluent\PluralRules\PluralRules;
use Stringable;

class FluentBundle
final class FluentBundle
{
/** Unicode BiDi isolation characters. */
public const FSI = "\u{2068}";

public const PDI = "\u{2069}";

/** @var array<string, Message> */
private array $messages = [];
protected array $messages = [];

/** @var array<string, Term> */
private array $terms = [];
protected array $terms = [];

/** @var ResolverException[] */
private array $errors = [];
protected array $errors = [];

public function __construct(
protected string $locale,
Expand Down Expand Up @@ -102,7 +102,7 @@ public function hasTerm(string $id): bool
return array_key_exists($id, $this->terms);
}

private function reportError(ResolverException $error): void
protected function reportError(ResolverException $error): void
{
$this->errors[] = $this->strict ? throw $error : $error;
}
Expand Down Expand Up @@ -148,7 +148,7 @@ public function message(string $_message, mixed ...$arguments): ?string
return null;
}

private function resolvePattern(
protected function resolvePattern(
?Pattern $pattern,
ResolutionScope $scope,
): string {
Expand Down Expand Up @@ -191,7 +191,7 @@ private function resolvePattern(
return $result;
}

private function resolvePlaceable(
protected function resolvePlaceable(
Placeable $element,
ResolutionScope $scope,
): string|Stringable {
Expand All @@ -200,7 +200,7 @@ private function resolvePlaceable(
: $this->resolveExpression($element->expression, $scope);
}

private function resolveExpression(
protected function resolveExpression(
Expression $expression,
ResolutionScope $scope,
): string|Stringable {
Expand All @@ -209,14 +209,14 @@ private function resolveExpression(
return $this->{$method}($expression, $scope);
}

private function resolveStringLiteral(
protected function resolveStringLiteral(
StringLiteral $literal,
ResolutionScope $scope,
): string {
return $literal->parse()->value;
}

private function resolveNumberLiteral(
protected function resolveNumberLiteral(
NumberLiteral $literal,
ResolutionScope $scope,
): FluentNumber {
Expand All @@ -226,7 +226,7 @@ private function resolveNumberLiteral(
->setFluentLocale($this->locale);
}

private function resolveVariableReference(
protected function resolveVariableReference(
VariableReference $reference,
ResolutionScope $scope,
): string|Stringable {
Expand Down Expand Up @@ -268,7 +268,7 @@ private function resolveVariableReference(
return new FluentNone("\${$id}");
}

private function resolveMessageReference(
protected function resolveMessageReference(
MessageReference $reference,
ResolutionScope $scope,
): string|Stringable {
Expand Down Expand Up @@ -307,7 +307,7 @@ private function resolveMessageReference(
return new FluentNone($id);
}

private function resolveTermReference(
protected function resolveTermReference(
TermReference $reference,
ResolutionScope $scope,
): string|Stringable {
Expand Down Expand Up @@ -353,14 +353,14 @@ private function resolveTermReference(
return $resolved;
}

private function resolveFunctionReference(
protected function resolveFunctionReference(
FunctionReference $reference,
ResolutionScope $scope,
): string|Stringable {
throw new Exception('Functions are not implemented yet.');
}

private function resolveSelectExpression(
protected function resolveSelectExpression(
SelectExpression $expression,
ResolutionScope $scope,
): string {
Expand Down Expand Up @@ -388,7 +388,7 @@ private function resolveSelectExpression(
/**
* @param Variant[] $variants
*/
private function getDefaultVariant(
protected function getDefaultVariant(
array $variants,
ResolutionScope $scope,
): string {
Expand All @@ -401,7 +401,7 @@ private function getDefaultVariant(
throw new ShouldNotHappen(); // @codeCoverageIgnore
}

private function matchVariant(
protected function matchVariant(
string|Stringable|FluentNumber $selector,
string|Stringable|FluentNumber $key,
): bool {
Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/ResolutionScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* @internal
*/
class ResolutionScope
final class ResolutionScope
{
/** @var WeakMap<Pattern, true> */
public WeakMap $dirty;
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/Bundle/MessageExistsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Major\Fluent\Exceptions\Bundle;

class MessageExistsException extends EntryExistsException
final class MessageExistsException extends EntryExistsException
{
public function __construct(string $id)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/Bundle/TermExistsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Major\Fluent\Exceptions\Bundle;

class TermExistsException extends EntryExistsException
final class TermExistsException extends EntryExistsException
{
public function __construct(string $id)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ParserException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Exception;

class ParserException extends Exception
final class ParserException extends Exception
{
public function __construct(
protected string $fluentErrorCode = 'E0001',
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/Resolver/NullPatternException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Major\Fluent\Exceptions\Resolver;

class NullPatternException extends ResolverException
final class NullPatternException extends ResolverException
{
public function __construct()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Node/Syntax/Expressions/Literals/StringLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
final class StringLiteral extends Literal
{
// backslash backslash, backslash double quote, uHHHH, UHHHHHH
private const KNOWN_ESCAPES = '/(?:\\\\\\\\|\\\\"|\\\\[u]([0-9a-fA-F]{4})|\\\\[U]([0-9a-fA-F]{6}))/';
protected const KNOWN_ESCAPES = '/(?:\\\\\\\\|\\\\"|\\\\[u]([0-9a-fA-F]{4})|\\\\[U]([0-9a-fA-F]{6}))/';

public function parse(): StringLiteralValue
{
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Cursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* @internal
*/
class Cursor
abstract class Cursor
{
protected int $index = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/Parser/FluentCursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @internal
*/
class FluentCursor extends Cursor
final class FluentCursor extends Cursor
{
public function isIdentifierStart(): bool
{
Expand Down

0 comments on commit b8d4a46

Please sign in to comment.