mirror of
https://github.com/standardebooks/web.git
synced 2025-07-14 10:31:59 -04:00
Update composer packages
This commit is contained in:
parent
58cc098058
commit
415aed8b31
59 changed files with 3352 additions and 2347 deletions
41
vendor/nette/robot-loader/readme.md
vendored
41
vendor/nette/robot-loader/readme.md
vendored
|
@ -14,11 +14,13 @@ Introduction
|
|||
RobotLoader is a tool that gives you comfort of automated class loading for your entire application including third-party libraries.
|
||||
|
||||
- get rid of all `require`
|
||||
- only necessary scripts are loaded
|
||||
- requires no strict file naming conventions
|
||||
- allows more classes in single file
|
||||
- extremely fast
|
||||
- no manual cache updates, everything runs automatically
|
||||
- highly mature, stable and widely used library
|
||||
|
||||
RobotLoader is extremely comfortable and addictive!
|
||||
RobotLoader is incredibly comfortable and addictive!
|
||||
|
||||
If you like Nette, **[please make a donation now](https://nette.org/donate)**. Thank you!
|
||||
|
||||
|
@ -46,7 +48,7 @@ The recommended way to install is via Composer:
|
|||
composer require nette/robot-loader
|
||||
```
|
||||
|
||||
It requires PHP version 5.6 and supports PHP up to 7.2.
|
||||
It requires PHP version 5.6 and supports PHP up to 7.3.
|
||||
|
||||
|
||||
Usage
|
||||
|
@ -76,3 +78,36 @@ This feature should be disabled on production server.
|
|||
If you want RobotLoader to skip some directory, use `$loader->excludeDirectory('temp')`.
|
||||
|
||||
By default, RobotLoader reports errors in PHP files by throwing exception `ParseError` (since PHP 7.0). It can be disabled via `$loader->reportParseErrors(false)`.
|
||||
|
||||
|
||||
PHP files analyzer
|
||||
------------------
|
||||
|
||||
RobotLoader can also be used to find classes, interfaces, and trait in PHP files without using the autoloading feature:
|
||||
|
||||
```php
|
||||
$loader = new Nette\Loaders\RobotLoader;
|
||||
$loader->addDirectory(__DIR__ . '/app');
|
||||
|
||||
// Scans directories for classes / intefaces / traits
|
||||
$loader->rebuild();
|
||||
|
||||
// Returns array of class => filename pairs
|
||||
$res = $loader->getIndexedClasses();
|
||||
```
|
||||
|
||||
When scanning files again, we can use the cache and unmodified files will not be analyzed repeatedly:
|
||||
|
||||
```php
|
||||
$loader = new Nette\Loaders\RobotLoader;
|
||||
$loader->addDirectory(__DIR__ . '/app');
|
||||
$loader->setTempDirectory(__DIR__ . '/temp');
|
||||
|
||||
// Scans directories using a cache
|
||||
$loader->refresh();
|
||||
|
||||
// Returns array of class => filename pairs
|
||||
$res = $loader->getIndexedClasses();
|
||||
```
|
||||
|
||||
Enjoy RobotLoader!
|
||||
|
|
|
@ -28,10 +28,10 @@ class RobotLoader
|
|||
|
||||
const RETRY_LIMIT = 3;
|
||||
|
||||
/** @var array comma separated wildcards */
|
||||
/** @var array */
|
||||
public $ignoreDirs = ['.*', '*.old', '*.bak', '*.tmp', 'temp'];
|
||||
|
||||
/** @var array comma separated wildcards */
|
||||
/** @var array */
|
||||
public $acceptFiles = ['*.php'];
|
||||
|
||||
/** @var bool */
|
||||
|
@ -95,7 +95,7 @@ class RobotLoader
|
|||
$missing = &$this->missing[$type];
|
||||
$missing++;
|
||||
if (!$this->refreshed && $missing <= self::RETRY_LIMIT) {
|
||||
$this->refresh();
|
||||
$this->refreshClasses();
|
||||
$this->saveCache();
|
||||
} elseif ($info) {
|
||||
unset($this->classes[$type]);
|
||||
|
@ -171,7 +171,8 @@ class RobotLoader
|
|||
*/
|
||||
public function rebuild()
|
||||
{
|
||||
$this->refresh();
|
||||
$this->classes = $this->missing = [];
|
||||
$this->refreshClasses();
|
||||
if ($this->tempDirectory) {
|
||||
$this->saveCache();
|
||||
}
|
||||
|
@ -179,12 +180,26 @@ class RobotLoader
|
|||
|
||||
|
||||
/**
|
||||
* Refreshes class list.
|
||||
* Refreshes class list cache.
|
||||
* @return void
|
||||
*/
|
||||
private function refresh()
|
||||
public function refresh()
|
||||
{
|
||||
$this->refreshed = true; // prevents calling refresh() or updateFile() in tryLoad()
|
||||
$this->loadCache();
|
||||
if (!$this->refreshed) {
|
||||
$this->refreshClasses();
|
||||
$this->saveCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Refreshes $classes.
|
||||
* @return void
|
||||
*/
|
||||
private function refreshClasses()
|
||||
{
|
||||
$this->refreshed = true; // prevents calling refreshClasses() or updateFile() in tryLoad()
|
||||
$files = [];
|
||||
foreach ($this->classes as $class => $info) {
|
||||
$files[$info['file']]['time'] = $info['time'];
|
||||
|
@ -193,7 +208,8 @@ class RobotLoader
|
|||
|
||||
$this->classes = [];
|
||||
foreach ($this->scanPaths as $path) {
|
||||
foreach (is_file($path) ? [new SplFileInfo($path)] : $this->createFileIterator($path) as $file) {
|
||||
$iterator = is_file($path) ? [new SplFileInfo($path)] : $this->createFileIterator($path);
|
||||
foreach ($iterator as $file) {
|
||||
$file = $file->getPathname();
|
||||
if (isset($files[$file]) && $files[$file]['time'] == filemtime($file)) {
|
||||
$classes = $files[$file]['classes'];
|
||||
|
@ -234,7 +250,8 @@ class RobotLoader
|
|||
}
|
||||
}
|
||||
|
||||
$iterator = Nette\Utils\Finder::findFiles(is_array($this->acceptFiles) ? $this->acceptFiles : preg_split('#[,\s]+#', $this->acceptFiles))
|
||||
$acceptFiles = is_array($this->acceptFiles) ? $this->acceptFiles : preg_split('#[,\s]+#', $this->acceptFiles);
|
||||
$iterator = Nette\Utils\Finder::findFiles($acceptFiles)
|
||||
->filter(function (SplFileInfo $file) use (&$disallow) {
|
||||
return !isset($disallow[str_replace('\\', '/', $file->getRealPath())]);
|
||||
})
|
||||
|
@ -419,9 +436,7 @@ class RobotLoader
|
|||
|
||||
list($this->classes, $this->missing) = @include $file; // @ file may not exist
|
||||
if (!is_array($this->classes)) {
|
||||
$this->classes = [];
|
||||
$this->refresh();
|
||||
$this->saveCache();
|
||||
$this->rebuild();
|
||||
}
|
||||
|
||||
flock($handle, LOCK_UN);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue