Skip to content

Commit 9897d6d

Browse files
committed
Drop PHP 7.4 support
1 parent 5df341b commit 9897d6d

File tree

14 files changed

+36
-59
lines changed

14 files changed

+36
-59
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ But with PHPFUI/InstaDoc, you can document your site in about a minute (OK, mayb
2828
* 5+ line config compatible with all PHP frameworks, or standalone.
2929
* Uses [Foundation CSS framework](https://get.foundation) for a great experience on mobile.
3030

31-
### Install PHPFUI/InstaDoc (requires PHP >= 7.4)
31+
### Install PHPFUI/InstaDoc (requires PHP >= 8.0)
3232
```
3333
composer require phpfui/InstaDoc
3434
```

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"php": ">=7.4 <8.2",
15+
"php": ">=8.0 <8.2",
1616
"phpfui/phpfui": "^6.0",
1717
"scrivo/highlight.php": "dev-master",
1818
"phpdocumentor/reflection-docblock": "^5.0",

src/PHPFUI/InstaDoc/ChildClasses.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function generate() : void
4040
}
4141
}
4242
}
43-
catch (\Throwable $e)
43+
catch (\Throwable)
4444
{
4545
}
4646
}

src/PHPFUI/InstaDoc/Controller.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ class Controller
6666
*/
6767
private array $accessTabs = ['Public', 'Protected', 'Private', 'Static'];
6868

69-
private \PHPFUI\InstaDoc\FileManager $fileManager;
70-
7169
private string $generating = '';
7270

7371
private string $gitFileOffset = '';
@@ -92,9 +90,8 @@ class Controller
9290

9391
private string $siteTitle = 'PHPFUI/InstaDoc';
9492

