Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Draft
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
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,19 @@
"league/commonmark": "^2.2",
"league/flysystem": "^1.0",
"league/tactician": "^1.0",
"league/uri": "^6.7",
"league/uri-interfaces": "^2.0",
"league/uri": "^7.5",
"league/uri-interfaces": "^7.5",
"monolog/monolog": "^2.9",
"nikic/php-parser": "^5.0",
"phar-io/manifest": "^2.0",
"phar-io/version": "^3.2",
"phpdocumentor/filesystem": "^1.7",
"phpdocumentor/flyfinder": "^1.0",
"phpdocumentor/graphviz": "^2.0",
"phpdocumentor/guides": "^1.5",
"phpdocumentor/guides-graphs": "^1.4",
"phpdocumentor/guides-markdown": "^1.5",
"phpdocumentor/guides-restructured-text": "^1.5",
"phpdocumentor/guides": "^1.7",
"phpdocumentor/guides-graphs": "^1.7",
"phpdocumentor/guides-markdown": "^1.7",
"phpdocumentor/guides-restructured-text": "^1.7",
"phpdocumentor/json-path": "^0.1.0",
"phpdocumentor/reflection": "^6.0",
"phpdocumentor/reflection-common": "^2.0",
Expand Down
467 changes: 289 additions & 178 deletions composer.lock

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ parameters:
- '#.*NodeDefinition::fixXmlConfig.*#'
- '#.*NodeDefinition::addDefaultsIfNotSet.*#'

# FlyFinder plugin adds a find method to FlySystem's Filesystem
- '#Call to an undefined method League\\Flysystem\\Filesystem::find\(\)#'

# PHPStan has issue when involving templates and parent types
- '#Parameter \#1 \$matcher of method phpDocumentor\\Descriptor\\Builder\\AssemblerFactory::(register|registerFallback)\(\) expects phpDocumentor\\Descriptor\\Builder\\Matcher<object>, phpDocumentor\\Descriptor\\Builder\\Matcher<.+> given\.#'

Expand Down
4 changes: 2 additions & 2 deletions src/phpDocumentor/Configuration/ApiSpecification.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use ArrayAccess;
use phpDocumentor\Configuration\Definition\Version3;
use phpDocumentor\Dsn;
use phpDocumentor\Path;
use phpDocumentor\FileSystem\Dsn;
use phpDocumentor\FileSystem\Path;
use RuntimeException;
use Webmozart\Assert\Assert;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace phpDocumentor\Configuration;

use League\Uri\Contracts\UriInterface;
use phpDocumentor\Dsn;
use phpDocumentor\Path;
use phpDocumentor\FileSystem\Dsn;
use phpDocumentor\FileSystem\Path;
use Symfony\Component\Filesystem\Path as SymfonyPath;
use Webmozart\Assert\Assert;

