[COMPOSER] Add new php-ffmpeg package

This commit is contained in:
t3nma
2020-08-07 23:42:38 +01:00
parent 0a6bb5190f
commit c527ad0803
8874 changed files with 1090008 additions and 154 deletions

3
vendor/symfony/stopwatch/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
vendor/
composer.lock
phpunit.xml

19
vendor/symfony/stopwatch/LICENSE vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2004-2018 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

13
vendor/symfony/stopwatch/README.md vendored Normal file
View File

@@ -0,0 +1,13 @@
Stopwatch Component
===================
The Stopwatch component provides a way to profile code.
Resources
---------
* [Documentation](https://symfony.com/doc/current/components/stopwatch.html)
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
* [Report issues](https://github.com/symfony/symfony/issues) and
[send Pull Requests](https://github.com/symfony/symfony/pulls)
in the [main Symfony repository](https://github.com/symfony/symfony)

191
vendor/symfony/stopwatch/Section.php vendored Normal file
View File

@@ -0,0 +1,191 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Stopwatch;
/**
* Stopwatch section.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Section
{
/**
* @var StopwatchEvent[]
*/
private $events = array();
/**
* @var float|null
*/
private $origin;
/**
* @var string
*/
private $id;
/**
* @var Section[]
*/
private $children = array();
/**
* @param float|null $origin Set the origin of the events in this section, use null to set their origin to their start time
*/
public function __construct($origin = null)
{
$this->origin = is_numeric($origin) ? $origin : null;
}
/**
* Returns the child section.
*
* @param string $id The child section identifier
*
* @return self|null The child section or null when none found
*/
public function get($id)
{
foreach ($this->children as $child) {
if ($id === $child->getId()) {
return $child;
}
}
}
/**
* Creates or re-opens a child section.
*
* @param string|null $id Null to create a new section, the identifier to re-open an existing one
*
* @return self
*/
public function open($id)
{
if (null === $session = $this->get($id)) {
$session = $this->children[] = new self(microtime(true) * 1000);
}
return $session;
}
/**
* @return string The identifier of the section
*/
public function getId()
{
return $this->id;
}
/**
* Sets the session identifier.
*
* @param string $id The session identifier
*
* @return $this
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Starts an event.
*
* @param string $name The event name
* @param string $category The event category
*
* @return StopwatchEvent The event
*/
public function startEvent($name, $category)
{
if (!isset($this->events[$name])) {
$this->events[$name] = new StopwatchEvent($this->origin ?: microtime(true) * 1000, $category);
}
return $this->events[$name]->start();
}
/**
* Checks if the event was started.
*
* @param string $name The event name
*
* @return bool
*/
public function isEventStarted($name)
{
return isset($this->events[$name]) && $this->events[$name]->isStarted();
}
/**
* Stops an event.
*
* @param string $name The event name
*
* @return StopwatchEvent The event
*
* @throws \LogicException When the event has not been started
*/
public function stopEvent($name)
{
if (!isset($this->events[$name])) {
throw new \LogicException(sprintf('Event "%s" is not started.', $name));
}
return $this->events[$name]->stop();
}
/**
* Stops then restarts an event.
*
* @param string $name The event name
*
* @return StopwatchEvent The event
*
* @throws \LogicException When the event has not been started
*/
public function lap($name)
{
return $this->stopEvent($name)->start();
}
/**
* Returns a specific event by name.
*
* @param string $name The event name
*
* @return StopwatchEvent The event
*
* @throws \LogicException When the event is not known
*/
public function getEvent($name)
{
if (!isset($this->events[$name])) {
throw new \LogicException(sprintf('Event "%s" is not known.', $name));
}
return $this->events[$name];
}
/**
* Returns the events from this section.
*
* @return StopwatchEvent[] An array of StopwatchEvent instances
*/
public function getEvents()
{
return $this->events;
}
}

159
vendor/symfony/stopwatch/Stopwatch.php vendored Normal file
View File

@@ -0,0 +1,159 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Stopwatch;
/**
* Stopwatch provides a way to profile code.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Stopwatch
{
/**
* @var Section[]
*/
private $sections;
/**
* @var Section[]
*/
private $activeSections;
public function __construct()
{
$this->sections = $this->activeSections = array('__root__' => new Section(null));
}
/**
* @return Section[]
*/
public function getSections()
{
return $this->sections;
}
/**
* Creates a new section or re-opens an existing section.
*
* @param string|null $id The id of the session to re-open, null to create a new one
*
* @throws \LogicException When the section to re-open is not reachable
*/
public function openSection($id = null)
{
$current = end($this->activeSections);
if (null !== $id && null === $current->get($id)) {
throw new \LogicException(sprintf('The section "%s" has been started at an other level and can not be opened.', $id));
}
$this->start('__section__.child', 'section');
$this->activeSections[] = $current->open($id);
$this->start('__section__');
}
/**
* Stops the last started section.
*
* The id parameter is used to retrieve the events from this section.
*
* @see getSectionEvents()
*
* @param string $id The identifier of the section
*
* @throws \LogicException When there's no started section to be stopped
*/
public function stopSection($id)
{
$this->stop('__section__');
if (1 == \count($this->activeSections)) {
throw new \LogicException('There is no started section to stop.');
}
$this->sections[$id] = array_pop($this->activeSections)->setId($id);
$this->stop('__section__.child');
}
/**
* Starts an event.
*
* @param string $name The event name
* @param string $category The event category
*
* @return StopwatchEvent
*/
public function start($name, $category = null)
{
return end($this->activeSections)->startEvent($name, $category);
}
/**
* Checks if the event was started.
*
* @param string $name The event name
*
* @return bool
*/
public function isStarted($name)
{
return end($this->activeSections)->isEventStarted($name);
}
/**
* Stops an event.
*
* @param string $name The event name
*
* @return StopwatchEvent
*/
public function stop($name)
{
return end($this->activeSections)->stopEvent($name);
}
/**
* Stops then restarts an event.
*
* @param string $name The event name
*
* @return StopwatchEvent
*/
public function lap($name)
{
return end($this->activeSections)->stopEvent($name)->start();
}
/**
* Returns a specific event by name.
*
* @param string $name The event name
*
* @return StopwatchEvent
*/
public function getEvent($name)
{
return end($this->activeSections)->getEvent($name);
}
/**
* Gets all events for a given section.
*
* @param string $id A section identifier
*
* @return StopwatchEvent[]
*/
public function getSectionEvents($id)
{
return isset($this->sections[$id]) ? $this->sections[$id]->getEvents() : array();
}
}

View File

@@ -0,0 +1,241 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Stopwatch;
/**
* Represents an Event managed by Stopwatch.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class StopwatchEvent
{
/**
* @var StopwatchPeriod[]
*/
private $periods = array();
/**
* @var float
*/
private $origin;
/**
* @var string
*/
private $category;
/**
* @var float[]
*/
private $started = array();
/**
* @param float $origin The origin time in milliseconds
* @param string|null $category The event category or null to use the default
*
* @throws \InvalidArgumentException When the raw time is not valid
*/
public function __construct($origin, $category = null)
{
$this->origin = $this->formatTime($origin);
$this->category = \is_string($category) ? $category : 'default';
}
/**
* Gets the category.
*
* @return string The category
*/
public function getCategory()
{
return $this->category;
}
/**
* Gets the origin.
*
* @return float The origin in milliseconds
*/
public function getOrigin()
{
return $this->origin;
}
/**
* Starts a new event period.
*
* @return $this
*/
public function start()
{
$this->started[] = $this->getNow();
return $this;
}
/**
* Stops the last started event period.
*
* @return $this
*
* @throws \LogicException When stop() is called without a matching call to start()
*/
public function stop()
{
if (!\count($this->started)) {
throw new \LogicException('stop() called but start() has not been called before.');
}
$this->periods[] = new StopwatchPeriod(array_pop($this->started), $this->getNow());
return $this;
}
/**
* Checks if the event was started.
*
* @return bool
*/
public function isStarted()
{
return !empty($this->started);
}
/**
* Stops the current period and then starts a new one.
*
* @return $this
*/
public function lap()
{
return $this->stop()->start();
}
/**
* Stops all non already stopped periods.
*/
public function ensureStopped()
{
while (\count($this->started)) {
$this->stop();
}
}
/**
* Gets all event periods.
*
* @return StopwatchPeriod[] An array of StopwatchPeriod instances
*/
public function getPeriods()
{
return $this->periods;
}
/**
* Gets the relative time of the start of the first period.
*
* @return int The time (in milliseconds)
*/
public function getStartTime()
{
return isset($this->periods[0]) ? $this->periods[0]->getStartTime() : 0;
}
/**
* Gets the relative time of the end of the last period.
*
* @return int The time (in milliseconds)
*/
public function getEndTime()
{
$count = \count($this->periods);
return $count ? $this->periods[$count - 1]->getEndTime() : 0;
}
/**
* Gets the duration of the events (including all periods).
*
* @return int The duration (in milliseconds)
*/
public function getDuration()
{
$periods = $this->periods;
$stopped = \count($periods);
$left = \count($this->started) - $stopped;
for ($i = 0; $i < $left; ++$i) {
$index = $stopped + $i;
$periods[] = new StopwatchPeriod($this->started[$index], $this->getNow());
}
$total = 0;
foreach ($periods as $period) {
$total += $period->getDuration();
}
return $total;
}
/**
* Gets the max memory usage of all periods.
*
* @return int The memory usage (in bytes)
*/
public function getMemory()
{
$memory = 0;
foreach ($this->periods as $period) {
if ($period->getMemory() > $memory) {
$memory = $period->getMemory();
}
}
return $memory;
}
/**
* Return the current time relative to origin.
*
* @return float Time in ms
*/
protected function getNow()
{
return $this->formatTime(microtime(true) * 1000 - $this->origin);
}
/**
* Formats a time.
*
* @param int|float $time A raw time
*
* @return float The formatted time
*
* @throws \InvalidArgumentException When the raw time is not valid
*/
private function formatTime($time)
{
if (!is_numeric($time)) {
throw new \InvalidArgumentException('The time must be a numerical value');
}
return round($time, 1);
}
/**
* @return string
*/
public function __toString()
{
return sprintf('%s: %.2F MiB - %d ms', $this->getCategory(), $this->getMemory() / 1024 / 1024, $this->getDuration());
}
}

View File

@@ -0,0 +1,75 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Stopwatch;
/**
* Represents an Period for an Event.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class StopwatchPeriod
{
private $start;
private $end;
private $memory;
/**
* @param int $start The relative time of the start of the period (in milliseconds)
* @param int $end The relative time of the end of the period (in milliseconds)
*/
public function __construct($start, $end)
{
$this->start = (int) $start;
$this->end = (int) $end;
$this->memory = memory_get_usage(true);
}
/**
* Gets the relative time of the start of the period.
*
* @return int The time (in milliseconds)
*/
public function getStartTime()
{
return $this->start;
}
/**
* Gets the relative time of the end of the period.
*
* @return int The time (in milliseconds)
*/
public function getEndTime()
{
return $this->end;
}
/**
* Gets the time spent in this period.
*
* @return int The period duration (in milliseconds)
*/
public function getDuration()
{
return $this->end - $this->start;
}
/**
* Gets the memory usage.
*
* @return int The memory usage (in bytes)
*/
public function getMemory()
{
return $this->memory;
}
}

