mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 06:27:59 +01:00
Removed vendor
This commit is contained in:
parent
84f6064a1b
commit
148ffe97ec
1290 changed files with 0 additions and 227180 deletions
2303
composer.lock
generated
2303
composer.lock
generated
File diff suppressed because it is too large
Load diff
7
vendor/autoload.php
vendored
7
vendor/autoload.php
vendored
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
// autoload.php generated by Composer
|
||||
|
||||
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit97c5c8042cf61f3c9c7ef80776c5c224::getLoader();
|
7
vendor/bin/classpreloader.php
vendored
7
vendor/bin/classpreloader.php
vendored
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
SRC_DIR="`pwd`"
|
||||
cd "`dirname "$0"`"
|
||||
cd "../classpreloader/classpreloader"
|
||||
BIN_TARGET="`pwd`/classpreloader.php"
|
||||
cd "$SRC_DIR"
|
||||
"$BIN_TARGET" "$@"
|
3
vendor/bin/classpreloader.php.bat
vendored
3
vendor/bin/classpreloader.php.bat
vendored
|
@ -1,3 +0,0 @@
|
|||
@ECHO OFF
|
||||
SET BIN_TARGET=%~dp0\"../classpreloader/classpreloader"\classpreloader.php
|
||||
php "%BIN_TARGET%" %*
|
7
vendor/codescale/ffmpeg-php/.gitignore
vendored
7
vendor/codescale/ffmpeg-php/.gitignore
vendored
|
@ -1,7 +0,0 @@
|
|||
.svn
|
||||
.buildpath
|
||||
.project
|
||||
.settings
|
||||
*.swp
|
||||
/docs/*
|
||||
.idea
|
292
vendor/codescale/ffmpeg-php/FFmpegAnimatedGif.php
vendored
292
vendor/codescale/ffmpeg-php/FFmpegAnimatedGif.php
vendored
|
@ -1,292 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FFmpegAnimatedGif represents an animated gif object
|
||||
*
|
||||
* This class in implemented in rather un-orthodox way.
|
||||
* Reason is that ffmpeg doesn't provide satisfactory
|
||||
* quality and compression of animated gifs.
|
||||
*
|
||||
* Code fragments used from: GIFEncoder Version 2.0 by László Zsidi
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @package FFmpegPHP
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class FFmpegAnimatedGif implements Serializable {
|
||||
|
||||
/**
|
||||
* Location in the filesystem where the animated gif will be written.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $outFilePath;
|
||||
/**
|
||||
* Width of the animated gif.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $width;
|
||||
/**
|
||||
* Height of the animated gif.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $height;
|
||||
/**
|
||||
* Frame rate of the animated gif in frames per second.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $frameRate;
|
||||
/**
|
||||
* Number of times to loop the animation. Put a zero here to loop forever or omit this parameter to disable looping.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $loopCount;
|
||||
/**
|
||||
* Binary data of gif files to create animation
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $frames;
|
||||
/**
|
||||
* Gif binary data of animation
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $gifData;
|
||||
/**
|
||||
* Counter of first animation
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $counter;
|
||||
|
||||
/**
|
||||
* Create a new FFmpegAnimatedGif object
|
||||
*
|
||||
* @param string $outFilePath Location in the filesystem where the animated gif will be written.
|
||||
* @param int $width Width of the animated gif.
|
||||
* @param int $height Height of the animated gif.
|
||||
* @param int $frameRate Frame rate of the animated gif in frames per second.
|
||||
* @param int $loopCount Number of times to loop the animation. Put a zero here to loop forever or omit this parameter to disable looping.
|
||||
* @return FFmpegAnimatedGif
|
||||
*/
|
||||
public function __construct($outFilePath, $width, $height, $frameRate, $loopCount) {
|
||||
$this->outFilePath = $outFilePath;
|
||||
$this->width = $width;
|
||||
$this->height = $height;
|
||||
$this->frameRate = $frameRate;
|
||||
$this->loopCount = ($loopCount < -1) ? 0 : $loopCount;
|
||||
$this->frames = array();
|
||||
$this->counter = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a frame to the end of the animated gif.
|
||||
*
|
||||
* @param FFmpegFrame $frame frame to add
|
||||
* @return void
|
||||
*/
|
||||
public function addFrame(FFmpegFrame $frame) {
|
||||
$tmpFrame = clone $frame;
|
||||
$tmpFrame->resize($this->width, $this->height);
|
||||
ob_start();
|
||||
imagegif($tmpFrame->toGDImage());
|
||||
$this->frames[] = ob_get_clean();
|
||||
$tmpFrame = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding header to the animation
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function addGifHeader() {
|
||||
$cmap = 0;
|
||||
|
||||
if (ord($this->frames[0]{10}) & 0x80) {
|
||||
$cmap = 3 * (2 << (ord($this->frames[0]{10}) & 0x07));
|
||||
|
||||
$this->gifData = 'GIF89a';
|
||||
$this->gifData .= substr($this->frames[0], 6, 7);
|
||||
$this->gifData .= substr($this->frames[0], 13, $cmap);
|
||||
$this->gifData .= "!\377\13NETSCAPE2.0\3\1".$this->getGifWord($this->loopCount)."\0";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding frame binary data to the animation
|
||||
*
|
||||
* @param int $i index of frame from FFmpegAnimatedGif::frame array
|
||||
* @param int $d delay (5 seconds = 500 delay units)
|
||||
* @return void
|
||||
*/
|
||||
protected function addFrameData($i, $d) {
|
||||
$DIS = 2;
|
||||
$COL = 0;
|
||||
|
||||
$Locals_str = 13 + 3 * (2 << (ord($this->frames[$i]{10}) & 0x07));
|
||||
$Locals_end = strlen($this->frames[$i]) - $Locals_str - 1;
|
||||
$Locals_tmp = substr($this->frames[$i], $Locals_str, $Locals_end );
|
||||
|
||||
$Global_len = 2 << (ord($this->frames[0]{10}) & 0x07);
|
||||
$Locals_len = 2 << (ord($this->frames[$i]{10}) & 0x07);
|
||||
|
||||
$Global_rgb = substr($this->frames[0], 13, 3 * (2 << (ord($this->frames[0]{10}) & 0x07)));
|
||||
$Locals_rgb = substr($this->frames[$i], 13, 3 * (2 << (ord($this->frames[$i]{10}) & 0x07)));
|
||||
|
||||
$Locals_ext = "!\xF9\x04".chr(($DIS << 2 ) + 0). chr(($d >> 0) & 0xFF).chr(($d >> 8) & 0xFF)."\x0\x0";
|
||||
|
||||
if ($COL > -1 && ord($this->frames[$i]{10}) & 0x80) {
|
||||
for ($j = 0; $j < (2 << (ord($this->frames[$i]{10}) & 0x07)); $j++) {
|
||||
if (ord($Locals_rgb{3 * $j + 0}) == (($COL >> 16 ) & 0xFF)
|
||||
&& ord($Locals_rgb{3 * $j + 1}) == (($COL >> 8 ) & 0xFF)
|
||||
&& ord($Locals_rgb{3 * $j + 2}) == (($COL >> 0 ) & 0xFF)
|
||||
) {
|
||||
$Locals_ext = "!\xF9\x04".chr(($DIS << 2) + 1).chr(($d >> 0) & 0xFF).chr(($d >> 8) & 0xFF).chr($j)."\x0";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch ($Locals_tmp{0}) {
|
||||
case "!":
|
||||
$Locals_img = substr($Locals_tmp, 8, 10);
|
||||
$Locals_tmp = substr($Locals_tmp, 18, strlen($Locals_tmp) - 18);
|
||||
break;
|
||||
case ",":
|
||||
$Locals_img = substr($Locals_tmp, 0, 10);
|
||||
$Locals_tmp = substr($Locals_tmp, 10, strlen($Locals_tmp) - 10);
|
||||
break;
|
||||
}
|
||||
if (ord($this->frames[$i]{10}) & 0x80 && $this->counter > -1) {
|
||||
if ($Global_len == $Locals_len) {
|
||||
if ($this->gifBlockCompare($Global_rgb, $Locals_rgb, $Global_len)) {
|
||||
$this->gifData .= ($Locals_ext.$Locals_img.$Locals_tmp);
|
||||
}
|
||||
else {
|
||||
$byte = ord($Locals_img{9});
|
||||
$byte |= 0x80;
|
||||
$byte &= 0xF8;
|
||||
$byte |= (ord($this->frames[0]{10}) & 0x07);
|
||||
$Locals_img{9} = chr ($byte);
|
||||
$this->gifData .= ($Locals_ext.$Locals_img.$Locals_rgb.$Locals_tmp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$byte = ord($Locals_img{9});
|
||||
$byte |= 0x80;
|
||||
$byte &= 0xF8;
|
||||
$byte |= (ord($this->frames[$i]{10}) & 0x07);
|
||||
$Locals_img{9} = chr($byte);
|
||||
$this->gifData .= ($Locals_ext.$Locals_img.$Locals_rgb.$Locals_tmp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->gifData .= ($Locals_ext.$Locals_img.$Locals_tmp);
|
||||
}
|
||||
$this->counter = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding footer to the animation
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function addGifFooter() {
|
||||
$this->gifData .= ';';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gif integer wrapper
|
||||
*
|
||||
* @param int $int
|
||||
* @return string
|
||||
*/
|
||||
protected function getGifWord($int) {
|
||||
|
||||
return (chr($int & 0xFF).chr(($int >> 8 ) & 0xFF));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gif compare block
|
||||
*
|
||||
* @param string $GlobalBlock
|
||||
* @param string $LocalBlock
|
||||
* @param int $Len
|
||||
* @return int
|
||||
*/
|
||||
protected function gifBlockCompare($GlobalBlock, $LocalBlock, $Len) {
|
||||
for ($i = 0; $i < $Len; $i++) {
|
||||
if (
|
||||
$GlobalBlock{3 * $i + 0} != $LocalBlock {3 * $i + 0} ||
|
||||
$GlobalBlock{3 * $i + 1} != $LocalBlock {3 * $i + 1} ||
|
||||
$GlobalBlock{3 * $i + 2} != $LocalBlock {3 * $i + 2}
|
||||
) {
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saving animated gif to remote file
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function save() {
|
||||
// No images to proces
|
||||
if (count($this->frames) == 0) return false;
|
||||
|
||||
return (boolean) file_put_contents($this->outFilePath, $this->getAnimation(), LOCK_EX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting animation binary data
|
||||
*
|
||||
* @return string|boolean
|
||||
*/
|
||||
public function getAnimation() {
|
||||
// No images to proces
|
||||
if (count($this->frames) == 0) return false;
|
||||
|
||||
// Process images as animation
|
||||
$this->addGifHeader();
|
||||
for ($i = 0; $i < count($this->frames); $i++) {
|
||||
$this->addFrameData($i, (1 / $this->frameRate * 100));
|
||||
}
|
||||
$this->addGifFooter();
|
||||
|
||||
return $this->gifData;
|
||||
}
|
||||
|
||||
public function serialize() {
|
||||
return serialize(array(
|
||||
$this->outFilePath,
|
||||
$this->width,
|
||||
$this->height,
|
||||
$this->frameRate,
|
||||
$this->loopCount,
|
||||
$this->gifData,
|
||||
$this->frames,
|
||||
$this->counter
|
||||
));
|
||||
}
|
||||
|
||||
public function unserialize($serialized) {
|
||||
$data = unserialize($serialized);
|
||||
list(
|
||||
$this->outFilePath,
|
||||
$this->width,
|
||||
$this->height,
|
||||
$this->frameRate,
|
||||
$this->loopCount,
|
||||
$this->gifData,
|
||||
$this->frames,
|
||||
$this->counter
|
||||
) = $data;
|
||||
}
|
||||
}
|
63
vendor/codescale/ffmpeg-php/FFmpegAutoloader.php
vendored
63
vendor/codescale/ffmpeg-php/FFmpegAutoloader.php
vendored
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FFmpegAutoloader manages lazy autoloading of all FFmpegPHP components
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @package FFmpegPHP
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class FFmpegAutoloader {
|
||||
/**
|
||||
* Map of all required FFmpegPHP package files
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $classes;
|
||||
|
||||
protected static function initClasses() {
|
||||
if (self::$classes === null) {
|
||||
self::$classes = array(
|
||||
'FFmpegAnimatedGif' => 'FFmpegAnimatedGif.php',
|
||||
'FFmpegFrame' => 'FFmpegFrame.php',
|
||||
'FFmpegMovie' => 'FFmpegMovie.php',
|
||||
'ffmpeg_animated_gif' => 'adapter'.DIRECTORY_SEPARATOR.'ffmpeg_animated_gif.php',
|
||||
'ffmpeg_frame' => 'adapter'.DIRECTORY_SEPARATOR.'ffmpeg_frame.php',
|
||||
'ffmpeg_movie' => 'adapter'.DIRECTORY_SEPARATOR.'ffmpeg_movie.php',
|
||||
'OutputProvider' => 'provider'.DIRECTORY_SEPARATOR.'OutputProvider.php',
|
||||
'AbstractOutputProvider' => 'provider'.DIRECTORY_SEPARATOR.'AbstractOutputProvider.php',
|
||||
'FFmpegOutputProvider' => 'provider'.DIRECTORY_SEPARATOR.'FFmpegOutputProvider.php',
|
||||
'FFprobeOutputProvider' => 'provider'.DIRECTORY_SEPARATOR.'FFprobeOutputProvider.php',
|
||||
'StringOutputProvider' => 'provider'.DIRECTORY_SEPARATOR.'StringOutputProvider.php'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoloading mechanizm
|
||||
*
|
||||
* @param string $className name of the class to be loaded
|
||||
* @return boolean
|
||||
*/
|
||||
public static function autoload($className) {
|
||||
if (array_key_exists($className, self::$classes)) {
|
||||
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.self::$classes[$className];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registering autoloading mechanizm
|
||||
*/
|
||||
public static function register() {
|
||||
if (function_exists('__autoload')) {
|
||||
trigger_error('FFmpegPHP uses spl_autoload_register() which will bypass your __autoload() and may break your autoloading', E_USER_WARNING);
|
||||
} else {
|
||||
self::initClasses();
|
||||
spl_autoload_register(array('FFmpegAutoloader', 'autoload'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FFmpegAutoloader::register();
|
192
vendor/codescale/ffmpeg-php/FFmpegFrame.php
vendored
192
vendor/codescale/ffmpeg-php/FFmpegFrame.php
vendored
|
@ -1,192 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FFmpegFrame represents one frame from the movie
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @package FFmpegPHP
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class FFmpegFrame implements Serializable {
|
||||
|
||||
protected static $EX_CODE_NO_VALID_RESOURCE = 334563;
|
||||
|
||||
/**
|
||||
* GdImage binary data
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $gdImageData;
|
||||
/**
|
||||
* Presentation time stamp
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $pts;
|
||||
|
||||
/**
|
||||
* Frame width in pixels
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $width;
|
||||
|
||||
/**
|
||||
* Frame height in pixels
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $height;
|
||||
|
||||
/**
|
||||
* Create a FFmpegFrame object from a GD image.
|
||||
*
|
||||
* @param resource $gdImage image resource of type gd
|
||||
* @param float $pts frame presentation timestamp; OPTIONAL parameter; DEFAULT value 0.0
|
||||
* @throws Exception
|
||||
* @return FFmpegFrame
|
||||
*/
|
||||
public function __construct($gdImage, $pts = 0.0) {
|
||||
if (!(is_resource($gdImage) && get_resource_type($gdImage) == 'gd')) {
|
||||
throw new Exception('Param given by constructor is not valid gd resource', self::$EX_CODE_NO_VALID_RESOURCE);
|
||||
}
|
||||
|
||||
$this->gdImageData = $this->gdImageToBinaryData($gdImage);
|
||||
$this->width = imagesx($gdImage);
|
||||
$this->height = imagesy($gdImage);
|
||||
$this->pts = $pts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the width of the frame.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth() {
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the height of the frame.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHeight() {
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the presentation time stamp of the frame; alias $frame->getPresentationTimestamp()
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getPTS() {
|
||||
return $this->pts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the presentation time stamp of the frame.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getPresentationTimestamp() {
|
||||
return $this->getPTS();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize and optionally crop the frame. (Cropping is built into ffmpeg resizing so I'm providing it here for completeness.)
|
||||
*
|
||||
* * width - New width of the frame (must be an even number).
|
||||
* * height - New height of the frame (must be an even number).
|
||||
* * croptop - Remove [croptop] rows of pixels from the top of the frame.
|
||||
* * cropbottom - Remove [cropbottom] rows of pixels from the bottom of the frame.
|
||||
* * cropleft - Remove [cropleft] rows of pixels from the left of the frame.
|
||||
* * cropright - Remove [cropright] rows of pixels from the right of the frame.
|
||||
*
|
||||
*
|
||||
* NOTE: Cropping is always applied to the frame before it is resized. Crop values must be even numbers.
|
||||
*
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @param int $cropTop OPTIONAL parameter; DEFAULT value - 0
|
||||
* @param int $cropBottom OPTIONAL parameter; DEFAULT value - 0
|
||||
* @param int $cropLeft OPTIONAL parameter; DEFAULT value - 0
|
||||
* @param int $cropRight OPTIONAL parameter; DEFAULT value - 0
|
||||
* @return void
|
||||
*/
|
||||
public function resize($width, $height, $cropTop = 0, $cropBottom = 0, $cropLeft = 0, $cropRight = 0) {
|
||||
$widthCrop = ($cropLeft + $cropRight);
|
||||
$heightCrop = ($cropTop + $cropBottom);
|
||||
$width -= $widthCrop;
|
||||
$height -= $heightCrop;
|
||||
$resizedImage = imagecreatetruecolor($width, $height);
|
||||
$gdImage = $this->toGDImage();
|
||||
imagecopyresampled($resizedImage, $gdImage, 0, 0, $cropLeft, $cropTop, $width, $height, $this->getWidth() - $widthCrop, $this->getHeight() - $heightCrop);
|
||||
imageconvolution($resizedImage, array(
|
||||
array( -1, -1, -1 ),
|
||||
array( -1, 24, -1 ),
|
||||
array( -1, -1, -1 ),
|
||||
), 16, 0);
|
||||
|
||||
$this->gdImageData = $this->gdImageToBinaryData($resizedImage);
|
||||
$this->width = imagesx($resizedImage);
|
||||
$this->height = imagesy($resizedImage);
|
||||
imagedestroy($gdImage);
|
||||
imagedestroy($resizedImage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Crop the frame.
|
||||
*
|
||||
* * croptop - Remove [croptop] rows of pixels from the top of the frame.
|
||||
* * cropbottom - Remove [cropbottom] rows of pixels from the bottom of the frame.
|
||||
* * cropleft - Remove [cropleft] rows of pixels from the left of the frame.
|
||||
* * cropright - Remove [cropright] rows of pixels from the right of the frame.
|
||||
*
|
||||
* NOTE: Crop values must be even numbers.
|
||||
*
|
||||
* @param int $cropTop
|
||||
* @param int $cropBottom OPTIONAL parameter; DEFAULT value - 0
|
||||
* @param int $cropLeft OPTIONAL parameter; DEFAULT value - 0
|
||||
* @param int $cropRight OPTIONAL parameter; DEFAULT value - 0
|
||||
* @return void
|
||||
*/
|
||||
public function crop($cropTop, $cropBottom = 0, $cropLeft = 0, $cropRight = 0) {
|
||||
$this->resize($this->getWidth(), $this->getHeight(), $cropTop, $cropBottom, $cropLeft, $cropRight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a truecolor GD image of the frame.
|
||||
*
|
||||
* @return resource resource of type gd
|
||||
*/
|
||||
public function toGDImage() {
|
||||
return imagecreatefromstring($this->gdImageData);
|
||||
}
|
||||
|
||||
protected function gdImageToBinaryData($gdImage) {
|
||||
ob_start();
|
||||
imagegd2($gdImage);
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
public function serialize() {
|
||||
$data = array(
|
||||
$this->gdImageData,
|
||||
$this->pts,
|
||||
$this->width,
|
||||
$this->height
|
||||
);
|
||||
|
||||
return serialize($data);
|
||||
}
|
||||
|
||||
public function unserialize($serialized) {
|
||||
$data = unserialize($serialized);
|
||||
list($this->gdImageData,
|
||||
$this->pts,
|
||||
$this->width,
|
||||
$this->height
|
||||
) = $data;
|
||||
}
|
||||
}
|
765
vendor/codescale/ffmpeg-php/FFmpegMovie.php
vendored
765
vendor/codescale/ffmpeg-php/FFmpegMovie.php
vendored
|
@ -1,765 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FFmpegMovie represents a movie file
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @package FFmpegPHP
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class FFmpegMovie implements Serializable {
|
||||
|
||||
protected static $REGEX_DURATION = '/Duration: ([0-9]{2}):([0-9]{2}):([0-9]{2})(\.([0-9]+))?/';
|
||||
protected static $REGEX_FRAME_RATE = '/([0-9\.]+\sfps,\s)?([0-9\.]+)\stbr/';
|
||||
protected static $REGEX_COMMENT = '/comment\s*(:|=)\s*(.+)/i';
|
||||
protected static $REGEX_TITLE = '/title\s*(:|=)\s*(.+)/i';
|
||||
protected static $REGEX_ARTIST = '/(artist|author)\s*(:|=)\s*(.+)/i';
|
||||
protected static $REGEX_COPYRIGHT = '/copyright\s*(:|=)\s*(.+)/i';
|
||||
protected static $REGEX_GENRE = '/genre\s*(:|=)\s*(.+)/i';
|
||||
protected static $REGEX_TRACK_NUMBER = '/track\s*(:|=)\s*(.+)/i';
|
||||
protected static $REGEX_YEAR = '/year\s*(:|=)\s*(.+)/i';
|
||||
protected static $REGEX_FRAME_WH = '/Video:.+?([1-9][0-9]*)x([1-9][0-9]*)/';
|
||||
protected static $REGEX_PIXEL_FORMAT = '/Video: [^,]+, ([^,]+)/';
|
||||
protected static $REGEX_BITRATE = '/bitrate: ([0-9]+) kb\/s/';
|
||||
protected static $REGEX_VIDEO_BITRATE = '/Video:.+?([0-9]+) kb\/s/';
|
||||
protected static $REGEX_AUDIO_BITRATE = '/Audio:.+?([0-9]+) kb\/s/';
|
||||
protected static $REGEX_AUDIO_SAMPLE_RATE = '/Audio:.+?([0-9]+) Hz/';
|
||||
protected static $REGEX_VIDEO_CODEC = '/Video:\s([^,]+),/';
|
||||
protected static $REGEX_AUDIO_CODEC = '/Audio:\s([^,]+),/';
|
||||
protected static $REGEX_AUDIO_CHANNELS = '/Audio:\s[^,]+,[^,]+,([^,]+)/';
|
||||
protected static $REGEX_HAS_AUDIO = '/Stream.+Audio/';
|
||||
protected static $REGEX_HAS_VIDEO = '/Stream.+Video/';
|
||||
protected static $REGEX_ERRORS = '/.*(Error|Permission denied|could not seek to position|Invalid pixel format|Unknown encoder|could not find codec|does not contain any stream).*/i';
|
||||
|
||||
/**
|
||||
* FFmpeg binary
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $ffmpegBinary;
|
||||
/**
|
||||
* Output provider
|
||||
*
|
||||
* @var OutputProvider
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* Movie file path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $movieFile;
|
||||
|
||||
/**
|
||||
* provider output
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $output;
|
||||
|
||||
/**
|
||||
* Movie duration in seconds
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $duration;
|
||||
/**
|
||||
* Current frame index
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $frameCount;
|
||||
/**
|
||||
* Movie frame rate
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $frameRate;
|
||||
/**
|
||||
* Comment ID3 field
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $comment;
|
||||
/**
|
||||
* Title ID3 field
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
/**
|
||||
* Author ID3 field
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $artist;
|
||||
/**
|
||||
* Copyright ID3 field
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $copyright;
|
||||
/**
|
||||
* Genre ID3 field
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $genre;
|
||||
/**
|
||||
* Track ID3 field
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $trackNumber;
|
||||
/**
|
||||
* Year ID3 field
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $year;
|
||||
/**
|
||||
* Movie frame height
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $frameHeight;
|
||||
/**
|
||||
* Movie frame width
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $frameWidth;
|
||||
/**
|
||||
* Movie pixel format
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $pixelFormat;
|
||||
/**
|
||||
* Movie bit rate combined with audio bit rate
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $bitRate;
|
||||
/**
|
||||
* Movie video stream bit rate
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $videoBitRate;
|
||||
/**
|
||||
* Movie audio stream bit rate
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $audioBitRate;
|
||||
/**
|
||||
* Audio sample rate
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $audioSampleRate;
|
||||
/**
|
||||
* Current frame number
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $frameNumber;
|
||||
/**
|
||||
* Movie video cocec
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $videoCodec;
|
||||
/**
|
||||
* Movie audio coded
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $audioCodec;
|
||||
/**
|
||||
* Movie audio channels
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $audioChannels;
|
||||
|
||||
/**
|
||||
* Open a video or audio file and return it as an FFmpegMovie object.
|
||||
* If ffmpeg and ffprobe are both installed on host system, ffmpeg
|
||||
* gets priority in extracting info from the movie file. However
|
||||
* to override this default behaviour use any implementation of OutputProvider interface
|
||||
* as the second constructor argumentwhile instantiating
|
||||
*
|
||||
*
|
||||
* @param string $moviePath full path to the movie file
|
||||
* @param OutputProvider $outputProvider provides parsable output
|
||||
* @param string $ffmpegBinary ffmpeg executable, if $outputProvider not specified
|
||||
* @throws Exception
|
||||
* @return FFmpegMovie
|
||||
*/
|
||||
public function __construct($moviePath, OutputProvider $outputProvider = null, $ffmpegBinary = 'ffmpeg') {
|
||||
$this->movieFile = $moviePath;
|
||||
$this->frameNumber = 0;
|
||||
$this->ffmpegBinary = $ffmpegBinary;
|
||||
if ($outputProvider === null) {
|
||||
$outputProvider = new FFmpegOutputProvider($ffmpegBinary);
|
||||
}
|
||||
$this->setProvider($outputProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting provider implementation
|
||||
*
|
||||
* @param OutputProvider $outputProvider
|
||||
*/
|
||||
public function setProvider(OutputProvider $outputProvider) {
|
||||
$this->provider = $outputProvider;
|
||||
$this->provider->setMovieFile($this->movieFile);
|
||||
$this->output = $this->provider->getOutput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting current provider implementation
|
||||
*
|
||||
* @return OutputProvider
|
||||
*/
|
||||
public function getProvider() {
|
||||
return $this->provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the duration of a movie or audio file in seconds.
|
||||
*
|
||||
* @return float movie duration in seconds
|
||||
*/
|
||||
public function getDuration() {
|
||||
if ($this->duration === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_DURATION, $this->output, $match);
|
||||
if (array_key_exists(1, $match) && array_key_exists(2, $match) && array_key_exists(3, $match)) {
|
||||
$hours = (int) $match[1];
|
||||
$minutes = (int) $match[2];
|
||||
$seconds = (int) $match[3];
|
||||
$fractions = (float) ((array_key_exists(5, $match)) ? "0.$match[5]" : 0.0);
|
||||
|
||||
$this->duration = (($hours * (3600)) + ($minutes * 60) + $seconds + $fractions);
|
||||
} else {
|
||||
$this->duration = 0.0;
|
||||
}
|
||||
|
||||
return $this->duration;
|
||||
}
|
||||
|
||||
return $this->duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of frames in a movie or audio file.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getFrameCount() {
|
||||
if ($this->frameCount === null) {
|
||||
$this->frameCount = (int) ($this->getDuration() * $this->getFrameRate());
|
||||
}
|
||||
|
||||
return $this->frameCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the frame rate of a movie in fps.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getFrameRate() {
|
||||
if ($this->frameRate === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_FRAME_RATE, $this->output, $match);
|
||||
$this->frameRate = (float) ((array_key_exists(1, $match)) ? $match[1] : 0.0);
|
||||
}
|
||||
|
||||
return $this->frameRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path and name of the movie file or audio file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFilename() {
|
||||
return $this->movieFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the comment field from the movie or audio file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getComment() {
|
||||
if ($this->comment === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_COMMENT, $this->output, $match);
|
||||
$this->comment = (array_key_exists(2, $match)) ? trim($match[2]) : '';
|
||||
}
|
||||
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the title field from the movie or audio file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
if ($this->title === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_TITLE, $this->output, $match);
|
||||
$this->title = (array_key_exists(2, $match)) ? trim($match[2]) : '';
|
||||
}
|
||||
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the author field from the movie or the artist ID3 field from an mp3 file; alias $movie->getArtist()
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getArtist() {
|
||||
if ($this->artist === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_ARTIST, $this->output, $match);
|
||||
$this->artist = (array_key_exists(3, $match)) ? trim($match[3]) : '';
|
||||
}
|
||||
|
||||
return $this->artist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the author field from the movie or the artist ID3 field from an mp3 file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthor() {
|
||||
return $this->getArtist();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the copyright field from the movie or audio file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCopyright() {
|
||||
if ($this->copyright === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_COPYRIGHT, $this->output, $match);
|
||||
$this->copyright = (array_key_exists(2, $match)) ? trim($match[2]) : '';
|
||||
}
|
||||
|
||||
return $this->copyright;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the genre ID3 field from an mp3 file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGenre() {
|
||||
if ($this->genre === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_GENRE, $this->output, $match);
|
||||
$this->genre = (array_key_exists(2, $match)) ? trim($match[2]) : '';
|
||||
}
|
||||
|
||||
return $this->genre;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the track ID3 field from an mp3 file.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTrackNumber() {
|
||||
if ($this->trackNumber === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_TRACK_NUMBER, $this->output, $match);
|
||||
$this->trackNumber = (int) ((array_key_exists(2, $match)) ? $match[2] : 0);
|
||||
}
|
||||
|
||||
return $this->trackNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the year ID3 field from an mp3 file.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getYear() {
|
||||
if ($this->year === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_YEAR, $this->output, $match);
|
||||
$this->year = (int) ((array_key_exists(2, $match)) ? $match[2] : 0);
|
||||
}
|
||||
|
||||
return $this->year;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the height of the movie in pixels.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getFrameHeight() {
|
||||
if ($this->frameHeight == null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_FRAME_WH, $this->output, $match);
|
||||
if (array_key_exists(1, $match) && array_key_exists(2, $match)) {
|
||||
$this->frameWidth = (int) $match[1];
|
||||
$this->frameHeight = (int) $match[2];
|
||||
} else {
|
||||
$this->frameWidth = 0;
|
||||
$this->frameHeight = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->frameHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the width of the movie in pixels.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getFrameWidth() {
|
||||
if ($this->frameWidth === null) {
|
||||
$this->getFrameHeight();
|
||||
}
|
||||
|
||||
return $this->frameWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the pixel format of the movie.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPixelFormat() {
|
||||
if ($this->pixelFormat === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_PIXEL_FORMAT, $this->output, $match);
|
||||
$this->pixelFormat = (array_key_exists(1, $match)) ? trim($match[1]) : '';
|
||||
}
|
||||
|
||||
return $this->pixelFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the bit rate of the movie or audio file in bits per second.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBitRate() {
|
||||
if ($this->bitRate === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_BITRATE, $this->output, $match);
|
||||
$this->bitRate = (int) ((array_key_exists(1, $match)) ? ($match[1] * 1000) : 0);
|
||||
}
|
||||
|
||||
return $this->bitRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the bit rate of the video in bits per second.
|
||||
*
|
||||
* NOTE: This only works for files with constant bit rate.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getVideoBitRate() {
|
||||
if ($this->videoBitRate === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_VIDEO_BITRATE, $this->output, $match);
|
||||
$this->videoBitRate = (int) ((array_key_exists(1, $match)) ? ($match[1] * 1000) : 0);
|
||||
}
|
||||
|
||||
return $this->videoBitRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the audio bit rate of the media file in bits per second.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAudioBitRate() {
|
||||
if ($this->audioBitRate === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_AUDIO_BITRATE, $this->output, $match);
|
||||
$this->audioBitRate = (int) ((array_key_exists(1, $match)) ? ($match[1] * 1000) : 0);
|
||||
}
|
||||
|
||||
return $this->audioBitRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the audio sample rate of the media file in bits per second.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAudioSampleRate() {
|
||||
if ($this->audioSampleRate === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_AUDIO_SAMPLE_RATE, $this->output, $match);
|
||||
$this->audioSampleRate = (int) ((array_key_exists(1, $match)) ? $match[1] : 0);
|
||||
}
|
||||
|
||||
return $this->audioSampleRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current frame index.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getFrameNumber() {
|
||||
return ($this->frameNumber == 0) ? 1 : $this->frameNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the video codec used to encode this movie as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVideoCodec() {
|
||||
if ($this->videoCodec === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_VIDEO_CODEC, $this->output, $match);
|
||||
$this->videoCodec = (array_key_exists(1, $match)) ? trim($match[1]) : '';
|
||||
}
|
||||
|
||||
return $this->videoCodec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the audio codec used to encode this movie as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAudioCodec() {
|
||||
if ($this->audioCodec === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_AUDIO_CODEC, $this->output, $match);
|
||||
$this->audioCodec = (array_key_exists(1, $match)) ? trim($match[1]) : '';
|
||||
}
|
||||
|
||||
return $this->audioCodec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of audio channels in this movie as an integer.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAudioChannels() {
|
||||
if ($this->audioChannels === null) {
|
||||
$match = array();
|
||||
preg_match(self::$REGEX_AUDIO_CHANNELS, $this->output, $match);
|
||||
if (array_key_exists(1, $match)) {
|
||||
switch (trim($match[1])) {
|
||||
case 'mono':
|
||||
$this->audioChannels = 1; break;
|
||||
case 'stereo':
|
||||
$this->audioChannels = 2; break;
|
||||
case '5.1':
|
||||
$this->audioChannels = 6; break;
|
||||
case '5:1':
|
||||
$this->audioChannels = 6; break;
|
||||
default:
|
||||
$this->audioChannels = (int) $match[1];
|
||||
}
|
||||
} else {
|
||||
$this->audioChannels = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->audioChannels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return boolean value indicating whether the movie has an audio stream.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasAudio() {
|
||||
return (boolean) preg_match(self::$REGEX_HAS_AUDIO, $this->output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return boolean value indicating whether the movie has a video stream.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasVideo() {
|
||||
return (boolean) preg_match(self::$REGEX_HAS_VIDEO, $this->output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a frame from the movie as an FFmpegFrame object. Returns false if the frame was not found.
|
||||
*
|
||||
* * framenumber - Frame from the movie to return. If no framenumber is specified, returns the next frame of the movie.
|
||||
*
|
||||
* @param int $framenumber
|
||||
* @param int $height
|
||||
* @param int $width
|
||||
* @param int $quality
|
||||
* @return FFmpegFrame|boolean
|
||||
*/
|
||||
public function getFrame($framenumber = null, $height = null, $width = null, $quality = null) {
|
||||
$framePos = ($framenumber === null) ? $this->frameNumber : (((int) $framenumber) - 1);
|
||||
|
||||
// Frame position out of range
|
||||
if (!is_numeric($framePos) || $framePos < 0 || $framePos > $this->getFrameCount()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$frameTime = round((($framePos / $this->getFrameCount()) * $this->getDuration()), 4);
|
||||
|
||||
$frame = $this->getFrameAtTime($frameTime, $height, $width, $quality);
|
||||
|
||||
// Increment internal frame number
|
||||
if ($framenumber === null) {
|
||||
++$this->frameNumber;
|
||||
}
|
||||
|
||||
return $frame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a frame from the movie as an FFmpegFrame object. Returns false if the frame was not found.
|
||||
*
|
||||
* @param float $seconds
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @param int $quality
|
||||
* @param string $frameFilePath
|
||||
* @param array $output
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return FFmpegFrame|boolean
|
||||
*
|
||||
*/
|
||||
public function getFrameAtTime($seconds = null, $width = null, $height = null, $quality = null, $frameFilePath = null, &$output = null) {
|
||||
// Set frame position for frame extraction
|
||||
$frameTime = ($seconds === null) ? 0 : $seconds;
|
||||
|
||||
// time out of range
|
||||
if (!is_numeric($frameTime) || $frameTime < 0 || $frameTime > $this->getDuration()) {
|
||||
throw(new Exception('Frame time is not in range '.$frameTime.'/'.$this->getDuration().' '.$this->getFilename()));
|
||||
}
|
||||
|
||||
if(is_numeric($height) && is_numeric($width)) {
|
||||
$image_size = ' -s '.$width.'x'.$height;
|
||||
} else {
|
||||
$image_size = '';
|
||||
}
|
||||
|
||||
if(is_numeric($quality)) {
|
||||
$quality = ' -qscale '.$quality;
|
||||
} else {
|
||||
$quality = '';
|
||||
}
|
||||
|
||||
$deleteTmp = false;
|
||||
if ($frameFilePath === null) {
|
||||
$frameFilePath = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('frame', true).'.jpg';
|
||||
$deleteTmp = true;
|
||||
}
|
||||
|
||||
$output = array();
|
||||
|
||||
// Fast and accurate way to seek. First quick-seek before input up to
|
||||
// a point just before the frame, and then accurately seek after input
|
||||
// to the exact point.
|
||||
// See: http://ffmpeg.org/trac/ffmpeg/wiki/Seeking%20with%20FFmpeg
|
||||
if ($frameTime > 30) {
|
||||
$seek1 = $frameTime - 30;
|
||||
$seek2 = 30;
|
||||
} else {
|
||||
$seek1 = 0;
|
||||
$seek2 = $frameTime;
|
||||
}
|
||||
|
||||
exec(implode(' ', array(
|
||||
$this->ffmpegBinary,
|
||||
'-ss '.$seek1,
|
||||
'-i '.escapeshellarg($this->movieFile),
|
||||
'-f image2',
|
||||
'-ss '.$seek2,
|
||||
'-vframes 1',
|
||||
$image_size,
|
||||
$quality,
|
||||
escapeshellarg($frameFilePath),
|
||||
'2>&1',
|
||||
)), $output, $retVar);
|
||||
$output = join(PHP_EOL, $output);
|
||||
|
||||
// Cannot write frame to the data storage
|
||||
if (!file_exists($frameFilePath)) {
|
||||
// Find error in output
|
||||
preg_match(self::$REGEX_ERRORS, $output, $errors);
|
||||
if ($errors) {
|
||||
throw new Exception($errors[0]);
|
||||
}
|
||||
// Default file not found error
|
||||
throw new Exception('TMP image not found/written '. $frameFilePath);
|
||||
}
|
||||
|
||||
// Create gdimage and delete temporary image
|
||||
$gdImage = imagecreatefromjpeg($frameFilePath);
|
||||
if ($deleteTmp && is_writable($frameFilePath)) {
|
||||
unlink($frameFilePath);
|
||||
}
|
||||
|
||||
$frame = new FFmpegFrame($gdImage, $frameTime);
|
||||
imagedestroy($gdImage);
|
||||
|
||||
return $frame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next key frame from the movie as an FFmpegFrame object. Returns false if the frame was not found.
|
||||
*
|
||||
* @return FFmpegFrame|boolean
|
||||
*/
|
||||
public function getNextKeyFrame() {
|
||||
return $this->getFrame();
|
||||
}
|
||||
|
||||
public function __clone() {
|
||||
$this->provider = clone $this->provider;
|
||||
}
|
||||
|
||||
public function serialize() {
|
||||
$data = serialize(array(
|
||||
$this->ffmpegBinary,
|
||||
$this->movieFile,
|
||||
$this->output,
|
||||
$this->frameNumber,
|
||||
$this->provider
|
||||
));
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function unserialize($serialized) {
|
||||
list($this->ffmpegBinary,
|
||||
$this->movieFile,
|
||||
$this->output,
|
||||
$this->frameNumber,
|
||||
$this->provider
|
||||
) = unserialize($serialized);
|
||||
|
||||
}
|
||||
}
|
26
vendor/codescale/ffmpeg-php/LICENSE
vendored
26
vendor/codescale/ffmpeg-php/LICENSE
vendored
|
@ -1,26 +0,0 @@
|
|||
The New BSD License
|
||||
|
||||
Copyright (c) 2011-2013, CodeScale s.r.o.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of CodeScale s.r.o. nor the names of its contributors
|
||||
may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
96
vendor/codescale/ffmpeg-php/README.rst
vendored
96
vendor/codescale/ffmpeg-php/README.rst
vendored
|
@ -1,96 +0,0 @@
|
|||
FFmpegPHP 2.7.0
|
||||
===============
|
||||
|
||||
FFmpegPHP is a pure OO PHP port of ffmpeg-php (written in C). It adds an easy to use,
|
||||
object-oriented API for accessing and retrieving information from video and audio files.
|
||||
It has methods for returning frames from movie files as images that can be manipulated
|
||||
using PHP image functions. This works well for automatically creating thumbnail images from movies.
|
||||
FFmpegPHP is also useful for reporting the duration and bitrate of audio files (mp3, wma...).
|
||||
FFmpegPHP can access many of the video formats supported by ffmpeg (mov, avi, mpg, wmv...)
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
- PHP 5.3 and higher
|
||||
- ffmpeg or ffprobe
|
||||
|
||||
|
||||
Tests
|
||||
-----
|
||||
|
||||
**Tested environment**
|
||||
|
||||
- Xubuntu Linux 12.04.2 LTS precise 64-bit
|
||||
- ffmpeg version N-37798-gcd1c12b
|
||||
- PHPUnit 3.7.18
|
||||
- PHP 5.3.10
|
||||
|
||||
|
||||
**Running tests**
|
||||
|
||||
To run the test install phpunit (http://www.phpunit.de/) and run: ::
|
||||
|
||||
$ phpunit --bootstrap test/bootstrap.php test/
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
You can easily install FFmpegPHP via PEAR framework: ::
|
||||
|
||||
$ sudo pear channel-discover pear.codescale.net
|
||||
$ sudo pear install codescale/FFmpegPHP2
|
||||
|
||||
or download package from github.com: ::
|
||||
|
||||
$ wget http://github.com/char0n/ffmpeg-php/tarball/master
|
||||
|
||||
or to install via composer (http://getcomposer.org/) place the following in your composer.json file: ::
|
||||
|
||||
{
|
||||
"require": {
|
||||
"codescale/ffmpeg-php": "dev-master"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Using FFmpegPHP
|
||||
---------------
|
||||
|
||||
Package installed via PEAR channel: ::
|
||||
|
||||
require_once 'FFmpegPHP2/FFmpegAutoloader.php';
|
||||
|
||||
Package downloaded from github.com and unpacked into certain directory: ::
|
||||
|
||||
require_once 'PATH_TO_YOUR_DIRECTORY/FFmpegAutoloader.php';
|
||||
|
||||
|
||||
Author
|
||||
------
|
||||
|
||||
| char0n (Vladimír Gorej, CodeScale s.r.o.)
|
||||
| email: gorej@codescale.net
|
||||
| web: http://www.codescale.net
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
FFmpegPHP documentation can be build from source code
|
||||
using PhpDocumentor with following commnad: ::
|
||||
|
||||
$ phpdoc -o HTML:Smarty:HandS -d . -t docs
|
||||
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
- http://github.com/CodeScaleInc/ffmpeg-php
|
||||
- http://www.phpclasses.org/package/5977-PHP-Manipulate-video-files-using-the-ffmpeg-program.html
|
||||
- http://freshmeat.net/projects/ffmpegphp
|
||||
- http://www.codescale.net/en/community/#ffmpegphp
|
||||
- http://pear.codescale.net/
|
||||
- http://www.phpdoc.org/
|
||||
- http://www.phpunit.de/
|
||||
- http://pear.php.net/
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* ffmpeg_animated_gif serves as a compatiblity adapter for old ffmpeg-php extension
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @package FFmpegPHP
|
||||
* @subpackage adapter
|
||||
* @link http://ffmpeg-php.sourceforge.net/doc/api/ffmpeg_animated_gif.php
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class ffmpeg_animated_gif {
|
||||
|
||||
protected $adaptee;
|
||||
|
||||
public function __construct($outFilePath, $width, $height, $frameRate, $loopCount) {
|
||||
$this->adaptee = new FFmpegAnimatedGif($outFilePath, $width, $height, $frameRate, $loopCount);
|
||||
}
|
||||
|
||||
public function addFrame(ffmpeg_frame $frame) {
|
||||
$this->adaptee->addFrame(new FFmpegFrame($frame->toGDImage(), $frame->getPTS()));
|
||||
return $this->adaptee->save();
|
||||
}
|
||||
|
||||
public function __clone() {
|
||||
$this->adaptee = clone $this->adaptee;
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
$this->adaptee = null;
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* ffmpeg_frame serves as a compatiblity adapter for old ffmpeg-php extension
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @package FFmpegPHP
|
||||
* @subpackage adapter
|
||||
* @link http://ffmpeg-php.sourceforge.net/doc/api/ffmpeg_frame.php
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class ffmpeg_frame {
|
||||
|
||||
protected $adaptee;
|
||||
|
||||
public function __construct($gdImage, $pts = 0.0) {
|
||||
$this->adaptee = new FFmpegFrame($gdImage, $pts);
|
||||
}
|
||||
|
||||
public function getWidth() {
|
||||
return $this->adaptee->getWidth();
|
||||
}
|
||||
|
||||
public function getHeight() {
|
||||
return $this->adaptee->getHeight();
|
||||
}
|
||||
|
||||
public function getPTS() {
|
||||
return $this->adaptee->getPTS();
|
||||
}
|
||||
|
||||
public function getPresentationTimestamp() {
|
||||
return $this->adaptee->getPresentationTimestamp();
|
||||
}
|
||||
|
||||
public function resize($width, $height, $cropTop = 0, $cropBottom = 0, $cropLeft = 0, $cropRight = 0) {
|
||||
return $this->adaptee->resize($width, $height, $cropTop, $cropBottom, $cropLeft, $cropRight);
|
||||
}
|
||||
|
||||
public function crop($cropTop, $cropBottom = 0, $cropLeft = 0, $cropRight = 0) {
|
||||
return $this->adaptee->crop($cropTop, $cropBottom, $cropLeft, $cropRight);
|
||||
}
|
||||
|
||||
public function toGDImage() {
|
||||
return $this->adaptee->toGDImage();
|
||||
}
|
||||
|
||||
public function __clone() {
|
||||
$this->adaptee = clone $this->adaptee;
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
$this->adaptee = null;
|
||||
}
|
||||
}
|
149
vendor/codescale/ffmpeg-php/adapter/ffmpeg_movie.php
vendored
149
vendor/codescale/ffmpeg-php/adapter/ffmpeg_movie.php
vendored
|
@ -1,149 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* ffmpeg_movie serves as a compatiblity adapter for old ffmpeg-php extension
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @package FFmpegPHP
|
||||
* @subpackage adapter
|
||||
* @link http://ffmpeg-php.sourceforge.net/doc/api/ffmpeg_movie.php
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class ffmpeg_movie {
|
||||
|
||||
protected $adaptee;
|
||||
|
||||
public function __construct($moviePath, $persistent = false) {
|
||||
$this->adaptee = new FFmpegMovie($moviePath, new FFmpegOutputProvider('ffmpeg', $persistent));
|
||||
}
|
||||
|
||||
public function getDuration() {
|
||||
return $this->adaptee->getDuration();
|
||||
}
|
||||
|
||||
public function getFrameCount() {
|
||||
return $this->adaptee->getFrameCount();
|
||||
}
|
||||
|
||||
public function getFrameRate() {
|
||||
return $this->adaptee->getFrameRate();
|
||||
}
|
||||
|
||||
public function getFilename() {
|
||||
return $this->adaptee->getFilename();
|
||||
}
|
||||
|
||||
public function getComment() {
|
||||
return $this->adaptee->getComment();
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
return $this->adaptee->getTitle();
|
||||
}
|
||||
|
||||
public function getArtist() {
|
||||
return $this->adaptee->getArtist();
|
||||
}
|
||||
|
||||
public function getAuthor() {
|
||||
return $this->adaptee->getAuthor();
|
||||
}
|
||||
|
||||
public function getCopyright() {
|
||||
return $this->adaptee->getCopyright();
|
||||
}
|
||||
|
||||
public function getGenre() {
|
||||
return $this->adaptee->getGenre();
|
||||
}
|
||||
|
||||
public function getTrackNumber() {
|
||||
return $this->adaptee->getTrackNumber();
|
||||
}
|
||||
|
||||
public function getYear() {
|
||||
return $this->adaptee->getYear();
|
||||
}
|
||||
|
||||
public function getFrameHeight() {
|
||||
return $this->adaptee->getFrameHeight();
|
||||
}
|
||||
|
||||
public function getFrameWidth() {
|
||||
return $this->adaptee->getFrameWidth();
|
||||
}
|
||||
|
||||
public function getPixelFormat() {
|
||||
return $this->adaptee->getPixelFormat();
|
||||
}
|
||||
|
||||
public function getBitRate() {
|
||||
return $this->adaptee->getBitRate();
|
||||
}
|
||||
|
||||
public function getVideoBitRate() {
|
||||
return $this->adaptee->getVideoBitRate();
|
||||
}
|
||||
|
||||
public function getAudioBitRate() {
|
||||
return $this->adaptee->getAudioBitRate();
|
||||
}
|
||||
|
||||
public function getAudioSampleRate() {
|
||||
return $this->adaptee->getAudioSampleRate();
|
||||
}
|
||||
|
||||
public function getFrameNumber() {
|
||||
return $this->adaptee->getFrameNumber();
|
||||
}
|
||||
|
||||
public function getVideoCodec() {
|
||||
return $this->adaptee->getVideoCodec();
|
||||
}
|
||||
|
||||
public function getAudioCodec() {
|
||||
return $this->adaptee->getAudioCodec();
|
||||
}
|
||||
|
||||
public function getAudioChannels() {
|
||||
return $this->adaptee->getAudioChannels();
|
||||
}
|
||||
|
||||
public function hasAudio() {
|
||||
return $this->adaptee->hasAudio();
|
||||
}
|
||||
|
||||
public function hasVideo() {
|
||||
return $this->adaptee->hasVideo();
|
||||
}
|
||||
|
||||
public function getFrame($framenumber = null) {
|
||||
$toReturn = null;
|
||||
$frame = $this->adaptee->getFrame($framenumber);
|
||||
if ($frame != null) {
|
||||
$toReturn = new ffmpeg_frame($frame->toGDImage(), $frame->getPTS());
|
||||
$frame = null;
|
||||
}
|
||||
|
||||
return $toReturn;
|
||||
}
|
||||
|
||||
public function getNextKeyFrame() {
|
||||
$toReturn = null;
|
||||
$frame = $this->adaptee->getNextKeyFrame();
|
||||
if ($frame != null) {
|
||||
$toReturn = new ffmpeg_frame($frame->toGDImage(), $frame->getPTS());
|
||||
$frame = null;
|
||||
}
|
||||
|
||||
return $toReturn;
|
||||
}
|
||||
|
||||
public function __clone() {
|
||||
$this->adaptee = clone $this->adaptee;
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
$this->adaptee = null;
|
||||
}
|
||||
}
|
23
vendor/codescale/ffmpeg-php/composer.json
vendored
23
vendor/codescale/ffmpeg-php/composer.json
vendored
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"name": "codescale/ffmpeg-php",
|
||||
"type": "library",
|
||||
"description": "PHP wrapper for FFmpeg application",
|
||||
"version": "2.7.0",
|
||||
"keywords": ["ffmpeg", "video", "audio"],
|
||||
"homepage": "http://freecode.com/projects/ffmpegphp",
|
||||
"license": "New BSD",
|
||||
"authors": [
|
||||
{
|
||||
"name": "char0n (Vladimír Gorej, CodeScale s.r.o.)",
|
||||
"email": "gorej@codescale.net",
|
||||
"homepage": "http://www.codescale.net/",
|
||||
"role": "Development lead"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": ["."]
|
||||
}
|
||||
}
|
150
vendor/codescale/ffmpeg-php/package.xml
vendored
150
vendor/codescale/ffmpeg-php/package.xml
vendored
|
@ -1,150 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<package packagerversion="1.9.2" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
|
||||
http://pear.php.net/dtd/tasks-1.0.xsd
|
||||
http://pear.php.net/dtd/package-2.0
|
||||
http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<name>FFmpegPHP2</name>
|
||||
<channel>pear.codescale.net</channel>
|
||||
<summary>Manipulate video files using the ffmpeg program</summary>
|
||||
<description>FFmpegPHP is a pure OO PHP port of ffmpeg-php writter in C. It adds an easy to use, object-oriented API for accessing and retrieving information from video and audio files. It has methods for returning frames from movie files as images that can be manipulated using PHP&apos;s image functions. This works well for automatically creating thumbnail images from movies. FFmpegPHP is also useful for reporting the duration and bitrate of audio files (mp3, wma...). FFmpegPHP can access many of the video formats supported by ffmpeg (mov, avi, mpg, wmv...)</description>
|
||||
<lead>
|
||||
<name>Vladimír Gorej</name>
|
||||
<user>char0n</user>
|
||||
<email>gorej@codescale.net</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<date>2012-02-12</date>
|
||||
<time>19:49:12</time>
|
||||
<version>
|
||||
<release>2.6.2.1</release>
|
||||
<api>2.6</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license>
|
||||
<notes>
|
||||
Removed php ending tags from php files
|
||||
Support for latest ffmpeg
|
||||
Tons of fixes and enhancements
|
||||
</notes>
|
||||
<contents>
|
||||
<dir baseinstalldir="FFmpegPHP2" name="/">
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="c6ce75ee0150e5cbb8137a9d21a2b63d" name="adapter/ffmpeg_animated_gif.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="6cc9c7e25224dd133bc860ec452c4665" name="adapter/ffmpeg_frame.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="5ce9010f166601289866d613b9e55159" name="adapter/ffmpeg_movie.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="0fc94a8fb2cadaf4e33e2130a5af9baa" name="docs/classtrees_FFmpegPHP.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="42b8b7563dcd72cde6ce98228ed58097" name="docs/elementindex.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="bbe296f7c5314ae84fb9f7030c9ab95f" name="docs/elementindex_FFmpegPHP.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="014611007691e989499111e36b38d96a" name="docs/errors.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="a4c82b4368cde0584a4542facf734125" name="docs/index.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="a4c82b4368cde0584a4542facf734125" name="docs/li_FFmpegPHP.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="d128a66fcdcd68fb144b48a99686d533" name="docs/FFmpegPHP/FFmpegAnimatedGif.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="968c47705eaa90b5b97868a82c0228b7" name="docs/FFmpegPHP/FFmpegAnimatedGifTest.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="a74eae488f9ff483ed701d3afa3a3807" name="docs/FFmpegPHP/FFmpegAutoloader.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="d9e0a16601862a6d0e7a9a479f5eb4d5" name="docs/FFmpegPHP/FFmpegAutoloaderTest.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="8369ce1ac63d6c9bf378b36108c87a13" name="docs/FFmpegPHP/FFmpegFrame.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="b8a2ae351b479198afbb77a451b1293f" name="docs/FFmpegPHP/FFmpegFrameTest.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="89d87fd2d4b6455940db68bc0faeabd1" name="docs/FFmpegPHP/FFmpegMovie.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="8eaa89d465c402aa928724089593db39" name="docs/FFmpegPHP/FFmpegMovieTest.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="46ddaa2aa8d292ddcf1d6f15aefad14d" name="docs/FFmpegPHP/_FFmpegAnimatedGif.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="86180a3b6c0a6dc9fffc1c8e56b8ff87" name="docs/FFmpegPHP/_FFmpegAutoloader.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="a1e0f5a370261482b3599ae0c2824bce" name="docs/FFmpegPHP/_FFmpegFrame.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="d243eb1896031b96bd13f16f3bb15f23" name="docs/FFmpegPHP/_FFmpegMovie.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="e809d36aaab0a23c78814c1d7a3a392f" name="docs/FFmpegPHP/_test---bootstrap.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="eb1f572aaab71fe0c6a648f0ca48ec44" name="docs/FFmpegPHP/_test---FFmpegAnimatedGifTest.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="fc6334662387fdba784001305a644238" name="docs/FFmpegPHP/_test---FFmpegAutoloaderTest.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="20de88b639a4916c749a93927c6a9e04" name="docs/FFmpegPHP/_test---FFmpegFrameTest.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="0c966a72ca4734ab2af19881189bca34" name="docs/FFmpegPHP/_test---FFmpegMovieTest.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="862fe6c3feab078dd03d4614bbcf08d5" name="docs/FFmpegPHP/adapter/ffmpeg_animated_gif.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="147e2d5c3958b4e61df70a408511c2fc" name="docs/FFmpegPHP/adapter/ffmpeg_animated_git_test.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="5369a180dfa7a9c67e4efb349a3d07e5" name="docs/FFmpegPHP/adapter/ffmpeg_frame.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="33df762a0fbc370fdf7dd215d455c349" name="docs/FFmpegPHP/adapter/ffmpeg_frame_test.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="6391a48d4c522bbcbc7d0c76c7d47183" name="docs/FFmpegPHP/adapter/ffmpeg_movie.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="b510dc9e9bdc5d2c3a107a0c08f7b6bf" name="docs/FFmpegPHP/adapter/ffmpeg_movie_test.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="52f541f35563ce63c70fbafc91828c64" name="docs/FFmpegPHP/adapter/_adapter---ffmpeg_animated_gif.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="3b67d0e03ea4393149238a160acb8038" name="docs/FFmpegPHP/adapter/_adapter---ffmpeg_frame.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="7688f294a865ed85e4e53bdb0ece7d60" name="docs/FFmpegPHP/adapter/_adapter---ffmpeg_movie.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="82ce261220ef72ed47ffce2d2ec298f2" name="docs/FFmpegPHP/adapter/_test---adapter---ffmpeg_animated_gif_Test.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="e14fa2963c7bfcccb91e798b48a5a1b4" name="docs/FFmpegPHP/adapter/_test---adapter---ffmpeg_frame_Test.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="ce7db18a1470aefbf30982937ef682e8" name="docs/FFmpegPHP/adapter/_test---adapter---ffmpeg_movie_Test.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="74681eabf62c27360ac55ca25949c2b9" name="docs/FFmpegPHP/provider/AbstractOutputProvider.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="0a10ce37cb71e289fcbb3ca1cb580e53" name="docs/FFmpegPHP/provider/FFmpegOutputProvider.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="74a1e44ebbf1adffcf48254d002c3999" name="docs/FFmpegPHP/provider/FFmpegOutputProviderTest.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="6fc34ba259ee341007716b9ba249e544" name="docs/FFmpegPHP/provider/FFprobeOutputProvider.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="121199ff72039c155c70744e4c3280c8" name="docs/FFmpegPHP/provider/FFprobeOutputProviderTest.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="6b0864617f24b156a95ab52ff383c83d" name="docs/FFmpegPHP/provider/OutputProvider.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="8871acc0aaa4248ae5b19088b7ce0d79" name="docs/FFmpegPHP/provider/StringOutputProvider.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="48c69da79f28259189faa33ac7dd8b93" name="docs/FFmpegPHP/provider/_provider---AbstractOutputProvider.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="67974ba49187fad84a855d5d7913a313" name="docs/FFmpegPHP/provider/_provider---FFmpegOutputProvider.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="bea12ddfd74efb69f8406e52df1ef17c" name="docs/FFmpegPHP/provider/_provider---FFprobeOutputProvider.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="c76bfec9af1d1ed4c46e961269f87be5" name="docs/FFmpegPHP/provider/_provider---OutputProvider.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="bf1ec9a704d3a027948f8b020977a622" name="docs/FFmpegPHP/provider/_provider---StringOutputProvider.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="f0ddad7d1269399005916f4d4fe56993" name="docs/FFmpegPHP/provider/_test---provider---FFmpegOutputProviderTest.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="6ec0fc32b9ded25cf1820ddbdf8fb9e5" name="docs/FFmpegPHP/provider/_test---provider---FFprobeOutputProviderTest.php.html" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="908a7af2b36fa04f1b869ff74b6a8d37" name="docs/media/background.png" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="4c480a60db1ab64317fe351a24396eb1" name="docs/media/empty.png" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="45923cad7340f4184f27e287c17e2429" name="docs/media/logo.png" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="e30f8980b460663466797d691f972467" name="docs/media/style.css" role="doc" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="e99fea428313c70fe35570f709a5aeb2" name="provider/AbstractOutputProvider.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="fc0738a8ad50606ba28c4ba6b6736138" name="provider/FFmpegOutputProvider.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="6cb518ba565d84f8295d036f9c45a8aa" name="provider/FFprobeOutputProvider.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="b645de65220e6bbdb808af8175aacf06" name="provider/OutputProvider.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="1f765dcfe130bdf8ce3bc40e9713e407" name="provider/StringOutputProvider.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="d23eed9f9d2139a7f36f5b1cdb3d6a56" name="test/bootstrap.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="d736f6ae9a4519b8b613dea24bbf4643" name="test/FFmpegAnimatedGifTest.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="e8ac11f55d04b5cde9065f8faddaa3a0" name="test/FFmpegAutoloaderTest.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="1dd4d119a0b7756ab36a496039b66c39" name="test/FFmpegFrameTest.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="3076406df448a021b0996daa7fb44bfe" name="test/FFmpegMovieTest.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="ebe6fd3780f3d2a4baceaa70abec520d" name="test/adapter/ffmpeg_animated_gif_Test.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="c065b1cb98cdf3aa4b116e5b84f24354" name="test/adapter/ffmpeg_frame_Test.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="390c3df08a9cb026a3146742a8240eca" name="test/adapter/ffmpeg_movie_Test.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="34ccb4a8bcf8af7054f66745ed081045" name="test/data/test.mp4" role="data" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="3ad821dca55f57baaf66881aa156c058" name="test/data/test.wav" role="data" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="d8e8fca2dc0f896fd7cb4cb0031ba249" name="test/data/test1.txt" role="data" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="827f0f6a3f2dcbf8a3b8063ec0943b4f" name="test/provider/FFmpegOutputProviderTest.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="c5e38d9d0ee8b2ad05690ad09fa1b74e" name="test/provider/FFprobeOutputProviderTest.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="e97a02c44c623e806614a617125fb8cf" name="FFmpegAnimatedGif.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="5261f35e77f21bd3e1a220ceec6b934d" name="FFmpegAutoloader.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="7af7fb0f8713be3ecc4613498efa1bf1" name="FFmpegFrame.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="eafd5fd248175e8128bd51f674a9bf44" name="FFmpegMovie.php" role="php" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="f7de63f5b302160363fe690479eb8323" name="LICENSE" role="data" />
|
||||
<file baseinstalldir="FFmpegPHP2" md5sum="351f9cb9debf0a3d6c9c51f9b0a3d20f" name="README.rst" role="data" />
|
||||
</dir>
|
||||
</contents>
|
||||
<dependencies>
|
||||
<required>
|
||||
<php>
|
||||
<min>5</min>
|
||||
</php>
|
||||
<pearinstaller>
|
||||
<min>1.4.0</min>
|
||||
</pearinstaller>
|
||||
</required>
|
||||
</dependencies>
|
||||
<phprelease />
|
||||
<changelog>
|
||||
<release>
|
||||
<version>
|
||||
<release>2.6.2.1</release>
|
||||
<api>2.6</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2012-02-12</date>
|
||||
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license>
|
||||
<notes>
|
||||
Removed php ending tags from php files
|
||||
Support for latest ffmpeg
|
||||
Tons of fixes and enhancements
|
||||
</notes>
|
||||
<deps>
|
||||
<dep type="php" rel="ge">5</dep>
|
||||
<dep type="ext" rel="has">gd</dep>
|
||||
</deps>
|
||||
</release>
|
||||
</changelog>
|
||||
</package>
|
|
@ -1,73 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* AbstractOutputProvider parent of all output providers
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @package FFmpegPHP
|
||||
* @subpackage provider
|
||||
* @abstract
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
abstract class AbstractOutputProvider implements OutputProvider, Serializable {
|
||||
|
||||
protected static $EX_CODE_FILE_NOT_FOUND = 334561;
|
||||
protected static $persistentBuffer = array();
|
||||
|
||||
/**
|
||||
* Binary that returns info about movie file
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $binary;
|
||||
|
||||
/**
|
||||
* Movie File path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $movieFile;
|
||||
|
||||
/**
|
||||
* Persistent functionality on/off
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $persistent;
|
||||
|
||||
/**
|
||||
* Base constructor for every provider
|
||||
*
|
||||
* @param string $binary binary that returns info about movie file
|
||||
* @param boolean $persistent persistent functionality on/off
|
||||
*/
|
||||
public function __construct($binary, $persistent) {
|
||||
$this->binary = $binary;
|
||||
$this->persistent = $persistent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting movie file path
|
||||
*
|
||||
* @param string $movieFile
|
||||
*/
|
||||
public function setMovieFile($movieFile) {
|
||||
$this->movieFile = $movieFile;
|
||||
}
|
||||
|
||||
public function serialize() {
|
||||
return serialize(array(
|
||||
$this->binary,
|
||||
$this->movieFile,
|
||||
$this->persistent
|
||||
));
|
||||
}
|
||||
|
||||
public function unserialize($serialized) {
|
||||
list(
|
||||
$this->binary,
|
||||
$this->movieFile,
|
||||
$this->persistent
|
||||
) = unserialize($serialized);
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FFmpegOutputProvider ffmpeg provider implementation
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @package FFmpegPHP
|
||||
* @subpackage provider
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class FFmpegOutputProvider extends AbstractOutputProvider {
|
||||
|
||||
protected static $EX_CODE_NO_FFMPEG = 334560;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $ffmpegBinary path to ffmpeg executable
|
||||
* @param boolean $persistent persistent functionality on/off
|
||||
*/
|
||||
public function __construct($ffmpegBinary = 'ffmpeg', $persistent = false) {
|
||||
parent::__construct($ffmpegBinary, $persistent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting parsable output from ffmpeg binary
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOutput() {
|
||||
|
||||
// Persistent opening
|
||||
if ($this->persistent == true && array_key_exists(get_class($this).$this->binary.$this->movieFile, self::$persistentBuffer)) {
|
||||
return self::$persistentBuffer[get_class($this).$this->binary.$this->movieFile];
|
||||
}
|
||||
|
||||
// File doesn't exist
|
||||
if (!file_exists($this->movieFile)) {
|
||||
throw new Exception('Movie file not found', self::$EX_CODE_FILE_NOT_FOUND);
|
||||
}
|
||||
|
||||
// Get information about file from ffmpeg
|
||||
$output = array();
|
||||
|
||||
exec($this->binary.' -i '.escapeshellarg($this->movieFile).' 2>&1', $output, $retVar);
|
||||
$output = join(PHP_EOL, $output);
|
||||
|
||||
// ffmpeg installed
|
||||
if (!preg_match('/FFmpeg version/i', $output)) {
|
||||
throw new Exception('FFmpeg is not installed on host server', self::$EX_CODE_NO_FFMPEG);
|
||||
}
|
||||
|
||||
// Storing persistent opening
|
||||
if ($this->persistent == true) {
|
||||
self::$persistentBuffer[get_class($this).$this->binary.$this->movieFile] = $output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* FFprobeOutputProvider ffprobe provider implementation
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @package FFmpegPHP
|
||||
* @subpackage provider
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class FFprobeOutputProvider extends AbstractOutputProvider {
|
||||
|
||||
protected static $EX_CODE_NO_FFPROBE = 334563;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $ffprobeBinary path to ffprobe executable
|
||||
* @param boolean $persistent persistent functionality on/off
|
||||
*/
|
||||
public function __construct($ffprobeBinary = 'ffprobe', $persistent = false) {
|
||||
parent::__construct($ffprobeBinary, $persistent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting parsable output from ffprobe binary
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOutput() {
|
||||
// Persistent opening
|
||||
if ($this->persistent == true && array_key_exists(get_class($this).$this->binary.$this->movieFile, self::$persistentBuffer)) {
|
||||
return self::$persistentBuffer[get_class($this).$this->binary.$this->movieFile];
|
||||
}
|
||||
|
||||
// File doesn't exist
|
||||
if (!file_exists($this->movieFile)) {
|
||||
throw new Exception('Movie file not found', self::$EX_CODE_FILE_NOT_FOUND);
|
||||
}
|
||||
|
||||
// Get information about file from ffprobe
|
||||
$output = array();
|
||||
|
||||
exec($this->binary.' '.escapeshellarg($this->movieFile).' 2>&1', $output, $retVar);
|
||||
$output = join(PHP_EOL, $output);
|
||||
|
||||
// ffprobe installed
|
||||
if (!preg_match('/FFprobe version/i', $output)) {
|
||||
throw new Exception('FFprobe is not installed on host server', self::$EX_CODE_NO_FFPROBE);
|
||||
}
|
||||
|
||||
// Storing persistent opening
|
||||
if ($this->persistent == true) {
|
||||
self::$persistentBuffer[get_class($this).$this->binary.$this->movieFile] = $output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* OutputProvider interface of all output providers
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @package FFmpegPHP
|
||||
* @subpackage provider
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
interface OutputProvider {
|
||||
|
||||
/**
|
||||
* Setting movie file path
|
||||
*
|
||||
* @param string $movieFile
|
||||
*/
|
||||
public function setMovieFile($movieFile);
|
||||
|
||||
/**
|
||||
* Getting parsable output
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOutput();
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* StringOutputProvider ffmpeg provider implementation
|
||||
*
|
||||
* @author funrob (Rob Walch, rwalch@gmail.com)
|
||||
* @package FFmpegPHP
|
||||
* @subpackage provider
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class StringOutputProvider extends AbstractOutputProvider {
|
||||
|
||||
protected $_output;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $ffmpegBinary path to ffmpeg executable
|
||||
* @param boolean $persistent persistent functionality on/off
|
||||
*/
|
||||
public function __construct($ffmpegBinary = 'ffmpeg', $persistent = false) {
|
||||
$this->_output = '';
|
||||
parent::__construct($ffmpegBinary, $persistent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting parsable output from ffmpeg binary
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOutput() {
|
||||
|
||||
// Persistent opening
|
||||
if ($this->persistent == true && array_key_exists(get_class($this).$this->binary.$this->movieFile, self::$persistentBuffer)) {
|
||||
return self::$persistentBuffer[get_class($this).$this->binary.$this->movieFile];
|
||||
}
|
||||
|
||||
return $this->_output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting parsable output
|
||||
*
|
||||
* @param string $output
|
||||
*/
|
||||
public function setOutput($output) {
|
||||
|
||||
$this->_output = $output;
|
||||
|
||||
// Storing persistent opening
|
||||
if ($this->persistent == true) {
|
||||
self::$persistentBuffer[get_class($this).$this->binary.$this->movieFile] = $output;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Testing framework: PHPUnit (http://www.phpunit.de)
|
||||
*
|
||||
* 1.) Install phpunit on your operating system
|
||||
* 2.) Run the test
|
||||
*
|
||||
* phpunit --bootstrap test/bootstrap.php test/FFmpegAnimatedGifTest.php
|
||||
*/
|
||||
/**
|
||||
* FFmpegAnimatedGifTest contains tests for FFmpegAnimatedGif class
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @category tests
|
||||
* @package FFmpegPHP
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class FFmpegAnimatedGifTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
protected static $outFilePath;
|
||||
protected static $moviePath;
|
||||
protected $movie;
|
||||
protected $frame1;
|
||||
protected $frame2;
|
||||
protected $anim;
|
||||
|
||||
public static function setUpBeforeClass() {
|
||||
self::$outFilePath = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('anim', true).'.gif';
|
||||
self::$moviePath = dirname(__FILE__).DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test.mp4';
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass() {
|
||||
self::$outFilePath = null;
|
||||
self::$moviePath = null;
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
$this->movie = new FFmpegMovie(self::$moviePath);
|
||||
$this->frame1 = $this->movie->getFrame(1);
|
||||
$this->frame2 = $this->movie->getFrame(2);
|
||||
$this->anim = new FFmpegAnimatedGif(self::$outFilePath, 100, 120, 1, 0);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
$this->movie = null;
|
||||
$this->frame1 = null;
|
||||
$this->frame2 = null;
|
||||
$this->anim = null;
|
||||
if (file_exists(self::$outFilePath)) unlink(self::$outFilePath);
|
||||
}
|
||||
|
||||
public function testAddFrame() {
|
||||
$frame = $this->movie->getFrame(3);
|
||||
$memoryBefore = memory_get_usage();
|
||||
|
||||
$this->anim->addFrame($frame);
|
||||
|
||||
$memoryAfter = memory_get_usage();
|
||||
|
||||
$this->assertGreaterThan($memoryBefore, $memoryAfter, 'Memory usage should be higher after adding frame');
|
||||
}
|
||||
|
||||
public function testGetAnimation() {
|
||||
$this->anim->addFrame($this->frame1);
|
||||
$this->anim->addFrame($this->frame2);
|
||||
|
||||
$animData = $this->anim->getAnimation();
|
||||
$this->assertEquals(20936, strlen($animData), 'Animation binary size should be int(20936)');
|
||||
}
|
||||
|
||||
public function testSave() {
|
||||
$this->anim->addFrame($this->frame1);
|
||||
$this->anim->addFrame($this->frame2);
|
||||
|
||||
$saveResult = $this->anim->save();
|
||||
$this->assertEquals(true, $saveResult, 'Save result should be true');
|
||||
$this->assertEquals(true, file_exists(self::$outFilePath), 'File "'.self::$outFilePath.'" should exist after saving');
|
||||
$this->assertEquals(20936, filesize(self::$outFilePath), 'Animation binary size should be int(20936)');
|
||||
$imageInfo = getimagesize(self::$outFilePath);
|
||||
$this->assertEquals(100, $imageInfo[0], 'Saved image width should be int(100)');
|
||||
$this->assertEquals(120, $imageInfo[1], 'Saved image height should be int(120)');
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize() {
|
||||
$this->anim->addFrame($this->frame1);
|
||||
$this->anim->addFrame($this->frame2);
|
||||
|
||||
$serialized = serialize($this->anim);
|
||||
$this->anim = null;
|
||||
$this->anim = unserialize($serialized);
|
||||
|
||||
$saveResult = $this->anim->save();
|
||||
$this->assertEquals(true, $saveResult, 'Save result should be true');
|
||||
$this->assertEquals(true, file_exists(self::$outFilePath), 'File "'.self::$outFilePath.'" should exist after saving');
|
||||
$this->assertEquals(20936, filesize(self::$outFilePath), 'Animation binary size should be int(20936)');
|
||||
$imageInfo = getimagesize(self::$outFilePath);
|
||||
$this->assertEquals(100, $imageInfo[0], 'Saved image width should be int(100)');
|
||||
$this->assertEquals(120, $imageInfo[1], 'Saved image height should be int(120)');
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Testing framework: PHPUnit (http://www.phpunit.de)
|
||||
*
|
||||
* 1.) Install phpunit on your operating system
|
||||
* 2.) Run the test
|
||||
*
|
||||
* phpunit --bootstrap test/bootstrap.php test/FFmpegAutoloaderTest.php
|
||||
*/
|
||||
/**
|
||||
* FFmpegAutoloaderTest contains tests for FFmpegAutoloader class
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @category tests
|
||||
* @package FFmpegPHP
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class FFmpegAutoloaderTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testAutoload() {
|
||||
$this->assertTrue(FFmpegAutoloader::autoload('FFmpegAnimatedGif'));
|
||||
$this->assertTrue(FFmpegAutoloader::autoload('FFmpegFrame'));
|
||||
$this->assertTrue(FFmpegAutoloader::autoload('FFmpegMovie'));
|
||||
$this->assertTrue(FFmpegAutoloader::autoload('ffmpeg_animated_gif'));
|
||||
$this->assertTrue(FFmpegAutoloader::autoload('ffmpeg_frame'));
|
||||
$this->assertTrue(FFmpegAutoloader::autoload('ffmpeg_movie'));
|
||||
$this->assertTrue(FFmpegAutoloader::autoload('OutputProvider'));
|
||||
$this->assertTrue(FFmpegAutoloader::autoload('AbstractOutputProvider'));
|
||||
$this->assertTrue(FFmpegAutoloader::autoload('FFmpegOutputProvider'));
|
||||
$this->assertTrue(FFmpegAutoloader::autoload('FFprobeOutputProvider'));
|
||||
$this->assertFalse(FFmpegAutoloader::autoload(uniqid()));
|
||||
}
|
||||
}
|
133
vendor/codescale/ffmpeg-php/test/FFmpegFrameTest.php
vendored
133
vendor/codescale/ffmpeg-php/test/FFmpegFrameTest.php
vendored
|
@ -1,133 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Testing framework: PHPUnit (http://www.phpunit.de)
|
||||
*
|
||||
* 1.) Install phpunit on your operating system
|
||||
* 2.) Run the test
|
||||
*
|
||||
* phpunit --bootstrap test/bootstrap.php test/FFmpegFrameTest.php
|
||||
*/
|
||||
/**
|
||||
* FFmpegFrameTest contains tests for FFmpegFrame class
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @category tests
|
||||
* @package FFmpegPHP
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class FFmpegFrameTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
protected static $moviePath;
|
||||
protected $movie;
|
||||
protected $frame;
|
||||
|
||||
public static function setUpBeforeClass() {
|
||||
self::$moviePath = dirname(__FILE__).DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test.mp4';
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass() {
|
||||
self::$moviePath = null;
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
$this->movie = new FFmpegMovie(self::$moviePath);
|
||||
$this->frame = $this->movie->getFrame(1);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
$this->movie = null;
|
||||
$this->frame = null;
|
||||
}
|
||||
|
||||
public function testConstructor() {
|
||||
try {
|
||||
$frame = new FFmpegFrame('test', 0.0);
|
||||
} catch (Exception $ex) {
|
||||
if ($ex->getCode() == 334563) {
|
||||
return;
|
||||
} else {
|
||||
$this->fail('Expected exception raised with wrong code');
|
||||
}
|
||||
}
|
||||
$this->fail('An expected exception with code 334561 has not been raised');
|
||||
}
|
||||
|
||||
public function testFrameExtracted() {
|
||||
$this->assertInstanceOf('FFmpegFrame', $this->frame);
|
||||
}
|
||||
|
||||
public function testGetWidth() {
|
||||
$this->assertInternalType('int', $this->frame->getWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(640, $this->frame->getWidth(), 'Frame width should be int(640)');
|
||||
}
|
||||
|
||||
public function testGetHeight() {
|
||||
$this->assertInternalType('int', $this->frame->getHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(272, $this->frame->getHeight(), 'Frame height should be int(272)');
|
||||
}
|
||||
|
||||
public function testGetPts() {
|
||||
$this->assertInternalType('float', $this->frame->getPts(), 'Pts is of integer type');
|
||||
$this->assertEquals(0.0, $this->frame->getPts(), 'Pts should be float(0.0)');
|
||||
}
|
||||
|
||||
public function testGetPresentationTimestamp() {
|
||||
$this->assertInternalType('float', $this->frame->getPresentationTimestamp(), 'Presentation timestamp is of integer type');
|
||||
$this->assertEquals(0.0, $this->frame->getPresentationTimestamp(), 'Presentation timestamp should be float(0.0)');
|
||||
$this->assertEquals($this->frame->getPts(), $this->frame->getPresentationTimestamp(), 'Presentation timestamp should equal Pts');
|
||||
}
|
||||
|
||||
public function testResize() {
|
||||
$oldWidth = $this->frame->getWidth();
|
||||
$oldHeight = $this->frame->getHeight();
|
||||
|
||||
$this->frame->resize(300, 300);
|
||||
$this->assertInternalType('int', $this->frame->getWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(300, $this->frame->getWidth(), 'Frame width should be int(300)');
|
||||
$this->assertInternalType('int', $this->frame->getHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(300, $this->frame->getHeight(), 'Frame height should be int(300)');
|
||||
$this->frame->resize($oldWidth, $oldHeight);
|
||||
$this->assertInternalType('int', $this->frame->getWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(640, $this->frame->getWidth(), 'Frame width should be int(640)');
|
||||
$this->assertInternalType('int', $this->frame->getHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(272, $this->frame->getHeight(), 'Frame height should be int(272)');
|
||||
}
|
||||
|
||||
public function testCrop() {
|
||||
$oldWidth = $this->frame->getWidth();
|
||||
$oldHeight = $this->frame->getHeight();
|
||||
|
||||
$this->frame->crop(100);
|
||||
$this->assertInternalType('int', $this->frame->getWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(640, $this->frame->getWidth(), 'Frame width should be int(300)');
|
||||
$this->assertInternalType('int', $this->frame->getHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(172, $this->frame->getHeight(), 'Frame height should be int(172)');
|
||||
$this->frame->resize($oldWidth, $oldHeight);
|
||||
$this->assertInternalType('int', $this->frame->getWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(640, $this->frame->getWidth(), 'Frame width should be int(640)');
|
||||
$this->assertInternalType('int', $this->frame->getHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(272, $this->frame->getHeight(), 'Frame height should be int(272)');
|
||||
}
|
||||
|
||||
public function testToGdImage() {
|
||||
$this->assertInternalType('resource', $this->frame->toGdImage(), 'GdImage is of resource(gd2) type');
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize() {
|
||||
$serialized = serialize($this->frame);
|
||||
$this->frame = null;
|
||||
$this->frame = unserialize($serialized);
|
||||
$this->assertInternalType('int', $this->frame->getWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(640, $this->frame->getWidth(), 'Frame width should be int(640)');
|
||||
$this->assertInternalType('int', $this->frame->getHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(272, $this->frame->getHeight(), 'Frame height should be int(272)');
|
||||
}
|
||||
|
||||
public function testClone() {
|
||||
$uoid = (string) $this->frame->toGdImage();
|
||||
$cloned = clone $this->frame;
|
||||
$cuoid = (string) $cloned->toGdImage();
|
||||
$this->assertNotEquals($uoid, $cuoid);
|
||||
}
|
||||
}
|
271
vendor/codescale/ffmpeg-php/test/FFmpegMovieTest.php
vendored
271
vendor/codescale/ffmpeg-php/test/FFmpegMovieTest.php
vendored
|
@ -1,271 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Testing framework: PHPUnit (http://www.phpunit.de)
|
||||
*
|
||||
* 1.) Install phpunit on your operating system
|
||||
* 2.) Run the test
|
||||
*
|
||||
* phpunit --bootstrap test/bootstrap.php test/FFmpegMovieTest.php
|
||||
*/
|
||||
/**
|
||||
* FFmpegMovieTest contains tests for FFmpegMovie class
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @category tests
|
||||
* @package FFmpegPHP
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class FFmpegMovieTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
protected static $moviePath;
|
||||
protected $movie;
|
||||
|
||||
protected static $audioPath;
|
||||
protected $audio;
|
||||
|
||||
protected static $noMediaPath;
|
||||
|
||||
public static function setUpBeforeClass() {
|
||||
self::$moviePath = dirname(__FILE__).DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test.mp4';
|
||||
self::$audioPath = dirname(__FILE__).DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test.wav';
|
||||
self::$noMediaPath = dirname(__FILE__).DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test1.txt';
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass() {
|
||||
self::$moviePath = null;
|
||||
self::$audioPath = null;
|
||||
self::$noMediaPath = null;
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
$this->movie = new FFmpegMovie(self::$moviePath);
|
||||
$this->audio = new FFmpegMovie(self::$audioPath);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
$this->movie = null;
|
||||
$this->audio = null;
|
||||
}
|
||||
|
||||
public function testFileDoesNotExistException() {
|
||||
try {
|
||||
$movie = new FFmpegMovie(uniqid('test', true));
|
||||
} catch (Exception $ex) {
|
||||
if ($ex->getCode() == 334561) {
|
||||
return;
|
||||
} else {
|
||||
$this->fail('Expected exception raised with wrong code');
|
||||
}
|
||||
}
|
||||
|
||||
$this->fail('An expected exception with code 334561 has not been raised');
|
||||
}
|
||||
|
||||
public function testPersistentResourceSimulation() {
|
||||
PHP_Timer::start();
|
||||
$movie = new FFmpegMovie(self::$moviePath, new FFmpegOutputProvider('ffmpeg', true));
|
||||
$movie = new FFmpegMovie(self::$moviePath, new FFmpegOutputProvider('ffmpeg', true));
|
||||
$movie = new FFmpegMovie(self::$moviePath, new FFmpegOutputProvider('ffmpeg', true));
|
||||
$elapsed = PHP_Timer::stop();
|
||||
|
||||
PHP_Timer::start();
|
||||
$movie = new FFmpegMovie(self::$moviePath);
|
||||
$movie = new FFmpegMovie(self::$moviePath);
|
||||
$movie = new FFmpegMovie(self::$moviePath);
|
||||
$elapsed1 = PHP_Timer::stop();
|
||||
$this->assertGreaterThan($elapsed, $elapsed1, 'Persistent resource simulation should be faster');
|
||||
}
|
||||
|
||||
public function testGetDuration() {
|
||||
$this->assertInternalType('float', $this->movie->getDuration(), 'Duration is of float type');
|
||||
$this->assertEquals(32.13, $this->movie->getDuration(), 'Duration should be float(32.13)');
|
||||
}
|
||||
public function testGetDuration_Audio() {
|
||||
$this->assertInternalType('float', $this->audio->getDuration(), 'Duration is of float type');
|
||||
$this->assertEquals(15.84, $this->audio->getDuration(), 'Duration should be float(15.84)');
|
||||
}
|
||||
|
||||
public function testGetFrameCount() {
|
||||
$this->assertInternalType('int', $this->movie->getFrameCount(), 'Frame count is of integer type');
|
||||
$this->assertEquals(803, $this->movie->getFrameCount(), 'Frame count should be int(830)');
|
||||
}
|
||||
|
||||
public function testGetFrameRate() {
|
||||
$this->assertInternalType('float', $this->movie->getFrameRate(), 'FrameRate is of float type');
|
||||
$this->assertEquals(25, $this->movie->getFrameRate(), 'FrameRate should be float(25)');
|
||||
}
|
||||
|
||||
public function testGetFileName() {
|
||||
$this->assertInternalType('string', $this->movie->getFilename(), 'Filename is of type string');
|
||||
$this->assertEquals(self::$moviePath, $this->movie->getFilename(), 'Filename should be string(data/test.avi)');
|
||||
}
|
||||
|
||||
public function testGetComment() {
|
||||
$this->assertInternalType('string', $this->movie->getComment(), 'Comment is of string type');
|
||||
$this->assertEquals('test comment', $this->movie->getComment(), 'Comment should be string(test comment)');
|
||||
}
|
||||
|
||||
public function testGetTitle() {
|
||||
$this->assertInternalType('string', $this->movie->getTitle(), 'Title is of string type');
|
||||
$this->assertEquals('title test', $this->movie->getTitle(), 'Title should be string(title test)');
|
||||
}
|
||||
|
||||
public function testGetArtist() {
|
||||
$this->assertInternalType('string', $this->movie->getArtist(), 'Artist is of string type');
|
||||
$this->assertEquals('char0n', $this->movie->getArtist(), 'Artist should be string(char0n)');
|
||||
}
|
||||
|
||||
public function testGetAuthor() {
|
||||
$this->assertInternalType('string', $this->movie->getAuthor(), 'Author is of string type');
|
||||
$this->assertEquals('char0n', $this->movie->getAuthor(), 'Author should be string(char0n)');
|
||||
$this->assertEquals($this->movie->getArtist(), $this->movie->getAuthor(), 'Author should qual Artist');
|
||||
}
|
||||
|
||||
public function testGetCopyright() {
|
||||
$this->assertInternalType('string', $this->movie->getCopyright(), 'Copyright is of string type');
|
||||
$this->assertEquals('test copyright', $this->movie->getCopyright(), 'Copyright should be string(test copyright)');
|
||||
}
|
||||
|
||||
public function testGetGenre() {
|
||||
$this->assertInternalType('string', $this->movie->getGenre(), 'Genre is of string type');
|
||||
$this->assertEquals('test genre', $this->movie->getGenre(), 'Genre should be string(test genre)');
|
||||
}
|
||||
|
||||
public function testGetTrackNumber() {
|
||||
$this->assertInternalType('int', $this->movie->getTrackNumber(), 'Track number is of integer type');
|
||||
$this->assertEquals(2, $this->movie->getTrackNumber(), 'Track number should be int(2)');
|
||||
}
|
||||
|
||||
public function testGetYear() {
|
||||
$this->assertInternalType('int', $this->movie->getYear(), 'Year is of integer type');
|
||||
$this->assertEquals(true, $this->movie->getYear() == 2010 || $this->movie->getYear() == 0, 'Year should be int(2010)');
|
||||
}
|
||||
|
||||
public function testGetFrameHeight() {
|
||||
$this->assertInternalType('int', $this->movie->getFrameHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(272, $this->movie->getFrameHeight(), 'Frame height should be int(272)');
|
||||
}
|
||||
|
||||
public function testGetFrameWidth() {
|
||||
$this->assertInternalType('int', $this->movie->getFrameWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(640, $this->movie->getFrameWidth(), 'Frame width should be int(640)');
|
||||
}
|
||||
|
||||
public function testGetPixelFormat() {
|
||||
$this->assertInternalType('string', $this->movie->getPixelFormat(), 'Pixel format is of string type');
|
||||
$this->assertEquals('yuv420p', $this->movie->getPixelFormat(), 'Pixel format should be string(yuv420p)');
|
||||
}
|
||||
|
||||
public function testGetBitRate() {
|
||||
$this->assertInternalType('int', $this->movie->getBitRate(), 'BitRate is of integer type');
|
||||
$this->assertEquals(296000, $this->movie->getBitRate(), 'BitRate should be int(296000)');
|
||||
}
|
||||
|
||||
public function testGetBitRate_Audio() {
|
||||
$this->assertInternalType('int', $this->audio->getBitRate(), 'BitRate is of integer type');
|
||||
$this->assertEquals(178000, $this->audio->getBitRate(), 'BitRate should be int(178000)');
|
||||
}
|
||||
|
||||
public function testGetVideoBitRate() {
|
||||
$this->assertInternalType('int', $this->movie->getVideoBitRate(), 'Video BitRate is of integer type');
|
||||
$this->assertEquals(224000, $this->movie->getVideoBitRate(), 'Video BitRate should be int(224000)');
|
||||
}
|
||||
|
||||
public function testGetAudioBitRate() {
|
||||
$this->assertInternalType('int', $this->movie->getAudioBitRate(), 'Audio BitRate is of integer type');
|
||||
$this->assertEquals(67000, $this->movie->getAudioBitRate(), 'Audio BitRate should be int(67000)');
|
||||
}
|
||||
|
||||
public function testGetAudioSampleRate() {
|
||||
$this->assertInternalType('int', $this->movie->getAudioSampleRate(), 'Audio SampleRate is of integer type');
|
||||
$this->assertEquals(44100, $this->movie->getAudioSampleRate(), 'Audio SampleRate should be int(44100)');
|
||||
}
|
||||
|
||||
public function testGetAudioSampleRate_Audio() {
|
||||
$this->assertInternalType('int', $this->audio->getAudioSampleRate(), 'Audio SampleRate is of integer type');
|
||||
$this->assertEquals(22050, $this->audio->getAudioSampleRate(), 'Audio SampleRate should be int(22050)');
|
||||
}
|
||||
|
||||
public function testGetFrameNumber() {
|
||||
$this->assertInternalType('int', $this->movie->getFrameNumber(), 'Frame number is of integer type');
|
||||
$this->assertEquals(1, $this->movie->getFrameNumber(), 'Frame number should be int(1)');
|
||||
|
||||
$this->assertInstanceOf('FFmpegFrame', $this->movie->getNextKeyFrame());
|
||||
$this->assertInternalType('int', $this->movie->getFrameNumber(), 'Frame number is of integer type');
|
||||
$this->assertEquals(1, $this->movie->getFrameNumber(), 'Frame number should be int(1)');
|
||||
|
||||
$this->assertInstanceOf('FFmpegFrame', $this->movie->getNextKeyFrame());
|
||||
$this->assertInternalType('int', $this->movie->getFrameNumber(), 'Frame number is of integer type');
|
||||
$this->assertEquals(2, $this->movie->getFrameNumber(), 'Frame number should be int(2)');
|
||||
|
||||
$this->assertInstanceOf('FFmpegFrame', $this->movie->getFrame());
|
||||
$this->assertInternalType('int', $this->movie->getFrameNumber(), 'Frame number is of integer type');
|
||||
$this->assertEquals(3, $this->movie->getFrameNumber(), 'Frame number should be int(3)');
|
||||
}
|
||||
|
||||
public function testGetVideoCodec() {
|
||||
$this->assertInternalType('string', $this->movie->getVideoCodec(), 'Video codec is of string type');
|
||||
$this->assertEquals('mpeg4 (Simple Profile) (mp4v / 0x7634706D)', $this->movie->getVideoCodec(), 'Video codec should be string(mpeg4)');
|
||||
}
|
||||
|
||||
public function testGetAudioCodec() {
|
||||
$this->assertInternalType('string', $this->movie->getAudioCodec(), 'Audio codec is of string type');
|
||||
$this->assertEquals('aac (mp4a / 0x6134706D)', $this->movie->getAudioCodec(), 'Audio codec should be string(aac)');
|
||||
}
|
||||
|
||||
public function testGetAudioChannels() {
|
||||
$this->assertInternalType('int', $this->movie->getAudioChannels(), 'Audio channels is of integer type');
|
||||
$this->assertEquals(2, $this->movie->getAudioChannels(), 'Audio channels should be int(2)');
|
||||
}
|
||||
|
||||
public function testGetAudioChannels_Audio() {
|
||||
$this->assertInternalType('int', $this->audio->getAudioChannels(), 'Audio channels is of integer type');
|
||||
$this->assertEquals(2, $this->audio->getAudioChannels(), 'Audio channels should be int(2)');
|
||||
}
|
||||
|
||||
public function testHasAudio() {
|
||||
$this->assertInternalType('boolean', $this->movie->hasAudio(), 'HasAudio is of boolean type');
|
||||
$this->assertEquals(true, $this->movie->hasAudio(), 'HasAudio should be boolean(true)');
|
||||
}
|
||||
|
||||
public function testHasAudio_Audio() {
|
||||
$this->assertInternalType('boolean', $this->audio->hasAudio(), 'HasAudio is of boolean type');
|
||||
$this->assertEquals(true, $this->audio->hasAudio(), 'HasAudio should be boolean(true)');
|
||||
}
|
||||
|
||||
public function testHasVideo() {
|
||||
$this->assertInternalType('boolean', $this->movie->hasVideo(), 'HasVideo is of boolean type');
|
||||
$this->assertEquals(true, $this->movie->hasVideo(), 'HasVideo is of should be boolean(true)');
|
||||
}
|
||||
|
||||
public function testHasVideo_Audio() {
|
||||
$this->assertInternalType('boolean', $this->audio->hasVideo(), 'HasVideo of audio file is of boolean type');
|
||||
$this->assertEquals(false, $this->audio->hasVideo(), 'HasVideo of audio file is of should be boolean(false)');
|
||||
}
|
||||
|
||||
public function testGetFrame() {
|
||||
$this->assertInstanceOf('FFmpegFrame', $this->movie->getFrame(), 'Frame is of FFmpegFrame type');
|
||||
$this->assertEquals(1, $this->movie->getFrameNumber(), 'Frame number should be int(1)');
|
||||
|
||||
$this->assertInstanceOf('FFmpegFrame', $this->movie->getFrame(25), 'Frame is of FFmpegFrame type');
|
||||
|
||||
$this->assertInstanceOf('FFmpegFrame', $this->movie->getFrame(), 'Frame is of FFmpegFrame type');
|
||||
$this->assertEquals(2, $this->movie->getFrameNumber(), 'Frame number should be int(2)');
|
||||
}
|
||||
|
||||
public function testGetNextKeyFrame() {
|
||||
$this->assertInstanceOf('FFmpegFrame', $this->movie->getNextKeyFrame(), 'KeyFrame is of FFmpegFrame type');
|
||||
$this->assertEquals(1, $this->movie->getFrameNumber(), 'Frame number should be int(1)');
|
||||
$this->assertInstanceOf('FFmpegFrame', $this->movie->getNextKeyFrame(), 'Next key frame is of FFmpegFrame type');
|
||||
$this->assertEquals(2, $this->movie->getFrameNumber(), 'Frame number should be int(2)');
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize() {
|
||||
$serialized = serialize($this->movie);
|
||||
$this->movie = null;
|
||||
$this->movie = unserialize($serialized);
|
||||
$this->assertInternalType('float', $this->movie->getDuration(), 'Duration is of float type');
|
||||
$this->assertEquals(32.13, $this->movie->getDuration(), 'Duration should be float(32.13)');
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Testing framework: PHPUnit (http://www.phpunit.de)
|
||||
*
|
||||
* 1.) Install phpunit on your operating system
|
||||
* 2.) Run the test
|
||||
*
|
||||
* phpunit --bootstrap test/bootstrap.php test/adapter/ffmpeg_animated_gif_test.php
|
||||
*/
|
||||
/**
|
||||
* ffmpeg_animated_gif_test contains tests for ffmpeg_animated_gif adapter class
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @category tests
|
||||
* @package FFmpegPHP
|
||||
* @subpackage adapter
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class ffmpeg_animated_git_test extends PHPUnit_Framework_TestCase {
|
||||
|
||||
protected static $outFilePath;
|
||||
protected static $moviePath;
|
||||
protected $movie;
|
||||
protected $frame1;
|
||||
protected $frame2;
|
||||
protected $anim;
|
||||
|
||||
public static function setUpBeforeClass() {
|
||||
self::$outFilePath = sys_get_temp_dir().DIRECTORY_SEPARATOR.uniqid('anim', true).'.gif';
|
||||
self::$moviePath = realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test.mp4');
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass() {
|
||||
self::$outFilePath = null;
|
||||
self::$moviePath = null;
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
$this->movie = new ffmpeg_movie(self::$moviePath);
|
||||
$this->frame1 = $this->movie->getFrame(1);
|
||||
$this->frame2 = $this->movie->getFrame(2);
|
||||
$this->anim = new ffmpeg_animated_gif(self::$outFilePath, 100, 120, 1, 0);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
$this->movie = null;
|
||||
$this->frame1 = null;
|
||||
$this->frame2 = null;
|
||||
$this->anim = null;
|
||||
if (file_exists(self::$outFilePath)) unlink(self::$outFilePath);
|
||||
}
|
||||
|
||||
public function testAddFrame() {
|
||||
$frame = $this->movie->getFrame(3);
|
||||
$memoryBefore = memory_get_usage();
|
||||
|
||||
$this->anim->addFrame($frame);
|
||||
|
||||
$memoryAfter = memory_get_usage();
|
||||
|
||||
$this->assertGreaterThan($memoryBefore, $memoryAfter, 'Memory usage should be higher after adding frame');
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize() {
|
||||
$this->anim->addFrame($this->frame1);
|
||||
$this->anim->addFrame($this->frame2);
|
||||
|
||||
$serialized = serialize($this->anim);
|
||||
$this->anim = null;
|
||||
$this->anim = unserialize($serialized);
|
||||
|
||||
$saveResult = $this->anim->addFrame($this->frame1);
|
||||
$this->assertEquals(true, $saveResult, 'Save result should be true');
|
||||
$this->assertEquals(true, file_exists(self::$outFilePath), 'File "'.self::$outFilePath.'" should exist after saving');
|
||||
$this->assertEquals(30585, filesize(self::$outFilePath), 'Animation binary size should be int(30585)');
|
||||
$imageInfo = getimagesize(self::$outFilePath);
|
||||
$this->assertEquals(100, $imageInfo[0], 'Saved image width should be int(100)');
|
||||
$this->assertEquals(120, $imageInfo[1], 'Saved image height should be int(120)');
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Testing framework: PHPUnit (http://www.phpunit.de)
|
||||
*
|
||||
* 1.) Install phpunit on your operating system
|
||||
* 2.) Run the test
|
||||
*
|
||||
* phpunit --bootstrap test/bootstrap.php test/adapter/ffmpeg_frame_test.php
|
||||
*/
|
||||
/**
|
||||
* ffmpeg_frame_test contains tests for ffmpeg_frame adapter class
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @category tests
|
||||
* @package FFmpegPHP
|
||||
* @subpackage adapter
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class ffmpeg_frame_test extends PHPUnit_Framework_TestCase {
|
||||
|
||||
protected static $moviePath;
|
||||
protected $movie;
|
||||
protected $frame;
|
||||
|
||||
public static function setUpBeforeClass() {
|
||||
self::$moviePath = realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test.mp4');
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass() {
|
||||
self::$moviePath = null;
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
$this->movie = new ffmpeg_movie(self::$moviePath);
|
||||
$this->frame = $this->movie->getFrame(1);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
$this->movie = null;
|
||||
$this->frame = null;
|
||||
}
|
||||
|
||||
public function testConstructor() {
|
||||
try {
|
||||
$frame = new FFmpegFrame('test', 0.0);
|
||||
} catch (Exception $ex) {
|
||||
if ($ex->getCode() == 334563) {
|
||||
return;
|
||||
} else {
|
||||
$this->fail('Expected exception raised with wrong code');
|
||||
}
|
||||
}
|
||||
$this->fail('An expected exception with code 334561 has not been raised');
|
||||
}
|
||||
|
||||
public function testFrameExtracted() {
|
||||
$this->assertInstanceOf('ffmpeg_frame', $this->frame);
|
||||
}
|
||||
|
||||
public function testGetWidth() {
|
||||
$this->assertInternalType('int', $this->frame->getWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(640, $this->frame->getWidth(), 'Frame width should be int(640)');
|
||||
}
|
||||
|
||||
public function testGetHeight() {
|
||||
$this->assertInternalType('int', $this->frame->getHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(272, $this->frame->getHeight(), 'Frame height should be int(272)');
|
||||
}
|
||||
|
||||
public function testGetPts() {
|
||||
$this->assertInternalType('float', $this->frame->getPts(), 'Pts is of integer type');
|
||||
$this->assertEquals(0.0, $this->frame->getPts(), 'Pts should be float(0.0)');
|
||||
}
|
||||
|
||||
public function testGetPresentationTimestamp() {
|
||||
$this->assertInternalType('float', $this->frame->getPresentationTimestamp(), 'Presentation timestamp is of integer type');
|
||||
$this->assertEquals(0.0, $this->frame->getPresentationTimestamp(), 'Presentation timestamp should be float(0.0)');
|
||||
$this->assertEquals($this->frame->getPts(), $this->frame->getPresentationTimestamp(), 'Presentation timestamp should equal Pts');
|
||||
}
|
||||
|
||||
public function testResize() {
|
||||
$oldWidth = $this->frame->getWidth();
|
||||
$oldHeight = $this->frame->getHeight();
|
||||
|
||||
$this->frame->resize(300, 300);
|
||||
$this->assertInternalType('int', $this->frame->getWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(300, $this->frame->getWidth(), 'Frame width should be int(300)');
|
||||
$this->assertInternalType('int', $this->frame->getHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(300, $this->frame->getHeight(), 'Frame height should be int(300)');
|
||||
$this->frame->resize($oldWidth, $oldHeight);
|
||||
$this->assertInternalType('int', $this->frame->getWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(640, $this->frame->getWidth(), 'Frame width should be int(640)');
|
||||
$this->assertInternalType('int', $this->frame->getHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(272, $this->frame->getHeight(), 'Frame height should be int(272)');
|
||||
}
|
||||
|
||||
public function testCrop() {
|
||||
$oldWidth = $this->frame->getWidth();
|
||||
$oldHeight = $this->frame->getHeight();
|
||||
|
||||
$this->frame->crop(100);
|
||||
$this->assertInternalType('int', $this->frame->getWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(640, $this->frame->getWidth(), 'Frame width should be int(300)');
|
||||
$this->assertInternalType('int', $this->frame->getHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(172, $this->frame->getHeight(), 'Frame height should be int(172)');
|
||||
$this->frame->resize($oldWidth, $oldHeight);
|
||||
$this->assertInternalType('int', $this->frame->getWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(640, $this->frame->getWidth(), 'Frame width should be int(640)');
|
||||
$this->assertInternalType('int', $this->frame->getHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(272, $this->frame->getHeight(), 'Frame height should be int(272)');
|
||||
}
|
||||
|
||||
public function testToGdImage() {
|
||||
$this->assertInternalType('resource', $this->frame->toGdImage(), 'GdImage is of resource(gd2) type');
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize() {
|
||||
$serialized = serialize($this->frame);
|
||||
$this->frame = null;
|
||||
$this->frame = unserialize($serialized);
|
||||
$this->assertInternalType('int', $this->frame->getWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(640, $this->frame->getWidth(), 'Frame width should be int(640)');
|
||||
$this->assertInternalType('int', $this->frame->getHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(272, $this->frame->getHeight(), 'Frame height should be int(272)');
|
||||
}
|
||||
|
||||
public function testClone() {
|
||||
$uoid = (string) $this->frame->toGdImage();
|
||||
$cloned = clone $this->frame;
|
||||
$cuoid = (string) $cloned->toGdImage();
|
||||
$this->assertNotEquals($uoid, $cuoid);
|
||||
}
|
||||
}
|
|
@ -1,273 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Testing framework: PHPUnit (http://www.phpunit.de)
|
||||
*
|
||||
* 1.) Install phpunit on your operating system
|
||||
* 2.) Run the test
|
||||
*
|
||||
* phpunit --bootstrap test/bootstrap.php test/adapter/ffmpeg_movie_test.php
|
||||
*/
|
||||
/**
|
||||
* ffmpeg_movie_test contains tests for ffmpeg_movie adapter class
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @category tests
|
||||
* @package FFmpegPHP
|
||||
* @subpackage adapter
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
class ffmpeg_movie_test extends PHPUnit_Framework_TestCase {
|
||||
|
||||
protected static $moviePath;
|
||||
protected $movie;
|
||||
|
||||
protected static $audioPath;
|
||||
protected $audio;
|
||||
|
||||
protected static $noMediaPath;
|
||||
|
||||
public static function setUpBeforeClass() {
|
||||
self::$moviePath = realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test.mp4');
|
||||
self::$audioPath = realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test.wav');
|
||||
self::$noMediaPath = realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test1.txt');
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass() {
|
||||
self::$moviePath = null;
|
||||
self::$audioPath = null;
|
||||
self::$noMediaPath = null;
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
$this->movie = new ffmpeg_movie(self::$moviePath);
|
||||
$this->audio = new ffmpeg_movie(self::$audioPath);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
$this->movie = null;
|
||||
$this->audio = null;
|
||||
}
|
||||
|
||||
public function testFileDoesNotExistException() {
|
||||
try {
|
||||
$movie = new ffmpeg_movie(uniqid('test', true));
|
||||
} catch (Exception $ex) {
|
||||
if ($ex->getCode() == 334561) {
|
||||
return;
|
||||
} else {
|
||||
$this->fail('Expected exception raised with wrong code');
|
||||
}
|
||||
}
|
||||
|
||||
$this->fail('An expected exception with code 334561 has not been raised');
|
||||
}
|
||||
|
||||
public function testPersistentResourceSimulation() {
|
||||
PHP_Timer::start();
|
||||
$movie = new ffmpeg_movie(self::$moviePath, true);
|
||||
$movie = new ffmpeg_movie(self::$moviePath, true);
|
||||
$movie = new ffmpeg_movie(self::$moviePath, true);
|
||||
$elapsed = PHP_Timer::stop();
|
||||
|
||||
PHP_Timer::start();
|
||||
$movie = new ffmpeg_movie(self::$moviePath);
|
||||
$movie = new ffmpeg_movie(self::$moviePath);
|
||||
$movie = new ffmpeg_movie(self::$moviePath);
|
||||
$elapsed1 = PHP_Timer::stop();
|
||||
$this->assertGreaterThan($elapsed, $elapsed1, 'Persistent resource simulation should be faster');
|
||||
}
|
||||
|
||||
public function testGetDuration() {
|
||||
$this->assertInternalType('float', $this->movie->getDuration(), 'Duration is of float type');
|
||||
$this->assertEquals(32.13, $this->movie->getDuration(), 'Duration should be float(32.13)');
|
||||
}
|
||||
|
||||
public function testGetDuration_Audio() {
|
||||
$this->assertInternalType('float', $this->audio->getDuration(), 'Duration is of float type');
|
||||
$this->assertEquals(15.84, $this->audio->getDuration(), 'Duration should be float(15.88)');
|
||||
}
|
||||
|
||||
public function testGetFrameCount() {
|
||||
$this->assertInternalType('int', $this->movie->getFrameCount(), 'Frame count is of integer type');
|
||||
$this->assertEquals(803, $this->movie->getFrameCount(), 'Frame count should be int(830)');
|
||||
}
|
||||
|
||||
public function testGetFrameRate() {
|
||||
$this->assertInternalType('float', $this->movie->getFrameRate(), 'FrameRate is of float type');
|
||||
$this->assertEquals(25, $this->movie->getFrameRate(), 'FrameRate should be float(25)');
|
||||
}
|
||||
|
||||
public function testGetFileName() {
|
||||
$this->assertInternalType('string', $this->movie->getFilename(), 'Filename is of type string');
|
||||
$this->assertEquals(self::$moviePath, $this->movie->getFilename(), 'Filename should be string(*/test/data/test.avi)');
|
||||
}
|
||||
|
||||
public function testGetComment() {
|
||||
$this->assertInternalType('string', $this->movie->getComment(), 'Comment is of string type');
|
||||
$this->assertEquals('test comment', $this->movie->getComment(), 'Comment should be string(test comment)');
|
||||
}
|
||||
|
||||
public function testGetTitle() {
|
||||
$this->assertInternalType('string', $this->movie->getTitle(), 'Title is of string type');
|
||||
$this->assertEquals('title test', $this->movie->getTitle(), 'Title should be string(title test)');
|
||||
}
|
||||
|
||||
public function testGetArtist() {
|
||||
$this->assertInternalType('string', $this->movie->getArtist(), 'Artist is of string type');
|
||||
$this->assertEquals('char0n', $this->movie->getArtist(), 'Artist should be string(char0n)');
|
||||
}
|
||||
|
||||
public function testGetAuthor() {
|
||||
$this->assertInternalType('string', $this->movie->getAuthor(), 'Author is of string type');
|
||||
$this->assertEquals('char0n', $this->movie->getAuthor(), 'Author should be string(char0n)');
|
||||
$this->assertEquals($this->movie->getArtist(), $this->movie->getAuthor(), 'Author should qual Artist');
|
||||
}
|
||||
|
||||
public function testGetCopyright() {
|
||||
$this->assertInternalType('string', $this->movie->getCopyright(), 'Copyright is of string type');
|
||||
$this->assertEquals('test copyright', $this->movie->getCopyright(), 'Copyright should be string(test copyright)');
|
||||
}
|
||||
|
||||
public function testGetGenre() {
|
||||
$this->assertInternalType('string', $this->movie->getGenre(), 'Genre is of string type');
|
||||
$this->assertEquals('test genre', $this->movie->getGenre(), 'Genre should be string(test genre)');
|
||||
}
|
||||
|
||||
public function testGetTrackNumber() {
|
||||
$this->assertInternalType('int', $this->movie->getTrackNumber(), 'Track number is of integer type');
|
||||
$this->assertEquals(2, $this->movie->getTrackNumber(), 'Track number should be int(2)');
|
||||
}
|
||||
|
||||
public function testGetYear() {
|
||||
$this->assertInternalType('int', $this->movie->getYear(), 'Year is of integer type');
|
||||
$this->assertTrue($this->movie->getYear() == 2010 || $this->movie->getYear() == 0, 'Year should be int(2010)');
|
||||
}
|
||||
|
||||
public function testGetFrameHeight() {
|
||||
$this->assertInternalType('int', $this->movie->getFrameHeight(), 'Frame height is of integer type');
|
||||
$this->assertEquals(272, $this->movie->getFrameHeight(), 'Frame height should be int(272)');
|
||||
}
|
||||
|
||||
public function testGetFrameWidth() {
|
||||
$this->assertInternalType('int', $this->movie->getFrameWidth(), 'Frame width is of integer type');
|
||||
$this->assertEquals(640, $this->movie->getFrameWidth(), 'Frame width should be int(640)');
|
||||
}
|
||||
|
||||
public function testGetPixelFormat() {
|
||||
$this->assertInternalType('string', $this->movie->getPixelFormat(), 'Pixel format is of string type');
|
||||
$this->assertEquals('yuv420p', $this->movie->getPixelFormat(), 'Pixel format should be string(yuv420p)');
|
||||
}
|
||||
|
||||
public function testGetBitRate() {
|
||||
$this->assertInternalType('int', $this->movie->getBitRate(), 'BitRate is of integer type');
|
||||
$this->assertEquals(296000, $this->movie->getBitRate(), 'BitRate should be int(296000)');
|
||||
}
|
||||
|
||||
public function testGetBitRate_Audio() {
|
||||
$this->assertInternalType('int', $this->audio->getBitRate(), 'BitRate is of integer type');
|
||||
$this->assertEquals(178000, $this->audio->getBitRate(), 'BitRate should be int(178000)');
|
||||
}
|
||||
|
||||
public function testGetVideoBitRate() {
|
||||
$this->assertInternalType('int', $this->movie->getVideoBitRate(), 'Video BitRate is of integer type');
|
||||
$this->assertEquals(224000, $this->movie->getVideoBitRate(), 'Video BitRate should be int(224000)');
|
||||
}
|
||||
|
||||
public function testGetAudioBitRate() {
|
||||
$this->assertInternalType('int', $this->movie->getAudioBitRate(), 'Audio BitRate is of integer type');
|
||||
$this->assertEquals(67000, $this->movie->getAudioBitRate(), 'Audio BitRate should be int(67000)');
|
||||
}
|
||||
|
||||
public function testGetAudioSampleRate() {
|
||||
$this->assertInternalType('int', $this->movie->getAudioSampleRate(), 'Audio SampleRate is of integer type');
|
||||
$this->assertEquals(44100, $this->movie->getAudioSampleRate(), 'Audio SampleRate should be int(44100)');
|
||||
}
|
||||
|
||||
public function testGetAudioSampleRate_Audio() {
|
||||
$this->assertInternalType('int', $this->audio->getAudioSampleRate(), 'Audio SampleRate is of integer type');
|
||||
$this->assertEquals(22050, $this->audio->getAudioSampleRate(), 'Audio SampleRate should be int(22050)');
|
||||
}
|
||||
|
||||
public function testGetFrameNumber() {
|
||||
$this->assertInternalType('int', $this->movie->getFrameNumber(), 'Frame number is of integer type');
|
||||
$this->assertEquals(1, $this->movie->getFrameNumber(), 'Frame number should be int(1)');
|
||||
|
||||
$this->assertInstanceOf('ffmpeg_frame', $this->movie->getNextKeyFrame());
|
||||
$this->assertInternalType('int', $this->movie->getFrameNumber(), 'Frame number is of integer type');
|
||||
$this->assertEquals(1, $this->movie->getFrameNumber(), 'Frame number should be int(1)');
|
||||
|
||||
$this->assertInstanceOf('ffmpeg_frame', $this->movie->getNextKeyFrame());
|
||||
$this->assertInternalType('int', $this->movie->getFrameNumber(), 'Frame number is of integer type');
|
||||
$this->assertEquals(2, $this->movie->getFrameNumber(), 'Frame number should be int(2)');
|
||||
|
||||
$this->assertInstanceOf('ffmpeg_frame', $this->movie->getFrame());
|
||||
$this->assertInternalType('int', $this->movie->getFrameNumber(), 'Frame number is of integer type');
|
||||
$this->assertEquals(3, $this->movie->getFrameNumber(), 'Frame number should be int(3)');
|
||||
}
|
||||
|
||||
public function testGetVideoCodec() {
|
||||
$this->assertInternalType('string', $this->movie->getVideoCodec(), 'Video codec is of string type');
|
||||
$this->assertEquals('mpeg4 (Simple Profile) (mp4v / 0x7634706D)', $this->movie->getVideoCodec(), 'Video codec should be string(mpeg4)');
|
||||
}
|
||||
|
||||
public function testGetAudioCodec() {
|
||||
$this->assertInternalType('string', $this->movie->getAudioCodec(), 'Audio codec is of string type');
|
||||
$this->assertEquals('aac (mp4a / 0x6134706D)', $this->movie->getAudioCodec(), 'Audio codec should be string(aac)');
|
||||
}
|
||||
|
||||
public function testGetAudioChannels() {
|
||||
$this->assertInternalType('int', $this->movie->getAudioChannels(), 'Audio channels is of integer type');
|
||||
$this->assertEquals(2, $this->movie->getAudioChannels(), 'Audio channels should be int(2)');
|
||||
}
|
||||
|
||||
public function testGetAudioChannels_Audio() {
|
||||
$this->assertInternalType('int', $this->audio->getAudioChannels(), 'Audio channels is of integer type');
|
||||
$this->assertEquals(2, $this->audio->getAudioChannels(), 'Audio channels should be int(2)');
|
||||
}
|
||||
|
||||
public function testHasAudio() {
|
||||
$this->assertInternalType('boolean', $this->movie->hasAudio(), 'HasAudio is of boolean type');
|
||||
$this->assertEquals(true, $this->movie->hasAudio(), 'HasAudio should be boolean(true)');
|
||||
}
|
||||
|
||||
public function testHasAudio_Audio() {
|
||||
$this->assertInternalType('boolean', $this->audio->hasAudio(), 'HasAudio is of boolean type');
|
||||
$this->assertEquals(true, $this->audio->hasAudio(), 'HasAudio should be boolean(true)');
|
||||
}
|
||||
|
||||
public function testHasVideo() {
|
||||
$this->assertInternalType('boolean', $this->movie->hasVideo(), 'HasVideo is of boolean type');
|
||||
$this->assertEquals(true, $this->movie->hasVideo(), 'HasVideo is of should be boolean(true)');
|
||||
}
|
||||
|
||||
public function testHasVideo_Audio() {
|
||||
$this->assertInternalType('boolean', $this->audio->hasVideo(), 'HasVideo of audio file is of boolean type');
|
||||
$this->assertEquals(false, $this->audio->hasVideo(), 'HasVideo of audio file is of should be boolean(false)');
|
||||
}
|
||||
|
||||
public function testGetFrame() {
|
||||
$this->assertInstanceOf('ffmpeg_frame', $this->movie->getFrame(), 'Frame is of FFmpegFrame type');
|
||||
$this->assertEquals(1, $this->movie->getFrameNumber(), 'Frame number should be int(1)');
|
||||
|
||||
$this->assertInstanceOf('ffmpeg_frame', $this->movie->getFrame(25), 'Frame is of FFmpegFrame type');
|
||||
|
||||
$this->assertInstanceOf('ffmpeg_frame', $this->movie->getFrame(), 'Frame is of FFmpegFrame type');
|
||||
$this->assertEquals(2, $this->movie->getFrameNumber(), 'Frame number should be int(2)');
|
||||
}
|
||||
|
||||
public function testGetNextKeyFrame() {
|
||||
$this->assertInstanceOf('ffmpeg_frame', $this->movie->getNextKeyFrame(), 'Next key frame is of FFmpegFrame type');
|
||||
$this->assertEquals(1, $this->movie->getFrameNumber(), 'Frame number should be int(1)');
|
||||
$this->assertInstanceOf('ffmpeg_frame', $this->movie->getNextKeyFrame(), 'Next key frame is of FFmpegFrame type');
|
||||
$this->assertEquals(2, $this->movie->getFrameNumber(), 'Frame number should be int(2)');
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize() {
|
||||
$serialized = serialize($this->movie);
|
||||
$this->movie = null;
|
||||
$this->movie = unserialize($serialized);
|
||||
$this->assertInternalType('float', $this->movie->getDuration(), 'Duration is of float type');
|
||||
$this->assertEquals(32.13, $this->movie->getDuration(), 'Duration should be float(32.13)');
|
||||
}
|
||||
}
|
26
vendor/codescale/ffmpeg-php/test/bootstrap.php
vendored
26
vendor/codescale/ffmpeg-php/test/bootstrap.php
vendored
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This is bootsrap file required for running all the tests
|
||||
* for FFmpegPHP package. This file manages all necessary
|
||||
* settings and file imports.
|
||||
*
|
||||
* Testing framework: PHPUnit (http://www.phpunit.de)
|
||||
*
|
||||
* @category tests
|
||||
* @package FFmpegPHP
|
||||
*/
|
||||
|
||||
date_default_timezone_set('Europe/Bratislava');
|
||||
|
||||
$basePath = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
|
||||
require_once $basePath.'FFmpegAutoloader.php';
|
||||
require_once $basePath.'provider'.DIRECTORY_SEPARATOR.'OutputProvider.php';
|
||||
require_once $basePath.'provider'.DIRECTORY_SEPARATOR.'AbstractOutputProvider.php';
|
||||
require_once $basePath.'provider'.DIRECTORY_SEPARATOR.'FFmpegOutputProvider.php';
|
||||
require_once $basePath.'provider'.DIRECTORY_SEPARATOR.'FFprobeOutputProvider.php';
|
||||
require_once $basePath.'FFmpegAnimatedGif.php';
|
||||
require_once $basePath.'FFmpegFrame.php';
|
||||
require_once $basePath.'FFmpegMovie.php';
|
||||
require_once $basePath.'adapter'.DIRECTORY_SEPARATOR.'ffmpeg_animated_gif.php';
|
||||
require_once $basePath.'adapter'.DIRECTORY_SEPARATOR.'ffmpeg_frame.php';
|
||||
require_once $basePath.'adapter'.DIRECTORY_SEPARATOR.'ffmpeg_movie.php';
|
BIN
vendor/codescale/ffmpeg-php/test/data/test.mp4
vendored
BIN
vendor/codescale/ffmpeg-php/test/data/test.mp4
vendored
Binary file not shown.
BIN
vendor/codescale/ffmpeg-php/test/data/test.wav
vendored
BIN
vendor/codescale/ffmpeg-php/test/data/test.wav
vendored
Binary file not shown.
|
@ -1 +0,0 @@
|
|||
test
|
|
@ -1,94 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Testing framework: PHPUnit (http://www.phpunit.de)
|
||||
*
|
||||
* 1.) Install phpunit on your operating system
|
||||
* 2.) Run the test
|
||||
*
|
||||
* phpunit --bootstrap test/bootstrap.php test/provider/FFmpegOutputProviderTest.php
|
||||
*/
|
||||
/**
|
||||
* FFmpegOutputProviderTest contains tests for FFmpegOutputProvider class
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @category tests
|
||||
* @package FFmpegPHP
|
||||
* @subpackage provider
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
|
||||
class FFmpegOutputProviderTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
protected static $moviePath;
|
||||
protected $provider;
|
||||
|
||||
public static function setUpBeforeClass() {
|
||||
self::$moviePath = realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test.mp4');
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass() {
|
||||
self::$moviePath = null;
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
$this->provider = new FFmpegOutputProvider();
|
||||
$this->provider->setMovieFile(self::$moviePath);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
$this->provider = null;
|
||||
}
|
||||
|
||||
public function testGetOutput() {
|
||||
$output = $this->provider->getOutput();
|
||||
$this->assertEquals(1, preg_match('/FFmpeg version/i', $output));
|
||||
}
|
||||
|
||||
public function testGetOutputFileDoesntExist() {
|
||||
try {
|
||||
$provider = new FFmpegOutputProvider();
|
||||
$provider->setMovieFile(uniqid('test', true));
|
||||
$provider->getOutput();
|
||||
} catch (Exception $ex) {
|
||||
if ($ex->getCode() == 334561) {
|
||||
return;
|
||||
} else {
|
||||
$this->fail('Expected exception raise with wrong code');
|
||||
}
|
||||
}
|
||||
|
||||
$this->fail('An expected exception with code 334561 has not been raised');
|
||||
}
|
||||
|
||||
public function testPersistentResourceSimulation() {
|
||||
PHP_Timer::start();
|
||||
$provider = new FFmpegOutputProvider('ffmpeg', true);
|
||||
$provider->setMovieFile(self::$moviePath);
|
||||
$provider->getOutput();
|
||||
$provider = clone $provider;
|
||||
$provider->getOutput();
|
||||
$provider = clone $provider;
|
||||
$provider->getOutput();
|
||||
$elapsed = PHP_Timer::stop();
|
||||
|
||||
PHP_Timer::start();
|
||||
$provider = new FFmpegOutputProvider('ffmpeg', false);
|
||||
$provider->setMovieFile(self::$moviePath);
|
||||
$provider->getOutput();
|
||||
$provider = clone $provider;
|
||||
$provider->getOutput();
|
||||
$provider = clone $provider;
|
||||
$provider->getOutput();
|
||||
$elapsed1 = PHP_Timer::stop();
|
||||
$this->assertGreaterThan($elapsed, $elapsed1, 'Persistent resource simulation should be faster');
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize() {
|
||||
$output = $this->provider->getOutput();
|
||||
$serialized = serialize($this->provider);
|
||||
$this->provider = null;
|
||||
$this->provider = unserialize($serialized);
|
||||
$this->assertEquals($output, $this->provider->getOutput(), 'Output from original and unserialized provider should be equal');
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Testing framework: PHPUnit (http://www.phpunit.de)
|
||||
*
|
||||
* 1.) Install phpunit on your operating system
|
||||
* 2.) Run the test
|
||||
*
|
||||
* phpunit --bootstrap test/bootstrap.php test/provider/FFprobeOutputProviderTest.php
|
||||
*/
|
||||
/**
|
||||
* FFprobeOutputProviderTest contains tests for FFprobeOutputProvider class
|
||||
*
|
||||
* @author char0n (Vladimír Gorej, gorej@codescale.net)
|
||||
* @category tests
|
||||
* @package FFmpegPHP
|
||||
* @subpackage provider
|
||||
* @license New BSD
|
||||
* @version 2.6
|
||||
*/
|
||||
|
||||
class FFprobeOutputProviderTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
protected static $moviePath;
|
||||
protected $provider;
|
||||
|
||||
public static function setUpBeforeClass() {
|
||||
self::$moviePath = realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'test.mp4');
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass() {
|
||||
self::$moviePath = null;
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
$this->provider = new FFprobeOutputProvider();
|
||||
$this->provider->setMovieFile(self::$moviePath);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
$this->provider = null;
|
||||
}
|
||||
|
||||
public function testGetOutput() {
|
||||
$output = $this->provider->getOutput();
|
||||
$this->assertEquals(1, preg_match('/FFprobe version/i', $output));
|
||||
}
|
||||
|
||||
public function testGetOutputFileDoesntExist() {
|
||||
try {
|
||||
$provider = new FFprobeOutputProvider();
|
||||
$provider->setMovieFile(uniqid('test', true));
|
||||
$provider->getOutput();
|
||||
} catch (Exception $ex) {
|
||||
if ($ex->getCode() == 334561) {
|
||||
return;
|
||||
} else {
|
||||
$this->fail('Expected exception raise with wrong code');
|
||||
}
|
||||
}
|
||||
|
||||
$this->fail('An expected exception with code 334561 has not been raised');
|
||||
}
|
||||
|
||||
public function testPersistentResourceSimulation() {
|
||||
PHP_Timer::start();
|
||||
$provider = new FFprobeOutputProvider('ffprobe', true);
|
||||
$provider->setMovieFile(self::$moviePath);
|
||||
$provider->getOutput();
|
||||
$provider = clone $provider;
|
||||
$provider->getOutput();
|
||||
$provider = clone $provider;
|
||||
$provider->getOutput();
|
||||
$elapsed = PHP_Timer::stop();
|
||||
|
||||
PHP_Timer::start();
|
||||
$provider = new FFprobeOutputProvider('ffprobe', false);
|
||||
$provider->setMovieFile(self::$moviePath);
|
||||
$provider->getOutput();
|
||||
$provider = clone $provider;
|
||||
$provider->getOutput();
|
||||
$provider = clone $provider;
|
||||
$provider->getOutput();
|
||||
$elapsed1 = PHP_Timer::stop();
|
||||
$this->assertGreaterThan($elapsed, $elapsed1, 'Persistent resource simulation should be faster');
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize() {
|
||||
$output = $this->provider->getOutput();
|
||||
$serialized = serialize($this->provider);
|
||||
$this->provider = null;
|
||||
$this->provider = unserialize($serialized);
|
||||
$this->assertEquals($output, $this->provider->getOutput(), 'Output from original and unserialized provider should be equal');
|
||||
}
|
||||
}
|
246
vendor/composer/ClassLoader.php
vendored
246
vendor/composer/ClassLoader.php
vendored
|
@ -1,246 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0 class loader
|
||||
*
|
||||
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
private $prefixes = array();
|
||||
private $fallbackDirs = array();
|
||||
private $useIncludePath = false;
|
||||
private $classMap = array();
|
||||
|
||||
public function getPrefixes()
|
||||
{
|
||||
return call_user_func_array('array_merge', $this->prefixes);
|
||||
}
|
||||
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirs;
|
||||
}
|
||||
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $classMap Class to filename map
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of classes, merging with any others previously set.
|
||||
*
|
||||
* @param string $prefix The classes prefix
|
||||
* @param array|string $paths The location(s) of the classes
|
||||
* @param bool $prepend Prepend the location(s)
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirs = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirs
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirs = array_merge(
|
||||
$this->fallbackDirs,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixes[$first][$prefix])) {
|
||||
$this->prefixes[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixes[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixes[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixes[$first][$prefix] = array_merge(
|
||||
$this->prefixes[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of classes, replacing any others previously set.
|
||||
*
|
||||
* @param string $prefix The classes prefix
|
||||
* @param array|string $paths The location(s) of the classes
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirs = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
$this->prefixes[substr($prefix, 0, 1)][$prefix] = (array) $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return bool|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
include $file;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
|
||||
if ('\\' == $class[0]) {
|
||||
$class = substr($class, 1);
|
||||
}
|
||||
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$classPath = strtr(substr($class, 0, $pos), '\\', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
$className = substr($class, $pos + 1);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$classPath = null;
|
||||
$className = $class;
|
||||
}
|
||||
|
||||
$classPath .= strtr($className, '_', DIRECTORY_SEPARATOR) . '.php';
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixes[$first])) {
|
||||
foreach ($this->prefixes[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
|
||||
return $dir . DIRECTORY_SEPARATOR . $classPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->fallbackDirs as $dir) {
|
||||
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
|
||||
return $dir . DIRECTORY_SEPARATOR . $classPath;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return $this->classMap[$class] = false;
|
||||
}
|
||||
}
|
1893
vendor/composer/autoload_classmap.php
vendored
1893
vendor/composer/autoload_classmap.php
vendored
File diff suppressed because it is too large
Load diff
50
vendor/composer/autoload_namespaces.php
vendored
50
vendor/composer/autoload_namespaces.php
vendored
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
// autoload_namespaces.php generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Whoops' => array($vendorDir . '/filp/whoops/src'),
|
||||
'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'),
|
||||
'Symfony\\Component\\Routing\\' => array($vendorDir . '/symfony/routing'),
|
||||
'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
|
||||
'Symfony\\Component\\HttpKernel\\' => array($vendorDir . '/symfony/http-kernel'),
|
||||
'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'),
|
||||
'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
|
||||
'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
|
||||
'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
|
||||
'Symfony\\Component\\DomCrawler\\' => array($vendorDir . '/symfony/dom-crawler'),
|
||||
'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
|
||||
'Symfony\\Component\\CssSelector\\' => array($vendorDir . '/symfony/css-selector'),
|
||||
'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
|
||||
'Symfony\\Component\\BrowserKit\\' => array($vendorDir . '/symfony/browser-kit'),
|
||||
'React\\Stream' => array($vendorDir . '/react/stream'),
|
||||
'React\\Socket' => array($vendorDir . '/react/socket'),
|
||||
'React\\EventLoop' => array($vendorDir . '/react/event-loop'),
|
||||
'Ratchet\\Tests' => array($vendorDir . '/cboden/ratchet/tests'),
|
||||
'Ratchet' => array($vendorDir . '/cboden/ratchet/src'),
|
||||
'Psr\\Log\\' => array($vendorDir . '/psr/log'),
|
||||
'Predis' => array($vendorDir . '/predis/predis/lib'),
|
||||
'Patchwork' => array($vendorDir . '/patchwork/utf8/class'),
|
||||
'PHPParser' => array($vendorDir . '/nikic/php-parser/lib'),
|
||||
'Normalizer' => array($vendorDir . '/patchwork/utf8/class'),
|
||||
'Monolog' => array($vendorDir . '/monolog/monolog/src'),
|
||||
'Illuminate' => array($vendorDir . '/laravel/framework/src'),
|
||||
'Guzzle\\Stream' => array($vendorDir . '/guzzle/stream'),
|
||||
'Guzzle\\Parser' => array($vendorDir . '/guzzle/parser'),
|
||||
'Guzzle\\Http' => array($vendorDir . '/guzzle/http'),
|
||||
'Guzzle\\Common' => array($vendorDir . '/guzzle/common'),
|
||||
'Evenement' => array($vendorDir . '/evenement/evenement/src'),
|
||||
'Doctrine\\DBAL' => array($vendorDir . '/doctrine/dbal/lib'),
|
||||
'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/lib'),
|
||||
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
|
||||
'Doctrine\\Common\\Collections\\' => array($vendorDir . '/doctrine/collections/lib'),
|
||||
'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib'),
|
||||
'Doctrine\\Common\\Annotations\\' => array($vendorDir . '/doctrine/annotations/lib'),
|
||||
'Doctrine\\Common\\' => array($vendorDir . '/doctrine/common/lib'),
|
||||
'ClassPreloader' => array($vendorDir . '/classpreloader/classpreloader/src'),
|
||||
'Carbon' => array($vendorDir . '/nesbot/carbon'),
|
||||
'Assetic' => array($vendorDir . '/kriswallsmith/assetic/src'),
|
||||
);
|
48
vendor/composer/autoload_real.php
vendored
48
vendor/composer/autoload_real.php
vendored
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
// autoload_real.php generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit97c5c8042cf61f3c9c7ef80776c5c224
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit97c5c8042cf61f3c9c7ef80776c5c224', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit97c5c8042cf61f3c9c7ef80776c5c224', 'loadClassLoader'));
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
require $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php';
|
||||
require $vendorDir . '/ircmaxell/password-compat/lib/password.php';
|
||||
require $vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php';
|
||||
require $vendorDir . '/kriswallsmith/assetic/src/functions.php';
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
2364
vendor/composer/installed.json
vendored
2364
vendor/composer/installed.json
vendored
File diff suppressed because it is too large
Load diff
1
vendor/doctrine/annotations/.gitignore
vendored
1
vendor/doctrine/annotations/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
vendor/
|
8
vendor/doctrine/annotations/.travis.yml
vendored
8
vendor/doctrine/annotations/.travis.yml
vendored
|
@ -1,8 +0,0 @@
|
|||
language: php
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
|
||||
before_script:
|
||||
- composer --prefer-source --dev install
|
9
vendor/doctrine/annotations/README.md
vendored
9
vendor/doctrine/annotations/README.md
vendored
|
@ -1,9 +0,0 @@
|
|||
# Doctrine Annotations
|
||||
|
||||
Docblock Annotations Parser library (extracted from Doctrine Common).
|
||||
|
||||
## Changelog
|
||||
|
||||
### v1.1
|
||||
|
||||
* Add Exception when ZendOptimizer+ or Opcache is configured to drop comments
|
30
vendor/doctrine/annotations/composer.json
vendored
30
vendor/doctrine/annotations/composer.json
vendored
|
@ -1,30 +0,0 @@
|
|||
{
|
||||
"name": "doctrine/annotations",
|
||||
"type": "library",
|
||||
"description": "Docblock Annotations Parser",
|
||||
"keywords": ["annotations", "docblock", "parser"],
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
|
||||
{"name": "Roman Borschel", "email": "roman@code-factory.org"},
|
||||
{"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"},
|
||||
{"name": "Jonathan Wage", "email": "jonwage@gmail.com"},
|
||||
{"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.2",
|
||||
"doctrine/lexer": "1.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/cache": "1.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Doctrine\\Common\\Annotations\\": "lib/" }
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
129
vendor/doctrine/annotations/composer.lock
generated
vendored
129
vendor/doctrine/annotations/composer.lock
generated
vendored
|
@ -1,129 +0,0 @@
|
|||
{
|
||||
"hash": "cacabc211410ba4430f0cadc8cc70667",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/lexer",
|
||||
"version": "v1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/lexer.git",
|
||||
"reference": "v1.0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/doctrine/lexer/archive/v1.0.zip",
|
||||
"reference": "v1.0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"time": "2013-01-12 18:59:04",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\Common\\Lexer\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com",
|
||||
"homepage": "http://www.instaclick.com"
|
||||
},
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com",
|
||||
"homepage": "https://github.com/schmittjoh",
|
||||
"role": "Developer of wrapped JMSSerializerBundle"
|
||||
}
|
||||
],
|
||||
"description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"parser",
|
||||
"lexer"
|
||||
]
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "doctrine/cache",
|
||||
"version": "v1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/cache.git",
|
||||
"reference": "v1.0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/doctrine/cache/archive/v1.0.zip",
|
||||
"reference": "v1.0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"time": "2013-01-10 22:43:46",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\Common\\Cache\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com",
|
||||
"homepage": "http://www.jwage.com/"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com",
|
||||
"homepage": "http://www.instaclick.com"
|
||||
},
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com",
|
||||
"homepage": "https://github.com/schmittjoh",
|
||||
"role": "Developer of wrapped JMSSerializerBundle"
|
||||
}
|
||||
],
|
||||
"description": "Caching library offering an object-oriented API for many cache backends",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"caching"
|
||||
]
|
||||
}
|
||||
],
|
||||
"aliases": [
|
||||
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [
|
||||
|
||||
]
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
/**
|
||||
* Annotations class
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
*/
|
||||
class Annotation
|
||||
{
|
||||
/**
|
||||
* Value property. Common among all derived classes.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $data Key-value for properties to be defined in this class
|
||||
*/
|
||||
public final function __construct(array $data)
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error handler for unknown property accessor in Annotation class.
|
||||
*
|
||||
* @param string $name Unknown property name
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
throw new \BadMethodCallException(
|
||||
sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error handler for unknown property mutator in Annotation class.
|
||||
*
|
||||
* @param string $name Unkown property name
|
||||
* @param mixed $value Property value
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
throw new \BadMethodCallException(
|
||||
sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
/**
|
||||
* Annotation that can be used to signal to the parser
|
||||
* to check the attribute type during the parsing process.
|
||||
*
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
final class Attribute
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
public $required = false;
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
/**
|
||||
* Annotation that can be used to signal to the parser
|
||||
* to check the types of all declared attributes during the parsing process.
|
||||
*
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
final class Attributes
|
||||
{
|
||||
/**
|
||||
* @var array<Doctrine\Common\Annotations\Annotation\Attribute>
|
||||
*/
|
||||
public $value;
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
/**
|
||||
* Annotation that can be used to signal to the parser
|
||||
* to check the available values during the parsing process.
|
||||
*
|
||||
* @since 2.4
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*
|
||||
* @Annotation
|
||||
* @Attributes({
|
||||
* @Attribute("value", required = true, type = "array"),
|
||||
* @Attribute("literal", required = false, type = "array")
|
||||
* })
|
||||
*/
|
||||
final class Enum
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* Literal target declaration.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $literal;
|
||||
|
||||
/**
|
||||
* Annotation construct
|
||||
*
|
||||
* @param array $values
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $values)
|
||||
{
|
||||
if ( ! isset($values['literal'])) {
|
||||
$values['literal'] = array();
|
||||
}
|
||||
|
||||
foreach ($values['value'] as $var) {
|
||||
if( ! is_scalar($var)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'@Enum supports only scalar values "%s" given.',
|
||||
is_object($var) ? get_class($var) : gettype($var)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($values['literal'] as $key => $var) {
|
||||
if( ! in_array($key, $values['value'])) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'Undefined enumerator value "%s" for literal "%s".',
|
||||
$key , $var
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$this->value = $values['value'];
|
||||
$this->literal = $values['literal'];
|
||||
}
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
/**
|
||||
* Annotation that can be used to signal to the parser to ignore specific
|
||||
* annotations during the parsing process.
|
||||
*
|
||||
* @Annotation
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
final class IgnoreAnnotation
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $names;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $values
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function __construct(array $values)
|
||||
{
|
||||
if (is_string($values['value'])) {
|
||||
$values['value'] = array($values['value']);
|
||||
}
|
||||
if (!is_array($values['value'])) {
|
||||
throw new \RuntimeException(sprintf('@IgnoreAnnotation expects either a string name, or an array of strings, but got %s.', json_encode($values['value'])));
|
||||
}
|
||||
|
||||
$this->names = $values['value'];
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
/**
|
||||
* Annotation that can be used to signal to the parser
|
||||
* to check if that attribute is required during the parsing process.
|
||||
*
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
final class Required
|
||||
{
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
/**
|
||||
* Annotation that can be used to signal to the parser
|
||||
* to check the annotation target during the parsing process.
|
||||
*
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
final class Target
|
||||
{
|
||||
const TARGET_CLASS = 1;
|
||||
const TARGET_METHOD = 2;
|
||||
const TARGET_PROPERTY = 4;
|
||||
const TARGET_ANNOTATION = 8;
|
||||
const TARGET_ALL = 15;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $map = array(
|
||||
'ALL' => self::TARGET_ALL,
|
||||
'CLASS' => self::TARGET_CLASS,
|
||||
'METHOD' => self::TARGET_METHOD,
|
||||
'PROPERTY' => self::TARGET_PROPERTY,
|
||||
'ANNOTATION' => self::TARGET_ANNOTATION,
|
||||
);
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* Targets as bitmask.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $targets;
|
||||
|
||||
/**
|
||||
* Literal target declaration.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $literal;
|
||||
|
||||
/**
|
||||
* Annotation construct
|
||||
*
|
||||
* @param array $values
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $values)
|
||||
{
|
||||
if (!isset($values['value'])){
|
||||
$values['value'] = null;
|
||||
}
|
||||
if (is_string($values['value'])){
|
||||
$values['value'] = array($values['value']);
|
||||
}
|
||||
if (!is_array($values['value'])){
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf('@Target expects either a string value, or an array of strings, "%s" given.',
|
||||
is_object($values['value']) ? get_class($values['value']) : gettype($values['value'])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$bitmask = 0;
|
||||
foreach ($values['value'] as $literal) {
|
||||
if(!isset(self::$map[$literal])){
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf('Invalid Target "%s". Available targets: [%s]',
|
||||
$literal, implode(', ', array_keys(self::$map)))
|
||||
);
|
||||
}
|
||||
$bitmask += self::$map[$literal];
|
||||
}
|
||||
|
||||
$this->targets = $bitmask;
|
||||
$this->value = $values['value'];
|
||||
$this->literal = implode(', ', $this->value);
|
||||
}
|
||||
}
|
|
@ -1,158 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
/**
|
||||
* Description of AnnotationException
|
||||
*
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
*/
|
||||
class AnnotationException extends \Exception
|
||||
{
|
||||
/**
|
||||
* Creates a new AnnotationException describing a Syntax error.
|
||||
*
|
||||
* @param string $message Exception message
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function syntaxError($message)
|
||||
{
|
||||
return new self('[Syntax Error] ' . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AnnotationException describing a Semantical error.
|
||||
*
|
||||
* @param string $message Exception message
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function semanticalError($message)
|
||||
{
|
||||
return new self('[Semantical Error] ' . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AnnotationException describing a constant semantical error.
|
||||
*
|
||||
* @since 2.3
|
||||
* @param string $identifier
|
||||
* @param string $context
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function semanticalErrorConstants($identifier, $context = null)
|
||||
{
|
||||
return self::semanticalError(sprintf(
|
||||
"Couldn't find constant %s%s", $identifier,
|
||||
$context ? ", $context." : "."
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AnnotationException describing an error which occurred during
|
||||
* the creation of the annotation.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $message
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function creationError($message)
|
||||
{
|
||||
return new self('[Creation Error] ' . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AnnotationException describing an type error of an attribute.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $attributeName
|
||||
* @param string $annotationName
|
||||
* @param string $context
|
||||
* @param string $expected
|
||||
* @param mixed $actual
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function typeError($attributeName, $annotationName, $context, $expected, $actual)
|
||||
{
|
||||
return new self(sprintf(
|
||||
'[Type Error] Attribute "%s" of @%s declared on %s expects %s, but got %s.',
|
||||
$attributeName,
|
||||
$annotationName,
|
||||
$context,
|
||||
$expected,
|
||||
is_object($actual) ? 'an instance of '.get_class($actual) : gettype($actual)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AnnotationException describing an required error of an attribute.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $attributeName
|
||||
* @param string $annotationName
|
||||
* @param string $context
|
||||
* @param string $expected
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function requiredError($attributeName, $annotationName, $context, $expected)
|
||||
{
|
||||
return new self(sprintf(
|
||||
'[Type Error] Attribute "%s" of @%s declared on %s expects %s. This value should not be null.',
|
||||
$attributeName,
|
||||
$annotationName,
|
||||
$context,
|
||||
$expected
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AnnotationException describing a invalid enummerator.
|
||||
*
|
||||
* @since 2.4
|
||||
* @param string $attributeName
|
||||
* @param string $annotationName
|
||||
* @param string $context
|
||||
* @param array $available
|
||||
* @param mixed $given
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function enumeratorError($attributeName, $annotationName, $context, $available, $given)
|
||||
{
|
||||
throw new self(sprintf(
|
||||
'[Enum Error] Attribute "%s" of @%s declared on %s accept only [%s], but got %s.',
|
||||
$attributeName,
|
||||
$annotationName,
|
||||
$context,
|
||||
implode(', ', $available),
|
||||
is_object($given) ? get_class($given) : $given
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function optimizerPlusSaveComments()
|
||||
{
|
||||
throw new self("You have to enable opcache.save_comments=1 or zend_optimizerplus.save_comments=1.");
|
||||
}
|
||||
}
|
|
@ -1,318 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use Closure;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use ReflectionProperty;
|
||||
|
||||
/**
|
||||
* A reader for docblock annotations.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class AnnotationReader implements Reader
|
||||
{
|
||||
/**
|
||||
* Global map for imports.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $globalImports = array(
|
||||
'ignoreannotation' => 'Doctrine\Common\Annotations\Annotation\IgnoreAnnotation',
|
||||
);
|
||||
|
||||
/**
|
||||
* A list with annotations that are not causing exceptions when not resolved to an annotation class.
|
||||
*
|
||||
* The names are case sensitive.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $globalIgnoredNames = array(
|
||||
'access'=> true, 'author'=> true, 'copyright'=> true, 'deprecated'=> true,
|
||||
'example'=> true, 'ignore'=> true, 'internal'=> true, 'link'=> true, 'see'=> true,
|
||||
'since'=> true, 'tutorial'=> true, 'version'=> true, 'package'=> true,
|
||||
'subpackage'=> true, 'name'=> true, 'global'=> true, 'param'=> true,
|
||||
'return'=> true, 'staticvar'=> true, 'category'=> true, 'staticVar'=> true,
|
||||
'static'=> true, 'var'=> true, 'throws'=> true, 'inheritdoc'=> true,
|
||||
'inheritDoc'=> true, 'license'=> true, 'todo'=> true, 'TODO'=> true,
|
||||
'deprec'=> true, 'property' => true, 'method' => true,
|
||||
'abstract'=> true, 'exception'=> true, 'magic' => true, 'api' => true,
|
||||
'final'=> true, 'filesource'=> true, 'throw' => true, 'uses' => true,
|
||||
'usedby'=> true, 'private' => true, 'Annotation' => true, 'override' => true,
|
||||
'codeCoverageIgnore' => true, 'codeCoverageIgnoreStart' => true, 'codeCoverageIgnoreEnd' => true,
|
||||
'Required' => true, 'Attribute' => true, 'Attributes' => true,
|
||||
'Target' => true, 'SuppressWarnings' => true,
|
||||
'ingroup' => true, 'code' => true, 'endcode' => true,
|
||||
'package_version' => true, 'fixme' => true
|
||||
);
|
||||
|
||||
/**
|
||||
* Add a new annotation to the globally ignored annotation names with regard to exception handling.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
static public function addGlobalIgnoredName($name)
|
||||
{
|
||||
self::$globalIgnoredNames[$name] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Annotations Parser
|
||||
*
|
||||
* @var \Doctrine\Common\Annotations\DocParser
|
||||
*/
|
||||
private $parser;
|
||||
|
||||
/**
|
||||
* Annotations Parser used to collect parsing metadata
|
||||
*
|
||||
* @var \Doctrine\Common\Annotations\DocParser
|
||||
*/
|
||||
private $preParser;
|
||||
|
||||
/**
|
||||
* PHP Parser used to collect imports.
|
||||
*
|
||||
* @var \Doctrine\Common\Annotations\PhpParser
|
||||
*/
|
||||
private $phpParser;
|
||||
|
||||
/**
|
||||
* In-memory cache mechanism to store imported annotations per class.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $imports = array();
|
||||
|
||||
/**
|
||||
* In-memory cache mechanism to store ignored annotations per class.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $ignoredAnnotationNames = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Initializes a new AnnotationReader.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.save_comments') === "0" || ini_get('opcache.save_comments') === "0")) {
|
||||
throw AnnotationException::optimizerPlusSaveComments();
|
||||
}
|
||||
|
||||
if (extension_loaded('opcache') && ini_get('opcache.save_comments') == 0) {
|
||||
throw AnnotationException::optimizerPlusSaveComments();
|
||||
}
|
||||
|
||||
AnnotationRegistry::registerFile(__DIR__ . '/Annotation/IgnoreAnnotation.php');
|
||||
|
||||
$this->parser = new DocParser;
|
||||
|
||||
$this->preParser = new DocParser;
|
||||
$this->preParser->setImports(self::$globalImports);
|
||||
$this->preParser->setIgnoreNotImportedAnnotations(true);
|
||||
|
||||
$this->phpParser = new PhpParser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the annotations applied to a class.
|
||||
*
|
||||
* @param ReflectionClass $class The ReflectionClass of the class from which
|
||||
* the class annotations should be read.
|
||||
* @return array An array of Annotations.
|
||||
*/
|
||||
public function getClassAnnotations(ReflectionClass $class)
|
||||
{
|
||||
$this->parser->setTarget(Target::TARGET_CLASS);
|
||||
$this->parser->setImports($this->getImports($class));
|
||||
$this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
|
||||
|
||||
return $this->parser->parse($class->getDocComment(), 'class ' . $class->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a class annotation.
|
||||
*
|
||||
* @param ReflectionClass $class The ReflectionClass of the class from which
|
||||
* the class annotations should be read.
|
||||
* @param string $annotationName The name of the annotation.
|
||||
* @return mixed The Annotation or NULL, if the requested annotation does not exist.
|
||||
*/
|
||||
public function getClassAnnotation(ReflectionClass $class, $annotationName)
|
||||
{
|
||||
$annotations = $this->getClassAnnotations($class);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof $annotationName) {
|
||||
return $annotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the annotations applied to a property.
|
||||
*
|
||||
* @param ReflectionProperty $property The ReflectionProperty of the property
|
||||
* from which the annotations should be read.
|
||||
* @return array An array of Annotations.
|
||||
*/
|
||||
public function getPropertyAnnotations(ReflectionProperty $property)
|
||||
{
|
||||
$class = $property->getDeclaringClass();
|
||||
$context = 'property ' . $class->getName() . "::\$" . $property->getName();
|
||||
$this->parser->setTarget(Target::TARGET_PROPERTY);
|
||||
$this->parser->setImports($this->getImports($class));
|
||||
$this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
|
||||
|
||||
return $this->parser->parse($property->getDocComment(), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a property annotation.
|
||||
*
|
||||
* @param ReflectionProperty $property
|
||||
* @param string $annotationName The name of the annotation.
|
||||
* @return mixed The Annotation or NULL, if the requested annotation does not exist.
|
||||
*/
|
||||
public function getPropertyAnnotation(ReflectionProperty $property, $annotationName)
|
||||
{
|
||||
$annotations = $this->getPropertyAnnotations($property);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof $annotationName) {
|
||||
return $annotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the annotations applied to a method.
|
||||
*
|
||||
* @param \ReflectionMethod $method The ReflectionMethod of the method from which
|
||||
* the annotations should be read.
|
||||
*
|
||||
* @return array An array of Annotations.
|
||||
*/
|
||||
public function getMethodAnnotations(ReflectionMethod $method)
|
||||
{
|
||||
$class = $method->getDeclaringClass();
|
||||
$context = 'method ' . $class->getName() . '::' . $method->getName() . '()';
|
||||
$this->parser->setTarget(Target::TARGET_METHOD);
|
||||
$this->parser->setImports($this->getImports($class));
|
||||
$this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
|
||||
|
||||
return $this->parser->parse($method->getDocComment(), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a method annotation.
|
||||
*
|
||||
* @param ReflectionMethod $method
|
||||
* @param string $annotationName The name of the annotation.
|
||||
* @return mixed The Annotation or NULL, if the requested annotation does not exist.
|
||||
*/
|
||||
public function getMethodAnnotation(ReflectionMethod $method, $annotationName)
|
||||
{
|
||||
$annotations = $this->getMethodAnnotations($method);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof $annotationName) {
|
||||
return $annotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ignored annotations for the given class.
|
||||
*
|
||||
* @param ReflectionClass $class
|
||||
* @return array
|
||||
*/
|
||||
private function getIgnoredAnnotationNames(ReflectionClass $class)
|
||||
{
|
||||
if (isset($this->ignoredAnnotationNames[$name = $class->getName()])) {
|
||||
return $this->ignoredAnnotationNames[$name];
|
||||
}
|
||||
$this->collectParsingMetadata($class);
|
||||
|
||||
return $this->ignoredAnnotationNames[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve imports
|
||||
*
|
||||
* @param \ReflectionClass $class
|
||||
* @return array
|
||||
*/
|
||||
private function getImports(ReflectionClass $class)
|
||||
{
|
||||
if (isset($this->imports[$name = $class->getName()])) {
|
||||
return $this->imports[$name];
|
||||
}
|
||||
$this->collectParsingMetadata($class);
|
||||
|
||||
return $this->imports[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects parsing metadata for a given class
|
||||
*
|
||||
* @param ReflectionClass $class
|
||||
*/
|
||||
private function collectParsingMetadata(ReflectionClass $class)
|
||||
{
|
||||
$ignoredAnnotationNames = self::$globalIgnoredNames;
|
||||
|
||||
$annotations = $this->preParser->parse($class->getDocComment(), 'class '.$class->name);
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof IgnoreAnnotation) {
|
||||
foreach ($annotation->names AS $annot) {
|
||||
$ignoredAnnotationNames[$annot] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$name = $class->getName();
|
||||
$this->imports[$name] = array_merge(
|
||||
self::$globalImports,
|
||||
$this->phpParser->parseClass($class),
|
||||
array('__NAMESPACE__' => $class->getNamespaceName())
|
||||
);
|
||||
$this->ignoredAnnotationNames[$name] = $ignoredAnnotationNames;
|
||||
}
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
/**
|
||||
* AnnotationRegistry
|
||||
*/
|
||||
final class AnnotationRegistry
|
||||
{
|
||||
/**
|
||||
* A map of namespaces to use for autoloading purposes based on a PSR-0 convention.
|
||||
*
|
||||
* Contains the namespace as key and an array of directories as value. If the value is NULL
|
||||
* the include path is used for checking for the corresponding file.
|
||||
*
|
||||
* This autoloading mechanism does not utilize the PHP autoloading but implements autoloading on its own.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static private $autoloadNamespaces = array();
|
||||
|
||||
/**
|
||||
* A map of autoloader callables.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static private $loaders = array();
|
||||
|
||||
static public function reset()
|
||||
{
|
||||
self::$autoloadNamespaces = array();
|
||||
self::$loaders = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register file
|
||||
*
|
||||
* @param string $file
|
||||
*/
|
||||
static public function registerFile($file)
|
||||
{
|
||||
require_once $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a namespace with one or many directories to look for files or null for the include path.
|
||||
*
|
||||
* Loading of this namespaces will be done with a PSR-0 namespace loading algorithm.
|
||||
*
|
||||
* @param string $namespace
|
||||
* @param string|array|null $dirs
|
||||
*/
|
||||
static public function registerAutoloadNamespace($namespace, $dirs = null)
|
||||
{
|
||||
self::$autoloadNamespaces[$namespace] = $dirs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register multiple namespaces
|
||||
*
|
||||
* Loading of this namespaces will be done with a PSR-0 namespace loading algorithm.
|
||||
*
|
||||
* @param array $namespaces
|
||||
*/
|
||||
static public function registerAutoloadNamespaces(array $namespaces)
|
||||
{
|
||||
self::$autoloadNamespaces = array_merge(self::$autoloadNamespaces, $namespaces);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an autoloading callable for annotations, much like spl_autoload_register().
|
||||
*
|
||||
* NOTE: These class loaders HAVE to be silent when a class was not found!
|
||||
* IMPORTANT: Loaders have to return true if they loaded a class that could contain the searched annotation class.
|
||||
*
|
||||
* @param callable $callable
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
static public function registerLoader($callable)
|
||||
{
|
||||
if (!is_callable($callable)) {
|
||||
throw new \InvalidArgumentException("A callable is expected in AnnotationRegistry::registerLoader().");
|
||||
}
|
||||
self::$loaders[] = $callable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoload an annotation class silently.
|
||||
*
|
||||
* @param string $class
|
||||
* @return boolean
|
||||
*/
|
||||
static public function loadAnnotationClass($class)
|
||||
{
|
||||
foreach (self::$autoloadNamespaces AS $namespace => $dirs) {
|
||||
if (strpos($class, $namespace) === 0) {
|
||||
$file = str_replace("\\", DIRECTORY_SEPARATOR, $class) . ".php";
|
||||
if ($dirs === null) {
|
||||
if ($path = stream_resolve_include_path($file)) {
|
||||
require $path;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
foreach((array)$dirs AS $dir) {
|
||||
if (is_file($dir . DIRECTORY_SEPARATOR . $file)) {
|
||||
require $dir . DIRECTORY_SEPARATOR . $file;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (self::$loaders AS $loader) {
|
||||
if (call_user_func($loader, $class) === true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,250 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
|
||||
/**
|
||||
* A cache aware annotation reader.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
final class CachedReader implements Reader
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private static $CACHE_SALT = '@[Annot]';
|
||||
|
||||
/**
|
||||
* @var Reader
|
||||
*/
|
||||
private $delegate;
|
||||
|
||||
/**
|
||||
* @var Cache
|
||||
*/
|
||||
private $cache;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
private $debug;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $loadedAnnotations;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Reader $reader
|
||||
* @param Cache $cache
|
||||
* @param bool $debug
|
||||
*/
|
||||
public function __construct(Reader $reader, Cache $cache, $debug = false)
|
||||
{
|
||||
$this->delegate = $reader;
|
||||
$this->cache = $cache;
|
||||
$this->debug = (Boolean) $debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get annotations for class
|
||||
*
|
||||
* @param \ReflectionClass $class
|
||||
* @return array
|
||||
*/
|
||||
public function getClassAnnotations(\ReflectionClass $class)
|
||||
{
|
||||
$cacheKey = $class->getName();
|
||||
|
||||
if (isset($this->loadedAnnotations[$cacheKey])) {
|
||||
return $this->loadedAnnotations[$cacheKey];
|
||||
}
|
||||
|
||||
if (false === ($annots = $this->fetchFromCache($cacheKey, $class))) {
|
||||
$annots = $this->delegate->getClassAnnotations($class);
|
||||
$this->saveToCache($cacheKey, $annots);
|
||||
}
|
||||
|
||||
return $this->loadedAnnotations[$cacheKey] = $annots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selected annotation for class
|
||||
*
|
||||
* @param \ReflectionClass $class
|
||||
* @param string $annotationName
|
||||
* @return null
|
||||
*/
|
||||
public function getClassAnnotation(\ReflectionClass $class, $annotationName)
|
||||
{
|
||||
foreach ($this->getClassAnnotations($class) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get annotations for property
|
||||
*
|
||||
* @param \ReflectionProperty $property
|
||||
* @return array
|
||||
*/
|
||||
public function getPropertyAnnotations(\ReflectionProperty $property)
|
||||
{
|
||||
$class = $property->getDeclaringClass();
|
||||
$cacheKey = $class->getName().'$'.$property->getName();
|
||||
|
||||
if (isset($this->loadedAnnotations[$cacheKey])) {
|
||||
return $this->loadedAnnotations[$cacheKey];
|
||||
}
|
||||
|
||||
if (false === ($annots = $this->fetchFromCache($cacheKey, $class))) {
|
||||
$annots = $this->delegate->getPropertyAnnotations($property);
|
||||
$this->saveToCache($cacheKey, $annots);
|
||||
}
|
||||
|
||||
return $this->loadedAnnotations[$cacheKey] = $annots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selected annotation for property
|
||||
*
|
||||
* @param \ReflectionProperty $property
|
||||
* @param string $annotationName
|
||||
* @return null
|
||||
*/
|
||||
public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName)
|
||||
{
|
||||
foreach ($this->getPropertyAnnotations($property) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get method annotations
|
||||
*
|
||||
* @param \ReflectionMethod $method
|
||||
* @return array
|
||||
*/
|
||||
public function getMethodAnnotations(\ReflectionMethod $method)
|
||||
{
|
||||
$class = $method->getDeclaringClass();
|
||||
$cacheKey = $class->getName().'#'.$method->getName();
|
||||
|
||||
if (isset($this->loadedAnnotations[$cacheKey])) {
|
||||
return $this->loadedAnnotations[$cacheKey];
|
||||
}
|
||||
|
||||
if (false === ($annots = $this->fetchFromCache($cacheKey, $class))) {
|
||||
$annots = $this->delegate->getMethodAnnotations($method);
|
||||
$this->saveToCache($cacheKey, $annots);
|
||||
}
|
||||
|
||||
return $this->loadedAnnotations[$cacheKey] = $annots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selected method annotation
|
||||
*
|
||||
* @param \ReflectionMethod $method
|
||||
* @param string $annotationName
|
||||
* @return null
|
||||
*/
|
||||
public function getMethodAnnotation(\ReflectionMethod $method, $annotationName)
|
||||
{
|
||||
foreach ($this->getMethodAnnotations($method) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear loaded annotations
|
||||
*/
|
||||
public function clearLoadedAnnotations()
|
||||
{
|
||||
$this->loadedAnnotations = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a value from the cache.
|
||||
*
|
||||
* @param string $rawCacheKey The cache key.
|
||||
* @param \ReflectionClass $class The related class.
|
||||
* @return mixed|boolean The cached value or false when the value is not in cache.
|
||||
*/
|
||||
private function fetchFromCache($rawCacheKey, \ReflectionClass $class)
|
||||
{
|
||||
$cacheKey = $rawCacheKey . self::$CACHE_SALT;
|
||||
if (($data = $this->cache->fetch($cacheKey)) !== false) {
|
||||
if (!$this->debug || $this->isCacheFresh($cacheKey, $class)) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a value to the cache
|
||||
*
|
||||
* @param string $rawCacheKey The cache key.
|
||||
* @param mixed $value The value.
|
||||
*/
|
||||
private function saveToCache($rawCacheKey, $value)
|
||||
{
|
||||
$cacheKey = $rawCacheKey . self::$CACHE_SALT;
|
||||
$this->cache->save($cacheKey, $value);
|
||||
if ($this->debug) {
|
||||
$this->cache->save('[C]'.$cacheKey, time());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if cache is fresh
|
||||
*
|
||||
* @param string $cacheKey
|
||||
* @param \ReflectionClass $class
|
||||
* @return bool
|
||||
*/
|
||||
private function isCacheFresh($cacheKey, \ReflectionClass $class)
|
||||
{
|
||||
if (false === $filename = $class->getFilename()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->cache->fetch('[C]'.$cacheKey) >= filemtime($filename);
|
||||
}
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Lexer\AbstractLexer;
|
||||
|
||||
/**
|
||||
* Simple lexer for docblock annotations.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
final class DocLexer extends AbstractLexer
|
||||
{
|
||||
const T_NONE = 1;
|
||||
const T_INTEGER = 2;
|
||||
const T_STRING = 3;
|
||||
const T_FLOAT = 4;
|
||||
|
||||
// All tokens that are also identifiers should be >= 100
|
||||
const T_IDENTIFIER = 100;
|
||||
const T_AT = 101;
|
||||
const T_CLOSE_CURLY_BRACES = 102;
|
||||
const T_CLOSE_PARENTHESIS = 103;
|
||||
const T_COMMA = 104;
|
||||
const T_EQUALS = 105;
|
||||
const T_FALSE = 106;
|
||||
const T_NAMESPACE_SEPARATOR = 107;
|
||||
const T_OPEN_CURLY_BRACES = 108;
|
||||
const T_OPEN_PARENTHESIS = 109;
|
||||
const T_TRUE = 110;
|
||||
const T_NULL = 111;
|
||||
const T_COLON = 112;
|
||||
|
||||
protected $noCase = array(
|
||||
'@' => self::T_AT,
|
||||
',' => self::T_COMMA,
|
||||
'(' => self::T_OPEN_PARENTHESIS,
|
||||
')' => self::T_CLOSE_PARENTHESIS,
|
||||
'{' => self::T_OPEN_CURLY_BRACES,
|
||||
'}' => self::T_CLOSE_CURLY_BRACES,
|
||||
'=' => self::T_EQUALS,
|
||||
':' => self::T_COLON,
|
||||
'\\' => self::T_NAMESPACE_SEPARATOR
|
||||
);
|
||||
|
||||
protected $withCase = array(
|
||||
'true' => self::T_TRUE,
|
||||
'false' => self::T_FALSE,
|
||||
'null' => self::T_NULL
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getCatchablePatterns()
|
||||
{
|
||||
return array(
|
||||
'[a-z_\\\][a-z0-9_\:\\\]*[a-z]{1}',
|
||||
'(?:[+-]?[0-9]+(?:[\.][0-9]+)*)(?:[eE][+-]?[0-9]+)?',
|
||||
'"(?:[^"]|"")*"',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getNonCatchablePatterns()
|
||||
{
|
||||
return array('\s+', '\*+', '(.)');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getType(&$value)
|
||||
{
|
||||
$type = self::T_NONE;
|
||||
|
||||
if ($value[0] === '"') {
|
||||
$value = str_replace('""', '"', substr($value, 1, strlen($value) - 2));
|
||||
|
||||
return self::T_STRING;
|
||||
}
|
||||
|
||||
if (isset($this->noCase[$value])) {
|
||||
return $this->noCase[$value];
|
||||
}
|
||||
|
||||
if ($value[0] === '_' || $value[0] === '\\' || ctype_alpha($value[0])) {
|
||||
return self::T_IDENTIFIER;
|
||||
}
|
||||
|
||||
$lowerValue = strtolower($value);
|
||||
|
||||
if (isset($this->withCase[$lowerValue])) {
|
||||
return $this->withCase[$lowerValue];
|
||||
}
|
||||
|
||||
// Checking numeric value
|
||||
if (is_numeric($value)) {
|
||||
return (strpos($value, '.') !== false || stripos($value, 'e') !== false)
|
||||
? self::T_FLOAT : self::T_INTEGER;
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,269 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
|
||||
/**
|
||||
* File cache reader for annotations.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class FileCacheReader implements Reader
|
||||
{
|
||||
/**
|
||||
* @var Reader
|
||||
*/
|
||||
private $reader;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $dir;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $debug;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $loadedAnnotations = array();
|
||||
|
||||
private $classNameHashes = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Reader $reader
|
||||
* @param string $cacheDir
|
||||
* @param bool $debug
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(Reader $reader, $cacheDir, $debug = false)
|
||||
{
|
||||
$this->reader = $reader;
|
||||
if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true)) {
|
||||
throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist and could not be created.', $cacheDir));
|
||||
}
|
||||
if (!is_writable($cacheDir)) {
|
||||
throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with "chmod +a". If your system does not support this, check out the acl package.', $cacheDir));
|
||||
}
|
||||
|
||||
$this->dir = rtrim($cacheDir, '\\/');
|
||||
$this->debug = $debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve annotations for class
|
||||
*
|
||||
* @param \ReflectionClass $class
|
||||
* @return array
|
||||
*/
|
||||
public function getClassAnnotations(\ReflectionClass $class)
|
||||
{
|
||||
if ( ! isset($this->classNameHashes[$class->name])) {
|
||||
$this->classNameHashes[$class->name] = sha1($class->name);
|
||||
}
|
||||
$key = $this->classNameHashes[$class->name];
|
||||
|
||||
if (isset($this->loadedAnnotations[$key])) {
|
||||
return $this->loadedAnnotations[$key];
|
||||
}
|
||||
|
||||
$path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php';
|
||||
if (!is_file($path)) {
|
||||
$annot = $this->reader->getClassAnnotations($class);
|
||||
$this->saveCacheFile($path, $annot);
|
||||
return $this->loadedAnnotations[$key] = $annot;
|
||||
}
|
||||
|
||||
if ($this->debug
|
||||
&& (false !== $filename = $class->getFilename())
|
||||
&& filemtime($path) < filemtime($filename)) {
|
||||
@unlink($path);
|
||||
|
||||
$annot = $this->reader->getClassAnnotations($class);
|
||||
$this->saveCacheFile($path, $annot);
|
||||
return $this->loadedAnnotations[$key] = $annot;
|
||||
}
|
||||
|
||||
return $this->loadedAnnotations[$key] = include $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get annotations for property
|
||||
*
|
||||
* @param \ReflectionProperty $property
|
||||
* @return array
|
||||
*/
|
||||
public function getPropertyAnnotations(\ReflectionProperty $property)
|
||||
{
|
||||
$class = $property->getDeclaringClass();
|
||||
if ( ! isset($this->classNameHashes[$class->name])) {
|
||||
$this->classNameHashes[$class->name] = sha1($class->name);
|
||||
}
|
||||
$key = $this->classNameHashes[$class->name].'$'.$property->getName();
|
||||
|
||||
if (isset($this->loadedAnnotations[$key])) {
|
||||
return $this->loadedAnnotations[$key];
|
||||
}
|
||||
|
||||
$path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php';
|
||||
if (!is_file($path)) {
|
||||
$annot = $this->reader->getPropertyAnnotations($property);
|
||||
$this->saveCacheFile($path, $annot);
|
||||
return $this->loadedAnnotations[$key] = $annot;
|
||||
}
|
||||
|
||||
if ($this->debug
|
||||
&& (false !== $filename = $class->getFilename())
|
||||
&& filemtime($path) < filemtime($filename)) {
|
||||
@unlink($path);
|
||||
|
||||
$annot = $this->reader->getPropertyAnnotations($property);
|
||||
$this->saveCacheFile($path, $annot);
|
||||
return $this->loadedAnnotations[$key] = $annot;
|
||||
}
|
||||
|
||||
return $this->loadedAnnotations[$key] = include $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve annotations for method
|
||||
*
|
||||
* @param \ReflectionMethod $method
|
||||
* @return array
|
||||
*/
|
||||
public function getMethodAnnotations(\ReflectionMethod $method)
|
||||
{
|
||||
$class = $method->getDeclaringClass();
|
||||
if ( ! isset($this->classNameHashes[$class->name])) {
|
||||
$this->classNameHashes[$class->name] = sha1($class->name);
|
||||
}
|
||||
$key = $this->classNameHashes[$class->name].'#'.$method->getName();
|
||||
|
||||
if (isset($this->loadedAnnotations[$key])) {
|
||||
return $this->loadedAnnotations[$key];
|
||||
}
|
||||
|
||||
$path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php';
|
||||
if (!is_file($path)) {
|
||||
$annot = $this->reader->getMethodAnnotations($method);
|
||||
$this->saveCacheFile($path, $annot);
|
||||
return $this->loadedAnnotations[$key] = $annot;
|
||||
}
|
||||
|
||||
if ($this->debug
|
||||
&& (false !== $filename = $class->getFilename())
|
||||
&& filemtime($path) < filemtime($filename)) {
|
||||
@unlink($path);
|
||||
|
||||
$annot = $this->reader->getMethodAnnotations($method);
|
||||
$this->saveCacheFile($path, $annot);
|
||||
return $this->loadedAnnotations[$key] = $annot;
|
||||
}
|
||||
|
||||
return $this->loadedAnnotations[$key] = include $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save cache file
|
||||
*
|
||||
* @param string $path
|
||||
* @param mixed $data
|
||||
*/
|
||||
private function saveCacheFile($path, $data)
|
||||
{
|
||||
file_put_contents($path, '<?php return unserialize('.var_export(serialize($data), true).');');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a class annotation.
|
||||
*
|
||||
* @param \ReflectionClass $class The ReflectionClass of the class from which
|
||||
* the class annotations should be read.
|
||||
* @param string $annotationName The name of the annotation.
|
||||
*
|
||||
* @return mixed The Annotation or NULL, if the requested annotation does not exist.
|
||||
*/
|
||||
public function getClassAnnotation(\ReflectionClass $class, $annotationName)
|
||||
{
|
||||
$annotations = $this->getClassAnnotations($class);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof $annotationName) {
|
||||
return $annotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a method annotation.
|
||||
*
|
||||
* @param \ReflectionMethod $method
|
||||
* @param string $annotationName The name of the annotation.
|
||||
* @return mixed The Annotation or NULL, if the requested annotation does not exist.
|
||||
*/
|
||||
public function getMethodAnnotation(\ReflectionMethod $method, $annotationName)
|
||||
{
|
||||
$annotations = $this->getMethodAnnotations($method);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof $annotationName) {
|
||||
return $annotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a property annotation.
|
||||
*
|
||||
* @param \ReflectionProperty $property
|
||||
* @param string $annotationName The name of the annotation.
|
||||
* @return mixed The Annotation or NULL, if the requested annotation does not exist.
|
||||
*/
|
||||
public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName)
|
||||
{
|
||||
$annotations = $this->getPropertyAnnotations($property);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof $annotationName) {
|
||||
return $annotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear stores annotations
|
||||
*/
|
||||
public function clearLoadedAnnotations()
|
||||
{
|
||||
$this->loadedAnnotations = array();
|
||||
}
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
|
||||
/**
|
||||
* Allows the reader to be used in-place of Doctrine's reader.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class IndexedReader implements Reader
|
||||
{
|
||||
/**
|
||||
* @var Reader
|
||||
*/
|
||||
private $delegate;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Reader $reader
|
||||
*/
|
||||
public function __construct(Reader $reader)
|
||||
{
|
||||
$this->delegate = $reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Annotations for class
|
||||
*
|
||||
* @param \ReflectionClass $class
|
||||
* @return array
|
||||
*/
|
||||
public function getClassAnnotations(\ReflectionClass $class)
|
||||
{
|
||||
$annotations = array();
|
||||
foreach ($this->delegate->getClassAnnotations($class) as $annot) {
|
||||
$annotations[get_class($annot)] = $annot;
|
||||
}
|
||||
|
||||
return $annotations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selected annotation for class
|
||||
*
|
||||
* @param \ReflectionClass $class
|
||||
* @param string $annotation
|
||||
* @return mixed
|
||||
*/
|
||||
public function getClassAnnotation(\ReflectionClass $class, $annotation)
|
||||
{
|
||||
return $this->delegate->getClassAnnotation($class, $annotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Annotations for method
|
||||
*
|
||||
* @param \ReflectionMethod $method
|
||||
* @return array
|
||||
*/
|
||||
public function getMethodAnnotations(\ReflectionMethod $method)
|
||||
{
|
||||
$annotations = array();
|
||||
foreach ($this->delegate->getMethodAnnotations($method) as $annot) {
|
||||
$annotations[get_class($annot)] = $annot;
|
||||
}
|
||||
|
||||
return $annotations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selected annotation for method
|
||||
*
|
||||
* @param \ReflectionMethod $method
|
||||
* @param string $annotation
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMethodAnnotation(\ReflectionMethod $method, $annotation)
|
||||
{
|
||||
return $this->delegate->getMethodAnnotation($method, $annotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get annotations for property
|
||||
*
|
||||
* @param \ReflectionProperty $property
|
||||
* @return array
|
||||
*/
|
||||
public function getPropertyAnnotations(\ReflectionProperty $property)
|
||||
{
|
||||
$annotations = array();
|
||||
foreach ($this->delegate->getPropertyAnnotations($property) as $annot) {
|
||||
$annotations[get_class($annot)] = $annot;
|
||||
}
|
||||
|
||||
return $annotations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selected annotation for property
|
||||
*
|
||||
* @param \ReflectionProperty $property
|
||||
* @param string $annotation
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPropertyAnnotation(\ReflectionProperty $property, $annotation)
|
||||
{
|
||||
return $this->delegate->getPropertyAnnotation($property, $annotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy all methods to the delegate.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
return call_user_func_array(array($this->delegate, $method), $args);
|
||||
}
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use SplFileObject;
|
||||
|
||||
/**
|
||||
* Parses a file for namespaces/use/class declarations.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Christian Kaps <christian.kaps@mohiva.com>
|
||||
*/
|
||||
final class PhpParser
|
||||
{
|
||||
/**
|
||||
* Parses a class.
|
||||
*
|
||||
* @param \ReflectionClass $class A <code>ReflectionClass</code> object.
|
||||
* @return array A list with use statements in the form (Alias => FQN).
|
||||
*/
|
||||
public function parseClass(\ReflectionClass $class)
|
||||
{
|
||||
if (method_exists($class, 'getUseStatements')) {
|
||||
return $class->getUseStatements();
|
||||
}
|
||||
|
||||
if (false === $filename = $class->getFilename()) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$content = $this->getFileContent($filename, $class->getStartLine());
|
||||
|
||||
if (null === $content) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$namespace = preg_quote($class->getNamespaceName());
|
||||
$content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content);
|
||||
$tokenizer = new TokenParser('<?php ' . $content);
|
||||
|
||||
$statements = $tokenizer->parseUseStatements($class->getNamespaceName());
|
||||
|
||||
return $statements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content of the file right up to the given line number.
|
||||
*
|
||||
* @param string $filename The name of the file to load.
|
||||
* @param int $lineNumber The number of lines to read from file.
|
||||
* @return string The content of the file.
|
||||
*/
|
||||
private function getFileContent($filename, $lineNumber)
|
||||
{
|
||||
if ( ! is_file($filename)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$content = '';
|
||||
$lineCnt = 0;
|
||||
$file = new SplFileObject($filename);
|
||||
while (!$file->eof()) {
|
||||
if ($lineCnt++ == $lineNumber) {
|
||||
break;
|
||||
}
|
||||
|
||||
$content .= $file->fgets();
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
/**
|
||||
* Interface for annotation readers.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
interface Reader
|
||||
{
|
||||
/**
|
||||
* @param \ReflectionClass $class
|
||||
* @return mixed
|
||||
*/
|
||||
function getClassAnnotations(\ReflectionClass $class);
|
||||
|
||||
/**
|
||||
* @param \ReflectionClass $class
|
||||
* @param string $annotationName
|
||||
* @return mixed
|
||||
*/
|
||||
function getClassAnnotation(\ReflectionClass $class, $annotationName);
|
||||
|
||||
/**
|
||||
* @param \ReflectionMethod $method
|
||||
* @return mixed
|
||||
*/
|
||||
function getMethodAnnotations(\ReflectionMethod $method);
|
||||
|
||||
/**
|
||||
* @param \ReflectionMethod $method
|
||||
* @param string $annotationName
|
||||
* @return mixed
|
||||
*/
|
||||
function getMethodAnnotation(\ReflectionMethod $method, $annotationName);
|
||||
|
||||
/**
|
||||
* @param \ReflectionProperty $property
|
||||
* @return mixed
|
||||
*/
|
||||
function getPropertyAnnotations(\ReflectionProperty $property);
|
||||
|
||||
/**
|
||||
* @param \ReflectionProperty $property
|
||||
* @param string $annotationName
|
||||
* @return mixed
|
||||
*/
|
||||
function getPropertyAnnotation(\ReflectionProperty $property, $annotationName);
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
|
||||
/**
|
||||
* Simple Annotation Reader.
|
||||
*
|
||||
* This annotation reader is intended to be used in projects where you have
|
||||
* full-control over all annotations that are available.
|
||||
*
|
||||
* @since 2.2
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*/
|
||||
class SimpleAnnotationReader implements Reader
|
||||
{
|
||||
/**
|
||||
* @var DocParser
|
||||
*/
|
||||
private $parser;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Initializes a new SimpleAnnotationReader.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->parser = new DocParser();
|
||||
$this->parser->setIgnoreNotImportedAnnotations(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a namespace in which we will look for annotations.
|
||||
*
|
||||
* @param string $namespace
|
||||
*/
|
||||
public function addNamespace($namespace)
|
||||
{
|
||||
$this->parser->addNamespace($namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the annotations applied to a class.
|
||||
*
|
||||
* @param \ReflectionClass $class The ReflectionClass of the class from which
|
||||
* the class annotations should be read.
|
||||
*
|
||||
* @return array An array of Annotations.
|
||||
*/
|
||||
public function getClassAnnotations(\ReflectionClass $class)
|
||||
{
|
||||
return $this->parser->parse($class->getDocComment(), 'class '.$class->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the annotations applied to a method.
|
||||
*
|
||||
* @param \ReflectionMethod $method The ReflectionMethod of the method from which
|
||||
* the annotations should be read.
|
||||
*
|
||||
* @return array An array of Annotations.
|
||||
*/
|
||||
public function getMethodAnnotations(\ReflectionMethod $method)
|
||||
{
|
||||
return $this->parser->parse($method->getDocComment(), 'method '.$method->getDeclaringClass()->name.'::'.$method->getName().'()');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the annotations applied to a property.
|
||||
*
|
||||
* @param \ReflectionProperty $property The ReflectionProperty of the property
|
||||
* from which the annotations should be read.
|
||||
*
|
||||
* @return array An array of Annotations.
|
||||
*/
|
||||
public function getPropertyAnnotations(\ReflectionProperty $property)
|
||||
{
|
||||
return $this->parser->parse($property->getDocComment(), 'property '.$property->getDeclaringClass()->name.'::$'.$property->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a class annotation.
|
||||
*
|
||||
* @param \ReflectionClass $class The ReflectionClass of the class from which
|
||||
* the class annotations should be read.
|
||||
* @param string $annotationName The name of the annotation.
|
||||
*
|
||||
* @return mixed The Annotation or NULL, if the requested annotation does not exist.
|
||||
*/
|
||||
public function getClassAnnotation(\ReflectionClass $class, $annotationName)
|
||||
{
|
||||
foreach ($this->getClassAnnotations($class) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a method annotation.
|
||||
*
|
||||
* @param \ReflectionMethod $method
|
||||
* @param string $annotationName The name of the annotation.
|
||||
*
|
||||
* @return mixed The Annotation or NULL, if the requested annotation does not exist.
|
||||
*/
|
||||
public function getMethodAnnotation(\ReflectionMethod $method, $annotationName)
|
||||
{
|
||||
foreach ($this->getMethodAnnotations($method) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a property annotation.
|
||||
*
|
||||
* @param \ReflectionProperty $property
|
||||
* @param string $annotationName The name of the annotation.
|
||||
* @return mixed The Annotation or NULL, if the requested annotation does not exist.
|
||||
*/
|
||||
public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName)
|
||||
{
|
||||
foreach ($this->getPropertyAnnotations($property) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,175 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
/**
|
||||
* Parses a file for namespaces/use/class declarations.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Christian Kaps <christian.kaps@mohiva.com>
|
||||
*/
|
||||
class TokenParser
|
||||
{
|
||||
/**
|
||||
* The token list.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $tokens;
|
||||
|
||||
/**
|
||||
* The number of tokens.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $numTokens = 0;
|
||||
|
||||
/**
|
||||
* The current array pointer.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $pointer = 0;
|
||||
|
||||
public function __construct($contents)
|
||||
{
|
||||
$this->tokens = token_get_all($contents);
|
||||
$this->numTokens = count($this->tokens);
|
||||
$this->pointer = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the next non whitespace and non comment token.
|
||||
*
|
||||
* @param $docCommentIsComment
|
||||
* If TRUE then a doc comment is considered a comment and skipped.
|
||||
* If FALSE then only whitespace and normal comments are skipped.
|
||||
*
|
||||
* @return array The token if exists, null otherwise.
|
||||
*/
|
||||
public function next($docCommentIsComment = TRUE)
|
||||
{
|
||||
for ($i = $this->pointer; $i < $this->numTokens; $i++) {
|
||||
$this->pointer++;
|
||||
if ($this->tokens[$i][0] === T_WHITESPACE ||
|
||||
$this->tokens[$i][0] === T_COMMENT ||
|
||||
($docCommentIsComment && $this->tokens[$i][0] === T_DOC_COMMENT)) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
return $this->tokens[$i];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a single use statement.
|
||||
*
|
||||
* @return array A list with all found class names for a use statement.
|
||||
*/
|
||||
public function parseUseStatement()
|
||||
{
|
||||
$class = '';
|
||||
$alias = '';
|
||||
$statements = array();
|
||||
$explicitAlias = false;
|
||||
while (($token = $this->next())) {
|
||||
$isNameToken = $token[0] === T_STRING || $token[0] === T_NS_SEPARATOR;
|
||||
if (!$explicitAlias && $isNameToken) {
|
||||
$class .= $token[1];
|
||||
$alias = $token[1];
|
||||
} else if ($explicitAlias && $isNameToken) {
|
||||
$alias .= $token[1];
|
||||
} else if ($token[0] === T_AS) {
|
||||
$explicitAlias = true;
|
||||
$alias = '';
|
||||
} else if ($token === ',') {
|
||||
$statements[strtolower($alias)] = $class;
|
||||
$class = '';
|
||||
$alias = '';
|
||||
$explicitAlias = false;
|
||||
} else if ($token === ';') {
|
||||
$statements[strtolower($alias)] = $class;
|
||||
break;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $statements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all use statements.
|
||||
*
|
||||
* @param string $namespaceName The namespace name of the reflected class.
|
||||
* @return array A list with all found use statements.
|
||||
*/
|
||||
public function parseUseStatements($namespaceName)
|
||||
{
|
||||
$statements = array();
|
||||
while (($token = $this->next())) {
|
||||
if ($token[0] === T_USE) {
|
||||
$statements = array_merge($statements, $this->parseUseStatement());
|
||||
continue;
|
||||
}
|
||||
if ($token[0] !== T_NAMESPACE || $this->parseNamespace() != $namespaceName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get fresh array for new namespace. This is to prevent the parser to collect the use statements
|
||||
// for a previous namespace with the same name. This is the case if a namespace is defined twice
|
||||
// or if a namespace with the same name is commented out.
|
||||
$statements = array();
|
||||
}
|
||||
|
||||
return $statements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the namespace.
|
||||
*
|
||||
* @return string The found namespace.
|
||||
*/
|
||||
public function parseNamespace()
|
||||
{
|
||||
$name = '';
|
||||
while (($token = $this->next()) && ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR)) {
|
||||
$name .= $token[1];
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class name.
|
||||
*
|
||||
* @return string The foundclass name.
|
||||
*/
|
||||
public function parseClass()
|
||||
{
|
||||
// Namespaces and class names are tokenized the same: T_STRINGs
|
||||
// separated by T_NS_SEPARATOR so we can use one function to provide
|
||||
// both.
|
||||
return $this->parseNamespace();
|
||||
}
|
||||
}
|
31
vendor/doctrine/annotations/phpunit.xml.dist
vendored
31
vendor/doctrine/annotations/phpunit.xml.dist
vendored
|
@ -1,31 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="./tests/Doctrine/Tests/TestInit.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Doctrine Annotations Test Suite">
|
||||
<directory>./tests/Doctrine/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./lib/Doctrine/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
<groups>
|
||||
<exclude>
|
||||
<group>performance</group>
|
||||
</exclude>
|
||||
</groups>
|
||||
</phpunit>
|
|
@ -1,571 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\DoctrineReader;
|
||||
use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
|
||||
use Doctrine\Common\Annotations\Annotation\IgnorePhpDoc;
|
||||
use ReflectionClass, Doctrine\Common\Annotations\AnnotationReader;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\DummyAnnotation;
|
||||
use Doctrine\Tests\Common\Annotations\Name;
|
||||
use Doctrine\Tests\Common\Annotations\DummyId;
|
||||
use Doctrine\Tests\Common\Annotations\DummyJoinTable;
|
||||
use Doctrine\Tests\Common\Annotations\DummyJoinColumn;
|
||||
use Doctrine\Tests\Common\Annotations\DummyColumn;
|
||||
use Doctrine\Tests\Common\Annotations\DummyGeneratedValue;
|
||||
|
||||
require_once __DIR__ . '/TopLevelAnnotation.php';
|
||||
|
||||
abstract class AbstractReaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function getReflectionClass()
|
||||
{
|
||||
$className = 'Doctrine\Tests\Common\Annotations\DummyClass';
|
||||
return new ReflectionClass($className);
|
||||
}
|
||||
|
||||
public function testAnnotations()
|
||||
{
|
||||
$class = $this->getReflectionClass();
|
||||
$reader = $this->getReader();
|
||||
|
||||
$this->assertEquals(1, count($reader->getClassAnnotations($class)));
|
||||
$this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyAnnotation', $annot = $reader->getClassAnnotation($class, $annotName));
|
||||
$this->assertEquals("hello", $annot->dummyValue);
|
||||
|
||||
$field1Prop = $class->getProperty('field1');
|
||||
$propAnnots = $reader->getPropertyAnnotations($field1Prop);
|
||||
$this->assertEquals(1, count($propAnnots));
|
||||
$this->assertInstanceOf($annotName, $annot = $reader->getPropertyAnnotation($field1Prop, $annotName));
|
||||
$this->assertEquals("fieldHello", $annot->dummyValue);
|
||||
|
||||
$getField1Method = $class->getMethod('getField1');
|
||||
$methodAnnots = $reader->getMethodAnnotations($getField1Method);
|
||||
$this->assertEquals(1, count($methodAnnots));
|
||||
$this->assertInstanceOf($annotName, $annot = $reader->getMethodAnnotation($getField1Method, $annotName));
|
||||
$this->assertEquals(array(1, 2, "three"), $annot->value);
|
||||
|
||||
$field2Prop = $class->getProperty('field2');
|
||||
$propAnnots = $reader->getPropertyAnnotations($field2Prop);
|
||||
$this->assertEquals(1, count($propAnnots));
|
||||
$this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyJoinTable', $joinTableAnnot = $reader->getPropertyAnnotation($field2Prop, $annotName));
|
||||
$this->assertEquals(1, count($joinTableAnnot->joinColumns));
|
||||
$this->assertEquals(1, count($joinTableAnnot->inverseJoinColumns));
|
||||
$this->assertTrue($joinTableAnnot->joinColumns[0] instanceof DummyJoinColumn);
|
||||
$this->assertTrue($joinTableAnnot->inverseJoinColumns[0] instanceof DummyJoinColumn);
|
||||
$this->assertEquals('col1', $joinTableAnnot->joinColumns[0]->name);
|
||||
$this->assertEquals('col2', $joinTableAnnot->joinColumns[0]->referencedColumnName);
|
||||
$this->assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name);
|
||||
$this->assertEquals('col4', $joinTableAnnot->inverseJoinColumns[0]->referencedColumnName);
|
||||
|
||||
$dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
|
||||
$this->assertEquals('', $dummyAnnot->dummyValue);
|
||||
$this->assertEquals(array(1, 2, 'three'), $dummyAnnot->value);
|
||||
|
||||
$dummyAnnot = $reader->getPropertyAnnotation($class->getProperty('field1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
|
||||
$this->assertEquals('fieldHello', $dummyAnnot->dummyValue);
|
||||
|
||||
$classAnnot = $reader->getClassAnnotation($class, 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
|
||||
$this->assertEquals('hello', $classAnnot->dummyValue);
|
||||
}
|
||||
|
||||
public function testAnnotationsWithValidTargets()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithValidAnnotationTarget');
|
||||
|
||||
$this->assertEquals(1,count($reader->getClassAnnotations($class)));
|
||||
$this->assertEquals(1,count($reader->getPropertyAnnotations($class->getProperty('foo'))));
|
||||
$this->assertEquals(1,count($reader->getMethodAnnotations($class->getMethod('someFunction'))));
|
||||
$this->assertEquals(1,count($reader->getPropertyAnnotations($class->getProperty('nested'))));
|
||||
}
|
||||
|
||||
public function testAnnotationsWithVarType()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType');
|
||||
|
||||
$this->assertEquals(1,count($fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo'))));
|
||||
$this->assertEquals(1,count($barAnnot = $reader->getMethodAnnotations($class->getMethod('bar'))));
|
||||
|
||||
$this->assertInternalType('string', $fooAnnot[0]->string);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', $barAnnot[0]->annotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetPropertyMethod is not allowed to be declared on class Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass. You may only use this annotation on these code elements: METHOD, PROPERTY
|
||||
*/
|
||||
public function testClassWithInvalidAnnotationTargetAtClassDocBlock()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass'));
|
||||
}
|
||||
|
||||
public function testClassWithWithInclude()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$annots = $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithRequire'));
|
||||
$this->assertCount(1, $annots);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetClass is not allowed to be declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty::$foo. You may only use this annotation on these code elements: CLASS
|
||||
*/
|
||||
public function testClassWithInvalidAnnotationTargetAtPropertyDocBlock()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty', 'foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetAnnotation is not allowed to be declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty::$bar. You may only use this annotation on these code elements: ANNOTATION
|
||||
*/
|
||||
public function testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty', 'bar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetClass is not allowed to be declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtMethod::functionName(). You may only use this annotation on these code elements: CLASS
|
||||
*/
|
||||
public function testClassWithInvalidAnnotationTargetAtMethodDocBlock()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtMethod', 'functionName'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError.
|
||||
*/
|
||||
public function testClassWithAnnotationWithTargetSyntaxErrorAtClassDocBlock()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError.
|
||||
*/
|
||||
public function testClassWithAnnotationWithTargetSyntaxErrorAtPropertyDocBlock()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError','foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError.
|
||||
*/
|
||||
public function testClassWithAnnotationWithTargetSyntaxErrorAtMethodDocBlock()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError','bar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage [Type Error] Attribute "string" of @AnnotationWithVarType declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType::$invalidProperty expects a(n) string, but got integer.
|
||||
*/
|
||||
public function testClassWithPropertyInvalidVarTypeError()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType');
|
||||
|
||||
$reader->getPropertyAnnotations($class->getProperty('invalidProperty'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage [Type Error] Attribute "annotation" of @AnnotationWithVarType declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType::invalidMethod() expects a(n) Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll, but got an instance of Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation.
|
||||
*/
|
||||
public function testClassWithMethodInvalidVarTypeError()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType');
|
||||
|
||||
$reader->getMethodAnnotations($class->getMethod('invalidMethod'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in class Doctrine\Tests\Common\Annotations\DummyClassSyntaxError.
|
||||
*/
|
||||
public function testClassSyntaxErrorContext()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\DummyClassSyntaxError'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in method Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError::foo().
|
||||
*/
|
||||
public function testMethodSyntaxErrorContext()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError', 'foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in property Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError::$foo.
|
||||
*/
|
||||
public function testPropertySyntaxErrorContext()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError', 'foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group regression
|
||||
*/
|
||||
public function testMultipleAnnotationsOnSameLine()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$annots = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClass2', 'id'));
|
||||
$this->assertEquals(3, count($annots));
|
||||
}
|
||||
|
||||
public function testNonAnnotationProblem()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
|
||||
$this->assertNotNull($annot = $reader->getPropertyAnnotation(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClassNonAnnotationProblem', 'foo'), $name = 'Doctrine\Tests\Common\Annotations\DummyAnnotation'));
|
||||
$this->assertInstanceOf($name, $annot);
|
||||
}
|
||||
|
||||
public function testImportWithConcreteAnnotation()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$property = new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestImportWithConcreteAnnotation', 'field');
|
||||
$annotations = $reader->getPropertyAnnotations($property);
|
||||
$this->assertEquals(1, count($annotations));
|
||||
$this->assertNotNull($reader->getPropertyAnnotation($property, 'Doctrine\Tests\Common\Annotations\DummyAnnotation'));
|
||||
}
|
||||
|
||||
public function testImportWithInheritance()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
|
||||
$class = new TestParentClass();
|
||||
$ref = new \ReflectionClass($class);
|
||||
|
||||
$childAnnotations = $reader->getPropertyAnnotations($ref->getProperty('child'));
|
||||
$this->assertEquals(1, count($childAnnotations));
|
||||
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Foo\Name', reset($childAnnotations));
|
||||
|
||||
$parentAnnotations = $reader->getPropertyAnnotations($ref->getProperty('parent'));
|
||||
$this->assertEquals(1, count($parentAnnotations));
|
||||
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Name', reset($parentAnnotations));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage The annotation "@NameFoo" in property Doctrine\Tests\Common\Annotations\TestAnnotationNotImportedClass::$field was never imported.
|
||||
*/
|
||||
public function testImportDetectsNotImportedAnnotation()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestAnnotationNotImportedClass', 'field'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage The annotation "@Foo\Bar\Name" in property Doctrine\Tests\Common\Annotations\TestNonExistentAnnotationClass::$field was never imported.
|
||||
*/
|
||||
public function testImportDetectsNonExistentAnnotation()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestNonExistentAnnotationClass', 'field'));
|
||||
}
|
||||
|
||||
public function testTopLevelAnnotation()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$annotations = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestTopLevelAnnotationClass', 'field'));
|
||||
|
||||
$this->assertEquals(1, count($annotations));
|
||||
$this->assertInstanceOf('\TopLevelAnnotation', reset($annotations));
|
||||
}
|
||||
|
||||
public function testIgnoresAnnotationsNotPrefixedWithWhitespace()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
|
||||
$annotation = $reader->getClassAnnotation(new \ReflectionClass(new TestIgnoresNonAnnotationsClass()), 'Doctrine\Tests\Common\Annotations\Name');
|
||||
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Name', $annotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\Common\Annotations\AnnotationException
|
||||
* @expectedExceptionMessage The class "Doctrine\Tests\Common\Annotations\Fixtures\NoAnnotation" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "Doctrine\Tests\Common\Annotations\Fixtures\NoAnnotation". If it is indeed no annotation, then you need to add @IgnoreAnnotation("NoAnnotation") to the _class_ doc comment of class Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageClass.
|
||||
*/
|
||||
public function testErrorWhenInvalidAnnotationIsUsed()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageClass');
|
||||
$reader->getClassAnnotations($ref);
|
||||
}
|
||||
|
||||
public function testInvalidAnnotationUsageButIgnoredClass()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageButIgnoredClass');
|
||||
$annots = $reader->getClassAnnotations($ref);
|
||||
|
||||
$this->assertEquals(2, count($annots));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1660
|
||||
* @group regression
|
||||
*/
|
||||
public function testInvalidAnnotationButIgnored()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassDDC1660');
|
||||
|
||||
$this->assertTrue(class_exists('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Version'));
|
||||
$this->assertCount(0, $reader->getClassAnnotations($class));
|
||||
$this->assertCount(0, $reader->getMethodAnnotations($class->getMethod('bar')));
|
||||
$this->assertCount(0, $reader->getPropertyAnnotations($class->getProperty('foo')));
|
||||
}
|
||||
|
||||
public function testAnnotationEnumeratorException()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum');
|
||||
|
||||
$this->assertCount(1, $bar = $reader->getMethodAnnotations($class->getMethod('bar')));
|
||||
$this->assertCount(1, $foo = $reader->getPropertyAnnotations($class->getProperty('foo')));
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum', $bar[0]);
|
||||
$this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum', $foo[0]);
|
||||
|
||||
try {
|
||||
$reader->getPropertyAnnotations($class->getProperty('invalidProperty'));
|
||||
$this->fail();
|
||||
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
|
||||
$this->assertEquals('[Enum Error] Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum::$invalidProperty accept only [ONE, TWO, THREE], but got FOUR.', $exc->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
$reader->getMethodAnnotations($class->getMethod('invalidMethod'));
|
||||
$this->fail();
|
||||
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
|
||||
$this->assertEquals('[Enum Error] Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum::invalidMethod() accept only [ONE, TWO, THREE], but got 5.', $exc->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DCOM-106
|
||||
*/
|
||||
public function testIgnoreFixMeAndUpperCaseToDo()
|
||||
{
|
||||
$reader = $this->getReader();
|
||||
$ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\DCOM106');
|
||||
$reader->getClassAnnotations($ref);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AnnotationReader
|
||||
*/
|
||||
abstract protected function getReader();
|
||||
}
|
||||
|
||||
/**
|
||||
* @parseAnnotation("var")
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*
|
||||
*/
|
||||
class TestParseAnnotationClass
|
||||
{
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
private $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Name
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class TestIgnoresNonAnnotationsClass
|
||||
{
|
||||
}
|
||||
|
||||
class TestTopLevelAnnotationClass
|
||||
{
|
||||
/**
|
||||
* @\TopLevelAnnotation
|
||||
*/
|
||||
private $field;
|
||||
}
|
||||
|
||||
class TestNonExistentAnnotationClass
|
||||
{
|
||||
/**
|
||||
* @Foo\Bar\Name
|
||||
*/
|
||||
private $field;
|
||||
}
|
||||
|
||||
class TestAnnotationNotImportedClass
|
||||
{
|
||||
/**
|
||||
* @NameFoo
|
||||
*/
|
||||
private $field;
|
||||
}
|
||||
|
||||
class TestChildClass
|
||||
{
|
||||
/**
|
||||
* @\Doctrine\Tests\Common\Annotations\Foo\Name(name = "foo")
|
||||
*/
|
||||
protected $child;
|
||||
}
|
||||
|
||||
class TestParentClass extends TestChildClass
|
||||
{
|
||||
/**
|
||||
* @\Doctrine\Tests\Common\Annotations\Bar\Name(name = "bar")
|
||||
*/
|
||||
private $parent;
|
||||
}
|
||||
|
||||
class TestImportWithConcreteAnnotation
|
||||
{
|
||||
/**
|
||||
* @DummyAnnotation(dummyValue = "bar")
|
||||
*/
|
||||
private $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignoreAnnotation("var")
|
||||
*/
|
||||
class DummyClass2 {
|
||||
/**
|
||||
* @DummyId @DummyColumn(type="integer") @DummyGeneratedValue
|
||||
* @var integer
|
||||
*/
|
||||
private $id;
|
||||
}
|
||||
|
||||
/** @Annotation */
|
||||
class DummyId extends \Doctrine\Common\Annotations\Annotation {}
|
||||
/** @Annotation */
|
||||
class DummyColumn extends \Doctrine\Common\Annotations\Annotation {
|
||||
public $type;
|
||||
}
|
||||
/** @Annotation */
|
||||
class DummyGeneratedValue extends \Doctrine\Common\Annotations\Annotation {}
|
||||
/** @Annotation */
|
||||
class DummyAnnotation extends \Doctrine\Common\Annotations\Annotation {
|
||||
public $dummyValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @api
|
||||
* @Annotation
|
||||
*/
|
||||
class DummyAnnotationWithIgnoredAnnotation extends \Doctrine\Common\Annotations\Annotation {
|
||||
public $dummyValue;
|
||||
}
|
||||
|
||||
/** @Annotation */
|
||||
class DummyJoinColumn extends \Doctrine\Common\Annotations\Annotation {
|
||||
public $name;
|
||||
public $referencedColumnName;
|
||||
}
|
||||
/** @Annotation */
|
||||
class DummyJoinTable extends \Doctrine\Common\Annotations\Annotation {
|
||||
public $name;
|
||||
public $joinColumns;
|
||||
public $inverseJoinColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @DummyAnnotation(@)
|
||||
*/
|
||||
class DummyClassSyntaxError
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class DummyClassMethodSyntaxError
|
||||
{
|
||||
/**
|
||||
* @DummyAnnotation(@)
|
||||
*/
|
||||
public function foo()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class DummyClassPropertySyntaxError
|
||||
{
|
||||
/**
|
||||
* @DummyAnnotation(@)
|
||||
*/
|
||||
public $foo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignoreAnnotation({"since", "var"})
|
||||
*/
|
||||
class DummyClassNonAnnotationProblem
|
||||
{
|
||||
/**
|
||||
* @DummyAnnotation
|
||||
*
|
||||
* @var \Test
|
||||
* @since 0.1
|
||||
*/
|
||||
public $foo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @DummyAnnotation Foo bar <foobar@1domain.com>
|
||||
*/
|
||||
class DummyClassWithEmail
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fixme public
|
||||
* @TODO
|
||||
*/
|
||||
class DCOM106
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Foo;
|
||||
|
||||
/** @Annotation */
|
||||
class Name extends \Doctrine\Common\Annotations\Annotation
|
||||
{
|
||||
public $name;
|
||||
}
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Bar;
|
||||
|
||||
/** @Annotation */
|
||||
class Name extends \Doctrine\Common\Annotations\Annotation
|
||||
{
|
||||
public $name;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
|
||||
class AnnotationReaderTest extends AbstractReaderTest
|
||||
{
|
||||
protected function getReader()
|
||||
{
|
||||
return new AnnotationReader();
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\CachedReader;
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
|
||||
class CachedReaderTest extends AbstractReaderTest
|
||||
{
|
||||
private $cache;
|
||||
|
||||
public function testIgnoresStaleCache()
|
||||
{
|
||||
$file = __DIR__.'/Fixtures/Controller.php';
|
||||
touch($file);
|
||||
$name = 'Doctrine\Tests\Common\Annotations\Fixtures\Controller';
|
||||
$cacheKey = $name.'@[Annot]';
|
||||
|
||||
$cache = $this->getMock('Doctrine\Common\Cache\Cache');
|
||||
$cache
|
||||
->expects($this->at(0))
|
||||
->method('fetch')
|
||||
->with($this->equalTo($cacheKey))
|
||||
->will($this->returnValue(array()))
|
||||
;
|
||||
$cache
|
||||
->expects($this->at(1))
|
||||
->method('fetch')
|
||||
->with($this->equalTo('[C]'.$cacheKey))
|
||||
->will($this->returnValue(time() - 10))
|
||||
;
|
||||
$cache
|
||||
->expects($this->at(2))
|
||||
->method('save')
|
||||
->with($this->equalTo($cacheKey))
|
||||
;
|
||||
$cache
|
||||
->expects($this->at(3))
|
||||
->method('save')
|
||||
->with($this->equalTo('[C]'.$cacheKey))
|
||||
;
|
||||
|
||||
$reader = new CachedReader(new AnnotationReader(), $cache, true);
|
||||
$route = new Route();
|
||||
$route->pattern = '/someprefix';
|
||||
$this->assertEquals(array($route), $reader->getClassAnnotations(new \ReflectionClass($name)));
|
||||
}
|
||||
|
||||
protected function getReader()
|
||||
{
|
||||
$this->cache = new ArrayCache();
|
||||
return new CachedReader(new AnnotationReader(), $this->cache);
|
||||
}
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\DocLexer;
|
||||
|
||||
class DocLexerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testMarkerAnnotation()
|
||||
{
|
||||
$lexer = new DocLexer;
|
||||
|
||||
$lexer->setInput("@Name");
|
||||
$this->assertNull($lexer->token);
|
||||
$this->assertNull($lexer->lookahead);
|
||||
|
||||
$this->assertTrue($lexer->moveNext());
|
||||
$this->assertNull($lexer->token);
|
||||
$this->assertEquals('@', $lexer->lookahead['value']);
|
||||
|
||||
$this->assertTrue($lexer->moveNext());
|
||||
$this->assertEquals('@', $lexer->token['value']);
|
||||
$this->assertEquals('Name', $lexer->lookahead['value']);
|
||||
|
||||
$this->assertFalse($lexer->moveNext());
|
||||
}
|
||||
|
||||
public function testScannerTokenizesDocBlockWhitConstants()
|
||||
{
|
||||
$lexer = new DocLexer();
|
||||
$docblock = '@AnnotationWithConstants(PHP_EOL, ClassWithConstants::SOME_VALUE, \Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants::SOME_VALUE)';
|
||||
|
||||
$tokens = array (
|
||||
array(
|
||||
'value' => '@',
|
||||
'position' => 0,
|
||||
'type' => DocLexer::T_AT,
|
||||
),
|
||||
array(
|
||||
'value' => 'AnnotationWithConstants',
|
||||
'position' => 1,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
),
|
||||
array(
|
||||
'value' => '(',
|
||||
'position' => 24,
|
||||
'type' => DocLexer::T_OPEN_PARENTHESIS,
|
||||
),
|
||||
array(
|
||||
'value' => 'PHP_EOL',
|
||||
'position' => 25,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
),
|
||||
array(
|
||||
'value' => ',',
|
||||
'position' => 32,
|
||||
'type' => DocLexer::T_COMMA,
|
||||
),
|
||||
array(
|
||||
'value' => 'ClassWithConstants::SOME_VALUE',
|
||||
'position' => 34,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
),
|
||||
array(
|
||||
'value' => ',',
|
||||
'position' => 64,
|
||||
'type' => DocLexer::T_COMMA,
|
||||
),
|
||||
array(
|
||||
'value' => '\\Doctrine\\Tests\\Common\\Annotations\\Fixtures\\IntefaceWithConstants::SOME_VALUE',
|
||||
'position' => 66,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
),
|
||||
array(
|
||||
'value' => ')',
|
||||
'position' => 143,
|
||||
'type' => DocLexer::T_CLOSE_PARENTHESIS,
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
$lexer->setInput($docblock);
|
||||
|
||||
foreach ($tokens as $expected) {
|
||||
$lexer->moveNext();
|
||||
$lookahead = $lexer->lookahead;
|
||||
$this->assertEquals($expected['value'], $lookahead['value']);
|
||||
$this->assertEquals($expected['type'], $lookahead['type']);
|
||||
$this->assertEquals($expected['position'], $lookahead['position']);
|
||||
}
|
||||
|
||||
$this->assertFalse($lexer->moveNext());
|
||||
}
|
||||
|
||||
|
||||
public function testScannerTokenizesDocBlockWhitInvalidIdentifier()
|
||||
{
|
||||
$lexer = new DocLexer();
|
||||
$docblock = '@Foo\3.42';
|
||||
|
||||
$tokens = array (
|
||||
array(
|
||||
'value' => '@',
|
||||
'position' => 0,
|
||||
'type' => DocLexer::T_AT,
|
||||
),
|
||||
array(
|
||||
'value' => 'Foo',
|
||||
'position' => 1,
|
||||
'type' => DocLexer::T_IDENTIFIER,
|
||||
),
|
||||
array(
|
||||
'value' => '\\',
|
||||
'position' => 4,
|
||||
'type' => DocLexer::T_NAMESPACE_SEPARATOR,
|
||||
),
|
||||
array(
|
||||
'value' => 3.42,
|
||||
'position' => 5,
|
||||
'type' => DocLexer::T_FLOAT,
|
||||
)
|
||||
);
|
||||
|
||||
$lexer->setInput($docblock);
|
||||
|
||||
foreach ($tokens as $expected) {
|
||||
$lexer->moveNext();
|
||||
$lookahead = $lexer->lookahead;
|
||||
$this->assertEquals($expected['value'], $lookahead['value']);
|
||||
$this->assertEquals($expected['type'], $lookahead['type']);
|
||||
$this->assertEquals($expected['position'], $lookahead['position']);
|
||||
}
|
||||
|
||||
$this->assertFalse($lexer->moveNext());
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\DummyAnnotation;
|
||||
use Doctrine\Tests\Common\Annotations\Name;
|
||||
use Doctrine\Tests\Common\Annotations\DummyJoinTable;
|
||||
use Doctrine\Tests\Common\Annotations\DummyJoinColumn;
|
||||
|
||||
/**
|
||||
* A description of this class.
|
||||
*
|
||||
* Let's see if the parser recognizes that this @ is not really referring to an
|
||||
* annotation. Also make sure that @var \ is not concated to "@var\is".
|
||||
*
|
||||
* @author robo
|
||||
* @since 2.0
|
||||
* @DummyAnnotation(dummyValue="hello")
|
||||
*/
|
||||
class DummyClass
|
||||
{
|
||||
/**
|
||||
* A nice property.
|
||||
*
|
||||
* @var mixed
|
||||
* @DummyAnnotation(dummyValue="fieldHello")
|
||||
*/
|
||||
private $field1;
|
||||
|
||||
/**
|
||||
* @DummyJoinTable(name="join_table",
|
||||
* joinColumns={@DummyJoinColumn(name="col1", referencedColumnName="col2")},
|
||||
* inverseJoinColumns={
|
||||
* @DummyJoinColumn(name="col3", referencedColumnName="col4")
|
||||
* })
|
||||
*/
|
||||
private $field2;
|
||||
|
||||
/**
|
||||
* Gets the value of field1.
|
||||
*
|
||||
* @return mixed
|
||||
* @DummyAnnotation({1,2,"three"})
|
||||
*/
|
||||
public function getField1()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\FileCacheReader;
|
||||
|
||||
class FileCacheReaderTest extends AbstractReaderTest
|
||||
{
|
||||
private $cacheDir;
|
||||
|
||||
protected function getReader()
|
||||
{
|
||||
$this->cacheDir = sys_get_temp_dir() . "/annotations_". uniqid();
|
||||
@mkdir($this->cacheDir);
|
||||
return new FileCacheReader(new AnnotationReader(), $this->cacheDir);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
foreach (glob($this->cacheDir.'/*.php') AS $file) {
|
||||
unlink($file);
|
||||
}
|
||||
rmdir($this->cacheDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DCOM-81
|
||||
*/
|
||||
public function testAttemptToCreateAnnotationCacheDir()
|
||||
{
|
||||
$this->cacheDir = sys_get_temp_dir() . "/not_existed_dir_". uniqid();
|
||||
|
||||
$this->assertFalse(is_dir($this->cacheDir));
|
||||
|
||||
$cache = new FileCacheReader(new AnnotationReader(), $this->cacheDir);
|
||||
|
||||
$this->assertTrue(is_dir($this->cacheDir));
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/** @Annotation */
|
||||
class AnnotWithDefaultValue
|
||||
{
|
||||
/** @var string */
|
||||
public $foo = 'bar';
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
*/
|
||||
class Autoload
|
||||
{
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/** @Annotation */
|
||||
class Route
|
||||
{
|
||||
/** @var string @Required */
|
||||
public $pattern;
|
||||
public $name;
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/** @Annotation */
|
||||
class Secure
|
||||
{
|
||||
private $roles;
|
||||
|
||||
public function __construct(array $values)
|
||||
{
|
||||
if (is_string($values['value'])) {
|
||||
$values['value'] = array($values['value']);
|
||||
}
|
||||
|
||||
$this->roles = $values['value'];
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/** @Annotation */
|
||||
class Template
|
||||
{
|
||||
private $name;
|
||||
|
||||
public function __construct(array $values)
|
||||
{
|
||||
$this->name = isset($values['value']) ? $values['value'] : null;
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("PROPERTY")
|
||||
*/
|
||||
final class Version
|
||||
{
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationEnum
|
||||
{
|
||||
const ONE = 'ONE';
|
||||
const TWO = 'TWO';
|
||||
const THREE = 'THREE';
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*
|
||||
* @Enum({"ONE","TWO","THREE"})
|
||||
*/
|
||||
public $value;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationEnumInvalid
|
||||
{
|
||||
/**
|
||||
* @var mixed
|
||||
*
|
||||
* @Enum({1, 2, "foo", "bar", {"foo":"bar"}})
|
||||
*/
|
||||
public $value;
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnumLiteral as SelfEnum;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationEnumLiteral
|
||||
{
|
||||
const ONE = 1;
|
||||
const TWO = 2;
|
||||
const THREE = 3;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*
|
||||
* @Enum(
|
||||
* value = {
|
||||
* 1,
|
||||
* 2,
|
||||
* 3,
|
||||
* },
|
||||
* literal = {
|
||||
* 1 : "AnnotationEnumLiteral::ONE",
|
||||
* 2 : "AnnotationEnumLiteral::TWO",
|
||||
* 3 : "AnnotationEnumLiteral::THREE",
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
public $value;
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationEnumLiteralInvalid
|
||||
{
|
||||
const ONE = 1;
|
||||
const TWO = 2;
|
||||
const THREE = 3;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*
|
||||
* @Enum(
|
||||
* value = {
|
||||
* 1,
|
||||
* 2
|
||||
* },
|
||||
* literal = {
|
||||
* 1 : "AnnotationEnumLiteral::ONE",
|
||||
* 2 : "AnnotationEnumLiteral::TWO",
|
||||
* 3 : "AnnotationEnumLiteral::THREE"
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
public $value;
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
class AnnotationTargetAll
|
||||
{
|
||||
public $data;
|
||||
public $name;
|
||||
public $target;
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({ "ANNOTATION" })
|
||||
*/
|
||||
final class AnnotationTargetAnnotation
|
||||
{
|
||||
public $data;
|
||||
public $name;
|
||||
public $target;
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("CLASS")
|
||||
*/
|
||||
final class AnnotationTargetClass
|
||||
{
|
||||
public $data;
|
||||
public $name;
|
||||
public $target;
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("METHOD")
|
||||
*/
|
||||
final class AnnotationTargetMethod
|
||||
{
|
||||
public $data;
|
||||
public $name;
|
||||
public $target;
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({ "METHOD", "PROPERTY" })
|
||||
*/
|
||||
final class AnnotationTargetPropertyMethod
|
||||
{
|
||||
public $data;
|
||||
public $name;
|
||||
public $target;
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
* @Attributes({
|
||||
@Attribute("mixed", type = "mixed"),
|
||||
@Attribute("boolean", type = "boolean"),
|
||||
@Attribute("bool", type = "bool"),
|
||||
@Attribute("float", type = "float"),
|
||||
@Attribute("string", type = "string"),
|
||||
@Attribute("integer", type = "integer"),
|
||||
@Attribute("array", type = "array"),
|
||||
@Attribute("arrayOfIntegers", type = "array<integer>"),
|
||||
@Attribute("annotation", type = "Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll"),
|
||||
@Attribute("arrayOfAnnotations", type = "array<Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll>"),
|
||||
})
|
||||
*/
|
||||
final class AnnotationWithAttributes
|
||||
{
|
||||
|
||||
public final function __construct(array $data)
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
private $mixed;
|
||||
private $boolean;
|
||||
private $bool;
|
||||
private $float;
|
||||
private $string;
|
||||
private $integer;
|
||||
private $array;
|
||||
private $annotation;
|
||||
private $arrayOfIntegers;
|
||||
private $arrayOfAnnotations;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMixed()
|
||||
{
|
||||
return $this->mixed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getBoolean()
|
||||
{
|
||||
return $this->boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getBool()
|
||||
{
|
||||
return $this->bool;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getFloat()
|
||||
{
|
||||
return $this->float;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getString()
|
||||
{
|
||||
return $this->string;
|
||||
}
|
||||
|
||||
public function getInteger()
|
||||
{
|
||||
return $this->integer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getArray()
|
||||
{
|
||||
return $this->array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll
|
||||
*/
|
||||
public function getAnnotation()
|
||||
{
|
||||
return $this->annotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<integer>
|
||||
*/
|
||||
public function getArrayOfIntegers()
|
||||
{
|
||||
return $this->arrayOfIntegers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll>
|
||||
*/
|
||||
public function getArrayOfAnnotations()
|
||||
{
|
||||
return $this->arrayOfAnnotations;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationWithConstants
|
||||
{
|
||||
|
||||
const INTEGER = 1;
|
||||
const FLOAT = 1.2;
|
||||
const STRING = '1.2.3';
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
public $value;
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
* @Attributes({
|
||||
@Attribute("value", required = true , type = "string"),
|
||||
@Attribute("annot", required = true , type = "Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation"),
|
||||
})
|
||||
*/
|
||||
final class AnnotationWithRequiredAttributes
|
||||
{
|
||||
|
||||
public final function __construct(array $data)
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation
|
||||
*/
|
||||
private $annot;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation
|
||||
*/
|
||||
public function getAnnot()
|
||||
{
|
||||
return $this->annot;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationWithRequiredAttributesWithoutContructor
|
||||
{
|
||||
|
||||
/**
|
||||
* @Required
|
||||
* @var string
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* @Required
|
||||
* @var Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation
|
||||
*/
|
||||
public $annot;
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target(@)
|
||||
*/
|
||||
final class AnnotationWithTargetSyntaxError
|
||||
{
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
final class AnnotationWithVarType
|
||||
{
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
public $mixed;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
public $boolean;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $bool;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
public $float;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $string;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
public $integer;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $array;
|
||||
|
||||
/**
|
||||
* @var Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll
|
||||
*/
|
||||
public $annotation;
|
||||
|
||||
/**
|
||||
* @var array<integer>
|
||||
*/
|
||||
public $arrayOfIntegers;
|
||||
|
||||
/**
|
||||
* @var array<Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll>
|
||||
*/
|
||||
public $arrayOfAnnotations;
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This class is not an annotation
|
||||
* It's a class build to test ClassWithInclude
|
||||
*/
|
||||
class Api
|
||||
{
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
* @version $Id: SomeEntityClass.php 509 2012-02-03 09:38:48Z mf $
|
||||
*/
|
||||
class ClassDDC1660
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @since 2.0
|
||||
* @version 1
|
||||
*/
|
||||
public $foo;
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return string
|
||||
* @since 2.0
|
||||
* @version 1
|
||||
*/
|
||||
public function bar($param)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum;
|
||||
|
||||
class ClassWithAnnotationEnum
|
||||
{
|
||||
/**
|
||||
* @AnnotationEnum(AnnotationEnum::ONE)
|
||||
*/
|
||||
public $foo;
|
||||
|
||||
/**
|
||||
* @AnnotationEnum("TWO")
|
||||
*/
|
||||
public function bar(){}
|
||||
|
||||
|
||||
/**
|
||||
* @AnnotationEnum("FOUR")
|
||||
*/
|
||||
public $invalidProperty;
|
||||
|
||||
/**
|
||||
* @AnnotationEnum(5)
|
||||
*/
|
||||
public function invalidMethod(){}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError;
|
||||
|
||||
/**
|
||||
* @AnnotationWithTargetSyntaxError()
|
||||
*/
|
||||
class ClassWithAnnotationWithTargetSyntaxError
|
||||
{
|
||||
/**
|
||||
* @AnnotationWithTargetSyntaxError()
|
||||
*/
|
||||
public $foo;
|
||||
|
||||
/**
|
||||
* @AnnotationWithTargetSyntaxError()
|
||||
*/
|
||||
public function bar(){}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation;
|
||||
|
||||
class ClassWithAnnotationWithVarType
|
||||
{
|
||||
/**
|
||||
* @AnnotationWithVarType(string = "String Value")
|
||||
*/
|
||||
public $foo;
|
||||
|
||||
/**
|
||||
* @AnnotationWithVarType(annotation = @AnnotationTargetAll)
|
||||
*/
|
||||
public function bar(){}
|
||||
|
||||
|
||||
/**
|
||||
* @AnnotationWithVarType(string = 123)
|
||||
*/
|
||||
public $invalidProperty;
|
||||
|
||||
/**
|
||||
* @AnnotationWithVarType(annotation = @AnnotationTargetAnnotation)
|
||||
*/
|
||||
public function invalidMethod(){}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll;
|
||||
use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation;
|
||||
|
||||
/**
|
||||
* @AnnotationTargetAll("Foo")
|
||||
*/
|
||||
final class ClassWithClosure
|
||||
{
|
||||
|
||||
/**
|
||||
* @AnnotationTargetAll(@AnnotationTargetAnnotation)
|
||||
* @var string
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* @AnnotationTargetAll(@AnnotationTargetAnnotation)
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return \Closure
|
||||
*/
|
||||
public function methodName(\Closure $callback)
|
||||
{
|
||||
$self = $this;
|
||||
return function() use ($self, $callback) {
|
||||
return $callback;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $year
|
||||
* @param integer $month
|
||||
* @param integer $day
|
||||
* @return \Doctrine\Common\Collections\ArrayCollection
|
||||
*/
|
||||
public function getEventsForDate($year, $month, $day){
|
||||
$extractEvents = null; // check if date of item is inside day given
|
||||
$extractEvents = $this->events->filter(function ($item) use ($year, $month, $day) {
|
||||
$leftDate = new \DateTime($year.'-'.$month.'-'.$day.' 00:00');
|
||||
$rigthDate = new \DateTime($year.'-'.$month.'-'.$day.' +1 day 00:00');
|
||||
return ( ( $leftDate <= $item->getDateStart() ) && ( $item->getDateStart() < $rigthDate ) );
|
||||
|
||||
}
|
||||
);
|
||||
return $extractEvents;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
class ClassWithConstants
|
||||
{
|
||||
|
||||
const SOME_VALUE = 'ClassWithConstants.SOME_VALUE';
|
||||
const SOME_KEY = 'ClassWithConstants.SOME_KEY';
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Annotations\Fixtures;
|
||||
|
||||
use
|
||||
\Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure,
|
||||
\Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route
|
||||
;
|
||||
use \Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
|
||||
|
||||
class ClassWithFullyQualifiedUseStatements {}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue