Skip to content

Commit

Permalink
Fix code style and bump to php 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapio committed Mar 12, 2024
1 parent 1c6b546 commit c6d49fc
Show file tree
Hide file tree
Showing 36 changed files with 181 additions and 137 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
],
"require": {
"php": "^7.2 || ^8.0",
"php": "^7.4 || ^8.0",
"phpdocumentor/type-resolver": "^1.7",
"webmozart/assert": "^1.9.1",
"phpdocumentor/reflection-common": "^2.2",
Expand Down
73 changes: 59 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/04-adding-your-own-tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final class MyTag extends BaseTag
*
* @var string
*/
protected $name = 'my-tag';
protected string $name = 'my-tag';

/**
* The constructor for this Tag; this should contain all properties for this object.
Expand Down
14 changes: 7 additions & 7 deletions src/DocBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@
final class DocBlock
{
/** @var string The opening line for this docblock. */
private $summary;
private string $summary;

/** @var DocBlock\Description The actual description for this docblock. */
private $description;
private DocBlock\Description $description;

/** @var Tag[] An array containing all the tags in this docblock; except inline. */
private $tags = [];
private array $tags = [];

/** @var Types\Context|null Information about the context of this DocBlock. */
private $context;
private ?Types\Context $context = null;

/** @var Location|null Information about the location of this DocBlock. */
private $location;
private ?Location $location = null;

/** @var bool Is this DocBlock (the start of) a template? */
private $isTemplateStart;
private bool $isTemplateStart;

/** @var bool Does this DocBlock signify the end of a DocBlock template? */
private $isTemplateEnd;
private bool $isTemplateEnd;

/**
* @param DocBlock\Tag[] $tags
Expand Down
5 changes: 2 additions & 3 deletions src/DocBlock/Description.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@
*/
class Description
{
/** @var string */
private $bodyTemplate;
private string $bodyTemplate;

/** @var Tag[] */
private $tags;
private array $tags;

/**
* Initializes a Description with its body (template) and a listing of the tags used in the body template.
Expand Down
3 changes: 1 addition & 2 deletions src/DocBlock/DescriptionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
*/
class DescriptionFactory
{
/** @var Factory */
private $tagFactory;
private Factory $tagFactory;

/**
* Initializes this factory with the means to construct (inline) tags.
Expand Down
5 changes: 2 additions & 3 deletions src/DocBlock/ExampleFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
*/
class ExampleFinder
{
/** @var string */
private $sourceDirectory = '';
private string $sourceDirectory = '';

/** @var string[] */
private $exampleDirectories = [];
private array $exampleDirectories = [];

/**
* Attempts to find the example contents for the given descriptor.
Expand Down
13 changes: 6 additions & 7 deletions src/DocBlock/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,20 @@
class Serializer
{
/** @var string The string to indent the comment with. */
protected $indentString = ' ';
protected string $indentString = ' ';

/** @var int The number of times the indent string is repeated. */
protected $indent = 0;
protected int $indent = 0;

/** @var bool Whether to indent the first line with the given indent amount and string. */
protected $isFirstLineIndented = true;
protected bool $isFirstLineIndented = true;

/** @var int|null The max length of a line. */
protected $lineLength;
protected ?int $lineLength = null;

/** @var Formatter A custom tag formatter. */
protected $tagFormatter;
/** @var string */
private $lineEnding;
protected Formatter $tagFormatter;
private string $lineEnding;

/**
* Create a Serializer instance.
Expand Down
11 changes: 5 additions & 6 deletions src/DocBlock/StandardTagFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ final class StandardTagFactory implements TagFactory
* @var array<class-string<Tag>|Factory> An array with a tag as a key, and an
* FQCN to a class that handles it as an array value.
*/
private $tagHandlerMappings = [
private array $tagHandlerMappings = [
'author' => Author::class,
'covers' => Covers::class,
'deprecated' => Deprecated::class,
Expand All @@ -105,22 +105,21 @@ final class StandardTagFactory implements TagFactory
* @var array<class-string<Tag>> An array with a anotation s a key, and an
* FQCN to a class that handles it as an array value.
*/
private $annotationMappings = [];
private array $annotationMappings = [];

/**
* @var ReflectionParameter[][] a lazy-loading cache containing parameters
* for each tagHandler that has been used.
*/
private $tagHandlerParameterCache = [];
private array $tagHandlerParameterCache = [];

/** @var FqsenResolver */
private $fqsenResolver;
private FqsenResolver $fqsenResolver;

/**
* @var mixed[] an array representing a simple Service Locator where we can store parameters and
* services that can be inserted into the Factory Methods of Tag Handlers.
*/
private $serviceLocator = [];
private array $serviceLocator = [];

/**
* Initialize this tag factory with the means to resolve an FQSEN and optionally a list of tag handlers.
Expand Down
6 changes: 3 additions & 3 deletions src/DocBlock/Tags/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
final class Author extends BaseTag implements Factory\StaticMethod
{
/** @var string register that this is the author tag. */
protected $name = 'author';
protected string $name = 'author';

/** @var string The name of the author */
private $authorName;
private string $authorName;

/** @var string The email of the author */
private $authorEmail;
private string $authorEmail;

/**
* Initializes this tag with the author name and e-mail.
Expand Down
4 changes: 2 additions & 2 deletions src/DocBlock/Tags/BaseTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
abstract class BaseTag implements DocBlock\Tag
{
/** @var string Name of the tag */
protected $name = '';
protected string $name = '';

/** @var Description|null Description of the tag. */
protected $description;
protected ?Description $description = null;

/**
* Gets the name of this tag.
Expand Down
6 changes: 2 additions & 4 deletions src/DocBlock/Tags/Covers.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@
*/
final class Covers extends BaseTag implements Factory\StaticMethod
{
/** @var string */
protected $name = 'covers';
protected string $name = 'covers';

/** @var Fqsen */
private $refers;
private Fqsen $refers;

/**
* Initializes this tag.
Expand Down
5 changes: 2 additions & 3 deletions src/DocBlock/Tags/Deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
*/
final class Deprecated extends BaseTag implements Factory\StaticMethod
{
/** @var string */
protected $name = 'deprecated';
protected string $name = 'deprecated';

/**
* PCRE regular expression matching a version vector.
Expand All @@ -45,7 +44,7 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
)';

/** @var string|null The version vector. */
private $version;
private ?string $version = null;

public function __construct(?string $version = null, ?Description $description = null)
{
Expand Down
13 changes: 5 additions & 8 deletions src/DocBlock/Tags/Example.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,19 @@
final class Example implements Tag, Factory\StaticMethod
{
/** @var string Path to a file to use as an example. May also be an absolute URI. */
private $filePath;
private string $filePath;

/**
* @var bool Whether the file path component represents an URI. This determines how the file portion
* appears at {@link getContent()}.
*/
private $isURI;
private bool $isURI;

/** @var int */
private $startingLine;
private int $startingLine;

/** @var int */
private $lineCount;
private int $lineCount;

/** @var string|null */
private $content;
private ?string $content = null;

public function __construct(
string $filePath,
Expand Down
2 changes: 1 addition & 1 deletion src/DocBlock/Tags/Formatter/AlignFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class AlignFormatter implements Formatter
{
/** @var int The maximum tag name length. */
protected $maxLen = 0;
protected int $maxLen = 0;

/**
* @param Tag[] $tags All tags that should later be aligned with the formatter.
Expand Down
9 changes: 3 additions & 6 deletions src/DocBlock/Tags/InvalidTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@
*/
final class InvalidTag implements Tag
{
/** @var string */
private $name;
private string $name;

/** @var string */
private $body;
private string $body;

/** @var Throwable|null */
private $throwable;
private ?Throwable $throwable = null;

private function __construct(string $name, string $body)
{
Expand Down
Loading

0 comments on commit c6d49fc

Please sign in to comment.