View File

@@ -0,0 +1,176 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Stopwatch\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Stopwatch\StopwatchEvent;
/**
* StopwatchEventTest.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @group time-sensitive
*/
class StopwatchEventTest extends TestCase
{
const DELTA = 37;
public function testGetOrigin()
{
$event = new StopwatchEvent(12);
$this->assertEquals(12, $event->getOrigin());
}
public function testGetCategory()
{
$event = new StopwatchEvent(microtime(true) * 1000);
$this->assertEquals('default', $event->getCategory());
$event = new StopwatchEvent(microtime(true) * 1000, 'cat');
$this->assertEquals('cat', $event->getCategory());
}
public function testGetPeriods()
{
$event = new StopwatchEvent(microtime(true) * 1000);
$this->assertEquals(array(), $event->getPeriods());
$event = new StopwatchEvent(microtime(true) * 1000);
$event->start();
$event->stop();
$this->assertCount(1, $event->getPeriods());
$event = new StopwatchEvent(microtime(true) * 1000);
$event->start();
$event->stop();
$event->start();
$event->stop();
$this->assertCount(2, $event->getPeriods());
}
public function testLap()
{
$event = new StopwatchEvent(microtime(true) * 1000);
$event->start();
$event->lap();
$event->stop();
$this->assertCount(2, $event->getPeriods());
}
public function testDuration()
{
$event = new StopwatchEvent(microtime(true) * 1000);
$event->start();
usleep(200000);
$event->stop();
$this->assertEquals(200, $event->getDuration(), null, self::DELTA);
$event = new StopwatchEvent(microtime(true) * 1000);
$event->start();
usleep(100000);
$event->stop();
usleep(50000);
$event->start();
usleep(100000);
$event->stop();
$this->assertEquals(200, $event->getDuration(), null, self::DELTA);
}
public function testDurationBeforeStop()
{
$event = new StopwatchEvent(microtime(true) * 1000);
$event->start();
usleep(200000);
$this->assertEquals(200, $event->getDuration(), null, self::DELTA);
$event = new StopwatchEvent(microtime(true) * 1000);
$event->start();
usleep(100000);
$event->stop();
usleep(50000);
$event->start();
usleep(100000);
$this->assertEquals(100, $event->getDuration(), null, self::DELTA);
}
/**
* @expectedException \LogicException
*/
public function testStopWithoutStart()
{
$event = new StopwatchEvent(microtime(true) * 1000);
$event->stop();
}
public function testIsStarted()
{
$event = new StopwatchEvent(microtime(true) * 1000);
$event->start();
$this->assertTrue($event->isStarted());
}
public function testIsNotStarted()
{
$event = new StopwatchEvent(microtime(true) * 1000);
$this->assertFalse($event->isStarted());
}
public function testEnsureStopped()
{
// this also test overlap between two periods
$event = new StopwatchEvent(microtime(true) * 1000);
$event->start();
usleep(100000);
$event->start();
usleep(100000);
$event->ensureStopped();
$this->assertEquals(300, $event->getDuration(), null, self::DELTA);
}
public function testStartTime()
{
$event = new StopwatchEvent(microtime(true) * 1000);
$this->assertLessThanOrEqual(0.5, $event->getStartTime());
$event = new StopwatchEvent(microtime(true) * 1000);
$event->start();
$event->stop();
$this->assertLessThanOrEqual(1, $event->getStartTime());
$event = new StopwatchEvent(microtime(true) * 1000);
$event->start();
usleep(100000);
$event->stop();
$this->assertEquals(0, $event->getStartTime(), null, self::DELTA);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testInvalidOriginThrowsAnException()
{
new StopwatchEvent('abc');
}
public function testHumanRepresentation()
{
$event = new StopwatchEvent(microtime(true) * 1000);
$this->assertEquals('default: 0.00 MiB - 0 ms', (string) $event);
$event->start();
$event->stop();
$this->assertEquals(1, preg_match('/default: [0-9\.]+ MiB - [0-9]+ ms/', (string) $event));
$event = new StopwatchEvent(microtime(true) * 1000, 'foo');
$this->assertEquals('foo: 0.00 MiB - 0 ms', (string) $event);
}
}

View File

@@ -0,0 +1,156 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Stopwatch\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Stopwatch\Stopwatch;
/**
* StopwatchTest.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @group time-sensitive
*/
class StopwatchTest extends TestCase
{
const DELTA = 20;
public function testStart()
{
$stopwatch = new Stopwatch();
$event = $stopwatch->start('foo', 'cat');
$this->assertInstanceOf('Symfony\Component\Stopwatch\StopwatchEvent', $event);
$this->assertEquals('cat', $event->getCategory());
$this->assertSame($event, $stopwatch->getEvent('foo'));
}
public function testIsStarted()
{
$stopwatch = new Stopwatch();
$stopwatch->start('foo', 'cat');
$this->assertTrue($stopwatch->isStarted('foo'));
}
public function testIsNotStarted()
{
$stopwatch = new Stopwatch();
$this->assertFalse($stopwatch->isStarted('foo'));
}
public function testIsNotStartedEvent()
{
$stopwatch = new Stopwatch();
$sections = new \ReflectionProperty('Symfony\Component\Stopwatch\Stopwatch', 'sections');
$sections->setAccessible(true);
$section = $sections->getValue($stopwatch);
$events = new \ReflectionProperty('Symfony\Component\Stopwatch\Section', 'events');
$events->setAccessible(true);
$stopwatchMockEvent = $this->getMockBuilder('Symfony\Component\Stopwatch\StopwatchEvent')
->setConstructorArgs(array(microtime(true) * 1000))
->getMock()
;
$events->setValue(end($section), array('foo' => $stopwatchMockEvent));
$this->assertFalse($stopwatch->isStarted('foo'));
}
public function testStop()
{
$stopwatch = new Stopwatch();
$stopwatch->start('foo', 'cat');
usleep(200000);
$event = $stopwatch->stop('foo');
$this->assertInstanceOf('Symfony\Component\Stopwatch\StopwatchEvent', $event);
$this->assertEquals(200, $event->getDuration(), null, self::DELTA);
}
/**
* @expectedException \LogicException
*/
public function testUnknownEvent()
{
$stopwatch = new Stopwatch();
$stopwatch->getEvent('foo');
}
/**
* @expectedException \LogicException
*/
public function testStopWithoutStart()
{
$stopwatch = new Stopwatch();
$stopwatch->stop('foo');
}
public function testSection()
{
$stopwatch = new Stopwatch();
$stopwatch->openSection();
$stopwatch->start('foo', 'cat');
$stopwatch->stop('foo');
$stopwatch->start('bar', 'cat');
$stopwatch->stop('bar');
$stopwatch->stopSection('1');
$stopwatch->openSection();
$stopwatch->start('foobar', 'cat');
$stopwatch->stop('foobar');
$stopwatch->stopSection('2');
$stopwatch->openSection();
$stopwatch->start('foobar', 'cat');
$stopwatch->stop('foobar');
$stopwatch->stopSection('0');
// the section is an event by itself
$this->assertCount(3, $stopwatch->getSectionEvents('1'));
$this->assertCount(2, $stopwatch->getSectionEvents('2'));
$this->assertCount(2, $stopwatch->getSectionEvents('0'));
}
public function testReopenASection()
{
$stopwatch = new Stopwatch();
$stopwatch->openSection();
$stopwatch->start('foo', 'cat');
$stopwatch->stopSection('section');
$stopwatch->openSection('section');
$stopwatch->start('bar', 'cat');
$stopwatch->stopSection('section');
$events = $stopwatch->getSectionEvents('section');
$this->assertCount(3, $events);
$this->assertCount(2, $events['__section__']->getPeriods());
}
/**
* @expectedException \LogicException
*/
public function testReopenANewSectionShouldThrowAnException()
{
$stopwatch = new Stopwatch();
$stopwatch->openSection('section');
}
}

33
vendor/symfony/stopwatch/composer.json vendored Normal file
View File

@@ -0,0 +1,33 @@
{
"name": "symfony/stopwatch",
"type": "library",
"description": "Symfony Stopwatch Component",
"keywords": [],
"homepage": "https://symfony.com",
"license": "MIT",
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"require": {
"php": ">=5.3.9"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Stopwatch\\": "" },
"exclude-from-classmap": [
"/Tests/"
]
},
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
}
}
}

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
failOnRisky="true"
failOnWarning="true"
>
<php>
<ini name="error_reporting" value="-1" />
</php>
<testsuites>
<testsuite name="Symfony Stopwatch Component Test Suite">
<directory>./Tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>