Expand Down Expand Up @@ -127,7 +127,7 @@ private function overwriteTemplates(Configuration $configuration): Configuration
{
if (isset($this->options['template']) && $this->options['template']) {
$configuration['phpdocumentor']['templates'] = array_map(
static fn ($templateName) => ['name' => $templateName],
static fn ($templateName) => new TemplateDefinition($templateName),
(array) $this->options['template'],
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/phpDocumentor/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace phpDocumentor\Configuration;

use ArrayObject;
use phpDocumentor\Dsn;
use phpDocumentor\Path;
use phpDocumentor\FileSystem\Dsn;
use phpDocumentor\FileSystem\Path;

/**
* @template-extends ArrayObject<string, mixed>&ConfigurationMap
Expand Down
10 changes: 10 additions & 0 deletions src/phpDocumentor/Configuration/ConfigurationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ private function createConfigurationFromArray(array $configuration): Configurati
}
}

if (isset($configuration['phpdocumentor']['templates'])) {
foreach ($configuration['phpdocumentor']['templates'] as $templateNumber => $template) {
$configuration['phpdocumentor']['templates'][$templateNumber] = new TemplateDefinition(
$template['name'],
$template['location'],
$template['parameters'],
);
}
}

return new Configuration($configuration);
}
}
4 changes: 2 additions & 2 deletions src/phpDocumentor/Configuration/Definition/Version3.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace phpDocumentor\Configuration\Definition;

use phpDocumentor\Configuration\SymfonyConfigFactory;
use phpDocumentor\Dsn;
use phpDocumentor\Path;
use phpDocumentor\FileSystem\Dsn;
use phpDocumentor\FileSystem\Path;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
Expand Down
15 changes: 7 additions & 8 deletions src/phpDocumentor/Configuration/PathNormalizingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
namespace phpDocumentor\Configuration;

use League\Uri\Contracts\UriInterface;
use phpDocumentor\Dsn;
use phpDocumentor\Path;
use Symfony\Component\Filesystem\Path as SymfonyPath;
use phpDocumentor\FileSystem\Dsn;
use phpDocumentor\FileSystem\Path;

use function array_map;
use function array_merge;
Expand Down Expand Up @@ -85,18 +84,18 @@ private function makeDsnRelativeToConfig(Configuration $configuration, UriInterf
}
}

/** @var array{name: string, location?: ?Path, parameters?: array<string, mixed>} $template */
/** @var TemplateDefinition $template */
foreach ($configuration['phpdocumentor']['templates'] as $key => $template) {
if (isset($template['location']) === false) {
if (isset($template->location) === false) {
continue;
}

$location = $template['location'];
if ($location instanceof Path && SymfonyPath::isAbsolute((string) $location) === false) {
$location = $template->location;
if ($location instanceof Path && Path::isAbsolutePath((string) $location) === false) {
$location = new Path($configPath . '/' . $location);
}

$template['location'] = $location;
$template->location = $location;

$configuration['phpdocumentor']['templates'][$key] = $template;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace phpDocumentor\Configuration;

use League\Uri\Contracts\UriInterface;
use phpDocumentor\Dsn;
use phpDocumentor\Path;
use phpDocumentor\FileSystem\Dsn;
use phpDocumentor\FileSystem\Path;
use phpDocumentor\Transformer\Writer\Twig\EnvironmentFactory;

use function file_exists;
Expand Down
4 changes: 2 additions & 2 deletions src/phpDocumentor/Configuration/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use ArrayAccess;
use BadMethodCallException;
use OutOfBoundsException;
use phpDocumentor\Dsn;
use phpDocumentor\Path;
use phpDocumentor\FileSystem\Dsn;
use phpDocumentor\FileSystem\Path;
use ReturnTypeWillChange;

use function array_map;
Expand Down
17 changes: 17 additions & 0 deletions src/phpDocumentor/Configuration/TemplateDefinition.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace phpDocumentor\Configuration;

use phpDocumentor\FileSystem\Path;

class TemplateDefinition
{
public function __construct(

Check failure on line 11 in src/phpDocumentor/Configuration/TemplateDefinition.php

View workflow job for this annotation

GitHub Actions / Phpstan

Method phpDocumentor\Configuration\TemplateDefinition::__construct() has parameter $parameters with no value type specified in iterable type array.
public string $name,
public Path|null $location = null,
public array $parameters = [],
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
* @link https://phpdoc.org
*/

namespace phpDocumentor;
namespace phpDocumentor\FileSystem;

use Generator;
use League\Uri\Contracts\UriInterface;
use League\Uri\UriInfo;
use League\Uri\UriResolver;
use phpDocumentor\UriFactory;
use Stringable;

use function array_shift;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
* @link https://phpdoc.org
*/

namespace phpDocumentor\Parser;

use League\Flysystem\Filesystem;
use phpDocumentor\Dsn;
namespace phpDocumentor\FileSystem;

/**
* Interface for FileSystem factories.
Expand All @@ -24,5 +21,5 @@ interface FileSystemFactory
/**
* Returns a Filesystem instance based on the scheme of the provided Dsn.
*/
public function create(Dsn $dsn): Filesystem;
public function create(Dsn $dsn): FileSystem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@
* @link https://phpdoc.org
*/

namespace phpDocumentor\Parser;
namespace phpDocumentor\FileSystem;

use Flyfinder\Finder;
use InvalidArgumentException;
use League\Flysystem\Adapter\Local;
use League\Flysystem\AdapterInterface;
use League\Flysystem\Filesystem;
use League\Flysystem\Filesystem as FlySystemFilesystem;
use League\Flysystem\MountManager;
use LogicException;
use phpDocumentor\Dsn;
use Webmozart\Assert\Assert;

use function hash;
Expand All @@ -39,23 +37,21 @@ public function __construct(private readonly MountManager $mountManager)
/**
* Returns a Filesystem instance based on the scheme of the provided Dsn
*/
public function create(Dsn $dsn): Filesystem
public function create(Dsn $dsn): FileSystem
{
$dsnId = hash('md5', (string) $dsn);

try {
$filesystem = $this->mountManager->getFilesystem($dsnId);
} catch (LogicException) {
$filesystem = new Filesystem($this->createAdapter($dsn));
$filesystem = new FlySystemFilesystem($this->createAdapter($dsn));

$this->mountManager->mountFilesystem($dsnId, $filesystem);
}

$filesystem->addPlugin(new Finder());
Assert::isInstanceOf($filesystem, FlySystemFilesystem::class);

Assert::isInstanceOf($filesystem, Filesystem::class);

return $filesystem;
return FlySystemAdapter::createFromFileSystem($filesystem);
}

private function createAdapter(Dsn $dsn): AdapterInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @link https://phpdoc.org
*/

namespace phpDocumentor;
namespace phpDocumentor\FileSystem;

use Stringable;
use Webmozart\Assert\Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
* @link https://phpdoc.org
*/

namespace phpDocumentor\Parser;
namespace phpDocumentor\FileSystem;

use Flyfinder\Specification\Glob;
use Flyfinder\Specification\HasExtension;
use Flyfinder\Specification\IsHidden;
use Flyfinder\Specification\NotSpecification;
use Flyfinder\Specification\SpecificationInterface;
use phpDocumentor\Parser\SpecificationFactoryInterface as FactoryInterface;
use phpDocumentor\Path;
use phpDocumentor\FileSystem\SpecificationFactoryInterface as FactoryInterface;

/**
* Factory class to build Specification used by FlyFinder when reading files to process.
Expand All @@ -30,7 +29,7 @@ final class SpecificationFactory implements FactoryInterface
* Creates a SpecificationInterface object based on the ignore and extension parameters.
*
* @param list<string|Path> $paths
* @param array<string, bool|array<string>|null> $ignore
* @param array{paths: list<string|Path>, hidden: bool} $ignore
* @param list<string> $extensions
*/
public function create(array $paths, array $ignore, array $extensions): SpecificationInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
* @link https://phpdoc.org
*/

namespace phpDocumentor\Parser;
namespace phpDocumentor\FileSystem;

use Flyfinder\Specification\SpecificationInterface;
use phpDocumentor\Path;

/**
* Interface for Specifications used to filter the FileSystem.
Expand All @@ -25,7 +24,7 @@ interface SpecificationFactoryInterface
* Creates a SpecificationInterface object based on the ignore and extension parameters.
*
* @param list<string|Path> $paths
* @param array<string, bool|array<string>|null> $ignore
* @param array{paths: list<string|Path>, hidden: bool} $ignore
* @param list<string> $extensions
*/
public function create(array $paths, array $ignore, array $extensions): SpecificationInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/phpDocumentor/Parser/Cache/Locator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace phpDocumentor\Parser\Cache;

use phpDocumentor\Path;
use phpDocumentor\FileSystem\Path;
use RuntimeException;
use Symfony\Contracts\Cache\CacheInterface;
use Webmozart\Assert\Assert;
Expand Down
13 changes: 6 additions & 7 deletions src/phpDocumentor/Parser/FileCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@

namespace phpDocumentor\Parser;

use phpDocumentor\Dsn;
use phpDocumentor\Path;
use phpDocumentor\FileSystem\FileSystem;
use phpDocumentor\FileSystem\Path;
use phpDocumentor\Reflection\File;

interface FileCollector
{
/**
* @param Dsn $dsn dsn of source.
* @param list<string|Path> $paths
* @param array<string, mixed> $ignore array containing keys 'paths' and 'hidden'
* @param list<string> $extensions
* @param list<string|Path> $paths
* @param array{paths: string[], hidden: bool} $ignore array containing keys 'paths' and 'hidden'
* @param list<string> $extensions
*
* @return File[]
*/
public function getFiles(Dsn $dsn, array $paths, array $ignore, array $extensions): array;
public function getFiles(FileSystem $fileSystem, array $paths, array $ignore, array $extensions): array;
}
10 changes: 4 additions & 6 deletions src/phpDocumentor/Parser/FlySystemCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

namespace phpDocumentor\Parser;

use phpDocumentor\Dsn;
use phpDocumentor\Path;
use phpDocumentor\FileSystem\FileSystem;
use phpDocumentor\FileSystem\Path;
use phpDocumentor\FileSystem\SpecificationFactoryInterface;

final class FlySystemCollector implements FileCollector
{
public function __construct(
private readonly SpecificationFactoryInterface $specificationFactory,
private readonly FlySystemFactory $flySystemFactory,
) {
}

Expand All @@ -31,12 +31,10 @@ public function __construct(
*
* @return list<FlySystemFile>
*/
public function getFiles(Dsn $dsn, array $paths, array $ignore, array $extensions): array
public function getFiles(FileSystem $fileSystem, array $paths, array $ignore, array $extensions): array
{
$specs = $this->specificationFactory->create($paths, $ignore, $extensions);

$fileSystem = $this->flySystemFactory->create($dsn);

$files = [];

foreach ($fileSystem->find($specs) as $file) {
Expand Down
Loading
Loading