95-
public function __construct(\PHPFUI\InstaDoc\FileManager $fileManager)
93+
public function __construct(private \PHPFUI\InstaDoc\FileManager $fileManager)
9694
{
97-
$this->fileManager = $fileManager;
9895
$this->gitRoot = $fileManager->getComposerPath();
9996
$this->page = $this->getPage();
10097
$this->setParameters($this->page->getQueryParameters());
@@ -481,7 +478,7 @@ public function getConstructorParameters(string $className) : string
481478
{
482479
$reflection = new \ReflectionClass($className);
483480
}
484-
catch (\Exception $e)
481+
catch (\Exception)
485482
{
486483
return '';
487484
}

src/PHPFUI/InstaDoc/FileManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class FileManager
3232
public function __construct(string $composerJsonPath = '')
3333
{
3434
$this->setComposerPath($composerJsonPath);
35-
$class = __CLASS__;
35+
$class = self::class;
3636
$this->fileName = \substr($class, \strrpos($class, '\\') + 1);
3737
}
3838

@@ -236,7 +236,7 @@ private function loadVendorDirectories() : void
236236

237237
$composerJsonPath = $this->composerJsonPath . 'composer.lock';
238238
$composerJsonPath = \str_replace('//', '/', $composerJsonPath);
239-
$json = \json_decode(@\file_get_contents($composerJsonPath), true);
239+
$json = \json_decode(@\file_get_contents($composerJsonPath), true, 512);
240240

241241
if (! $json)
242242
{

src/PHPFUI/InstaDoc/NamespaceTree.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static function addNamespace(string $namespace, string $directory, bool $
8181
$filename = $fileinfo->getFilename();
8282
$filenameLength = \strlen($filename);
8383

84-
if ($fileinfo->isDir() && false === \strpos($filename, '.'))
84+
if ($fileinfo->isDir() && ! \str_contains($filename, '.'))
8585
{
8686
self::addNamespace($namespace . '\\' . $filename, $directory . '/' . $filename, $localGit);
8787
}

src/PHPFUI/InstaDoc/Page.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,15 @@
44

55
class Page extends \PHPFUI\Page implements \PHPFUI\InstaDoc\PageInterface
66
{
7-
private \PHPFUI\InstaDoc\Controller $controller;
8-
97
private string $generating = '';
108

119
private string $homeUrl = '#';
1210

1311
private \PHPFUI\Cell $mainColumn;
1412

15-
public function __construct(\PHPFUI\InstaDoc\Controller $controller)
13+
public function __construct(private \PHPFUI\InstaDoc\Controller $controller)
1614
{
1715
parent::__construct();
18-
$this->controller = $controller;
1916
$this->mainColumn = new \PHPFUI\Cell(12, 8, 9);
2017
$this->addStyleSheet('css/styles.css');
2118
$this->addStyleSheet('css/markdown.css');

src/PHPFUI/InstaDoc/Section.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
*/
1010
class Section
1111
{
12-
protected \PHPFUI\InstaDoc\Controller $controller;
13-
14-
public function __construct(\PHPFUI\InstaDoc\Controller $controller)
12+
public function __construct(protected \PHPFUI\InstaDoc\Controller $controller)
1513
{
16-
$this->controller = $controller;
1714
}
1815

1916
public function generate(\PHPFUI\InstaDoc\PageInterface $page, string $object) : \PHPFUI\Container

src/PHPFUI/InstaDoc/Section/CodeCommon.php

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,24 @@ public function __construct(\PHPFUI\InstaDoc\Controller $controller, string $ful
2727

2828
try
2929
{
30-
/** @phpstan-ignore-next-line */
30+
// @phpstan-ignore-next-line
3131
$this->reflection->isInstantiable();
3232
}
33-
catch (\Throwable $e)
33+
catch (\Throwable)
3434
{
3535
$this->reflection = new \ReflectionEnum($fullClassPath);
3636
}
3737
}
38-
catch (\Throwable $e)
38+
catch (\Throwable)
3939
{
4040
}
4141
}
4242
}
4343

4444
/**
45-
* @param \ReflectionFunction | \ReflectionMethod $method
4645
* @param array<string, string> $parameterComments comments indexed by parameter name
4746
*/
48-
public function getMethodParameters($method, array $parameterComments = []) : string
47+
public function getMethodParameters(\ReflectionFunction|\ReflectionMethod $method, array $parameterComments = []) : string
4948
{
5049
$info = $comma = '';
5150

@@ -84,7 +83,7 @@ public function getMethodParameters($method, array $parameterComments = []) : st
8483
{
8584
if (\is_object($value))
8685
{
87-
$value = \get_class($value);
86+
$value = $value::class;
8887
}
8988
$extra = $parameter->getDefaultValueConstantName();
9089
$info .= \str_replace($value, '', $extra);
@@ -128,7 +127,7 @@ public function getValueString(mixed $value) : string
128127
break;
129128

130129
case 'object':
131-
$class = \get_class($value);
130+
$class = $value::class;
132131

133132
if ('ReflectionNamedType' == $class)
134133
{
@@ -252,7 +251,7 @@ protected function formatComments(?\phpDocumentor\Reflection\DocBlock $docBlock,
252251

253252
if (\method_exists($tag, 'getAuthorName'))
254253
{
255-
/** @phpstan-ignore-next-line */
254+
// @phpstan-ignore-next-line
256255
$body .= \PHPFUI\Link::email($tag->getEmail(), $tag->getAuthorName());
257256
}
258257

@@ -329,7 +328,7 @@ protected function getClassName(string $class, bool $asLink = true) : string
329328
$class = \substr($class, 1);
330329
}
331330

332-
if (false !== \strpos($class, '[]'))
331+
if (\str_contains($class, '[]'))
333332
{
334333
$array = '[]';
335334
$class = \str_replace($array, '', $class);
@@ -402,7 +401,7 @@ protected function getDocBlock(object $method) : ?\phpDocumentor\Reflection\DocB
402401
{
403402
$docBlock = $this->factory->create($comments);
404403
}
405-
catch (\Exception $e)
404+
catch (\Exception)
406405
{
407406
$docBlock = null;
408407
}
@@ -444,7 +443,7 @@ protected function getInheritedText(\phpDocumentor\Reflection\DocBlock $docBlock
444443
{
445444
$method = $parent->getMethod($reflectionMethod->name);
446445
}
447-
catch (\Throwable $e)
446+
catch (\Throwable)
448447
{
449448
$method = null;
450449
}
@@ -488,7 +487,7 @@ protected function getInheritedDocBlock(array $tags, \ReflectionMethod $reflecti
488487
{
489488
$method = $parent->getMethod($reflectionMethod->name);
490489
}
491-
catch (\Throwable $e)
490+
catch (\Throwable)
492491
{
493492
$method = null;
494493
}
@@ -534,7 +533,7 @@ protected function getParameterComments(?\phpDocumentor\Reflection\DocBlock $doc
534533

535534
if ('param' == $name && $description)
536535
{
537-
/** @phpstan-ignore-next-line */
536+
// @phpstan-ignore-next-line
538537
$var = $tag->getVariableName();
539538
$comments[$var] = $this->parsedown->html($description);
540539
}
@@ -543,10 +542,7 @@ protected function getParameterComments(?\phpDocumentor\Reflection\DocBlock $doc
543542
return $comments;
544543
}
545544

546-
/**
547-
* @param \ReflectionFunction | \ReflectionMethod $method
548-
*/
549-
protected function getMethodParametersBlock($method) : string
545+
protected function getMethodParametersBlock(\ReflectionFunction|\ReflectionMethod $method) : string
550546
{
551547
$docBlock = $this->getDocBlock($method);
552548
$parameterComments = $this->getParameterComments($docBlock);

src/PHPFUI/InstaDoc/Section/Doc.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public function generate(\PHPFUI\InstaDoc\PageInterface $page, string $fullClass
2323

2424
try
2525
{
26-
/** @phpstan-ignore-next-line */
26+
// @phpstan-ignore-next-line
2727
$this->reflection->isInstantiable();
2828
}
29-
catch (\Throwable $e)
29+
catch (\Throwable)
3030
{
3131
$this->reflection = new \ReflectionEnum($this->class);
3232
}
3333
}
34-
catch (\Throwable $e)
34+
catch (\Throwable)
3535
{
3636
// Try to parse as functions
3737
$functionView = new \PHPFUI\InstaDoc\Section\Functions($this->controller);
@@ -258,10 +258,9 @@ public function generate(\PHPFUI\InstaDoc\PageInterface $page, string $fullClass
258258
}
259259

260260
/**
261-
* @param \ReflectionProperty | \ReflectionClassConstant $constant
262261
* @return string the color coded access level (public, private, protected)
263262
*/
264-
protected function getAccess($constant) : string
263+
protected function getAccess(\ReflectionProperty|\ReflectionClassConstant $constant) : string
265264
{
266265
if ($constant->isPrivate())
267266
{
@@ -403,10 +402,7 @@ protected function getMethod(\ReflectionMethod $method) : string
403402
return $info;
404403
}
405404

406-
/**
407-
* @param \ReflectionClassConstant | \ReflectionMethod | \ReflectionProperty $method
408-
*/
409-
protected function getName($method, string $name, bool $fullyQualify = false) : string
405+
protected function getName(\ReflectionClassConstant|\ReflectionMethod|\ReflectionProperty $method, string $name, bool $fullyQualify = false) : string
410406
{
411407
$parent = $this->getNameScope($method, $fullyQualify);
412408

@@ -419,10 +415,7 @@ protected function getName($method, string $name, bool $fullyQualify = false) :
419415
return $name;
420416
}
421417

422-
/**
423-
* @param \ReflectionProperty | \ReflectionMethod $method
424-
*/
425-
protected function getNameScope(mixed $method, bool $fullyQualify = false) : string
418+
protected function getNameScope(\ReflectionProperty|\ReflectionMethod|\ReflectionClassConstant $method, bool $fullyQualify = false) : string
426419
{
427420
$parent = $method->getDeclaringClass();
428421

@@ -448,7 +441,7 @@ protected function getProperty(\ReflectionProperty $property) : string
448441

449442
if ($type)
450443
{
451-
/** @phpstan-ignore-next-line */
444+
// @phpstan-ignore-next-line
452445
$info .= $this->getColor('type', $this->getClassName($type->getName())) . ' ';
453446
}
454447
$info .= $this->getName($property, $this->getColor('variable', '$' . $property->getName()));
@@ -468,10 +461,7 @@ protected function getProperty(\ReflectionProperty $property) : string
468461
return $info;
469462
}
470463

471-
/**
472-
* @param \ReflectionClassConstant | \ReflectionMethod $method
473-
*/
474-
protected function getRowClasses($method) : string
464+
protected function getRowClasses(\ReflectionClassConstant|\ReflectionMethod|\ReflectionProperty $method) : string
475465
{
476466
$class = $this->getNameScope($method);
477467

src/PHPFUI/InstaDoc/Section/Functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function generate(\PHPFUI\InstaDoc\PageInterface $page, string $fullClass
3232
$end = \strpos($file, '(', $index);
3333
$name = \trim(\substr($file, $index, $end - $index));
3434

35-
if (false === \strpos($name, ' '))
35+
if (! \str_contains($name, ' '))
3636
{
3737
$functions[] = \trim(\substr($file, $index, $end - $index));
3838
}

src/PHPFUI/InstaDoc/Section/Git.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function generate(\PHPFUI\InstaDoc\PageInterface $page, string $fullClass
1313

1414
$offset = $this->controller->getGitFileOffset();
1515

16-
if ($offset && 0 === \strpos($fullClassPath, $offset))
16+
if ($offset && \str_starts_with($fullClassPath, $offset))
1717
{
1818
$fullClassPath = \substr($fullClassPath, \strlen($offset));
1919
}
@@ -98,7 +98,7 @@ public function generate(\PHPFUI\InstaDoc\PageInterface $page, string $fullClass
9898

9999
private function getReveal(\PHPFUI\InstaDoc\PageInterface $page, \PHPFUI\HTML5Element $opener, string $url) : \PHPFUI\Reveal
100100
{
101-
/** @phpstan-ignore-next-line */
101+
// @phpstan-ignore-next-line
102102
$reveal = new \PHPFUI\Reveal($page, $opener);
103103
$reveal->addClass('large');
104104
$div = new \PHPFUI\HTML5Element('div');

src/PHPFUI/InstaDoc/Section/GitDiff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function generate(\PHPFUI\InstaDoc\PageInterface $page, string $fullClass
1616
{
1717
$commit = $repo->getCommit($sha1);
1818
}
19-
catch (\Exception $e)
19+
catch (\Exception)
2020
{
2121
$container->add('Commit not found');
2222

tests/SectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
class SectionTest extends \PHPFUI\HTMLUnitTester\Extensions
1313
{
14-
private $sections = [];
14+
private array $sections = [];
1515

1616
private $fileManager;
1717

0 commit comments

Comments
 (0)