Update v1.0.6.5

This commit is contained in:
sujitprasad
2016-03-02 12:25:21 +05:30
parent 7011553462
commit c56ff86194
218 changed files with 17161 additions and 2358 deletions

View File

@@ -0,0 +1 @@
scripts/filemanager.config.js

View File

@@ -165,11 +165,12 @@ Error Handling
--------------
Every response should include two keys specific to error handling: Error, and Code. If an error occurs in your script, you may populate these keys with whatever values you feel are most appropriate. If there is no error, Error should remain empty or null, and Code should be empty, null, or zero (0). Do not use zero for any actual errors. The following example would be an appropriate response if the connector uses an external file for configuration (recommended), but that file cannot be found:
{
"Error": "Configuration file missing.",
"Code": -1
}
```json
{
"Error": "Configuration file missing.",
"Code": -1
}
```
Methods
-------
@@ -185,23 +186,25 @@ Example Request:
Example Response:
{
"Path": "/UserFiles/Image/logo.png",
"Filename": "logo.png",
"File Type": "png",
"Preview": "/UserFiles/Image/logo.png",
"Protected": 0,
"Properties": {
"Date Created": null,
"Date Modified": "02/09/2007 14:01:06",
"filemtime": 1360237058,
"Height": 14,
"Width": 14,
"Size": 384
},
"Error": "",
"Code": 0
}
```json
{
"Path": "/UserFiles/Image/logo.png",
"Filename": "logo.png",
"File Type": "png",
"Preview": "/UserFiles/Image/logo.png",
"Protected": 0,
"Properties": {
"Date Created": null,
"Date Modified": "02/09/2007 14:01:06",
"filemtime": 1360237058,
"Height": 14,
"Width": 14,
"Size": 384
},
"Error": "",
"Code": 0
}
```
The keys are as follows:
@@ -245,57 +248,59 @@ Example Request:
Example Response:
{
"/UserFiles/Image/logo.png": {
"Path": "/UserFiles/Image/logo.png",
"Filename": "logo.png",
"File Type": "png",
"Preview": "/UserFiles/Image/logo.png",
"Protected": 0,
"Properties": {
"Date Created": null,
"Date Modified": "02/09/2007 14:01:06",
"filemtime": 1360237058,
"Height": 14,
"Width": 14,
"Size": 384
},
"Error": "",
"Code": 0
},
"/UserFiles/Image/icon.png": {
"Path": "/UserFiles/Image/icon.png",
"Filename": "icon.png",
"File Type": "png",
"Preview": "/UserFiles/Image/icon.png",
"Properties": {
"Date Created": null,
"Date Modified": "02/09/2007 14:01:06",
"filemtime": 1360237058,
"Height": 14,
"Width": 14,
"Size": 384
},
"Error": "",
"Code": 0
},
"/UserFiles/folder/":{
"Path":"/UserFiles/folder/",
"Filename":"folder",
"File Type":"dir",
"Preview":"images\/fileicons\/_Open.png",
"Properties": {
"Date Created":null,
"Date Modified": "02/09/2007 14:01:06",
"filemtime": 1360237058,
"Height":null,
"Width":null,
"Size":null
},
"Error":"",
"Code":0
}
}
```json
{
"/UserFiles/Image/logo.png": {
"Path": "/UserFiles/Image/logo.png",
"Filename": "logo.png",
"File Type": "png",
"Preview": "/UserFiles/Image/logo.png",
"Protected": 0,
"Properties": {
"Date Created": null,
"Date Modified": "02/09/2007 14:01:06",
"filemtime": 1360237058,
"Height": 14,
"Width": 14,
"Size": 384
},
"Error": "",
"Code": 0
},
"/UserFiles/Image/icon.png": {
"Path": "/UserFiles/Image/icon.png",
"Filename": "icon.png",
"File Type": "png",
"Preview": "/UserFiles/Image/icon.png",
"Properties": {
"Date Created": null,
"Date Modified": "02/09/2007 14:01:06",
"filemtime": 1360237058,
"Height": 14,
"Width": 14,
"Size": 384
},
"Error": "",
"Code": 0
},
"/UserFiles/folder/":{
"Path":"/UserFiles/folder/",
"Filename":"folder",
"File Type":"dir",
"Preview":"images\/fileicons\/_Open.png",
"Properties": {
"Date Created":null,
"Date Modified": "02/09/2007 14:01:06",
"filemtime": 1360237058,
"Height":null,
"Width":null,
"Size":null
},
"Error":"",
"Code":0
}
}
```
Each key in the array is the path to an individual item, and the value is the file object for that item.
@@ -310,14 +315,16 @@ Example Request:
Example Response:
{
"Error": "No error",
"Code": 0,
"Old Path": "/a_folder_renamed/thisisareallylongincrediblylongfilenamefortesting.txt",
"Old Name": "thisisareallylongincrediblylongfilenamefortesting.txt",
"New Path": "/a_folder_renamed/a_renamed_file",
"New Name": "a_renamed_file"
}
```json
{
"Error": "No error",
"Code": 0,
"Old Path": "/a_folder_renamed/thisisareallylongincrediblylongfilenamefortesting.txt",
"Old Name": "thisisareallylongincrediblylongfilenamefortesting.txt",
"New Path": "/a_folder_renamed/a_renamed_file",
"New Name": "a_renamed_file"
}
```
move
------
@@ -329,14 +336,16 @@ Example Request: Move file
Example Response:
{
"Error": "No error",
"Code": 0,
"Old Path": "/uploads/images/original/Image/",
"Old Name": "logo.png",
"New Path": "/uploads/images/moved/",
"New Name": "logo.png"
}
```json
{
"Error": "No error",
"Code": 0,
"Old Path": "/uploads/images/original/Image/",
"Old Name": "logo.png",
"New Path": "/uploads/images/moved/",
"New Name": "logo.png"
}
```
Example Request: Move directory to not existing directory (will be created)
@@ -344,15 +353,16 @@ Example Request: Move directory to not existing directory (will be created)
Example Response:
{
"Error": "No error",
"Code": 0,
"Old Path": "/uploads/images/original/",
"Old Name": "Image",
"New Path": "/uploads/new_dir/",
"New Name": "Image"
}
```json
{
"Error": "No error",
"Code": 0,
"Old Path": "/uploads/images/original/",
"Old Name": "Image",
"New Path": "/uploads/new_dir/",
"New Name": "Image"
}
```
@@ -366,38 +376,43 @@ Example Request:
Example Response:
{
"Error": "No error",
"Code": 0,
"Path": "/UserFiles/Image/logo.png"
}
```json
{
"Error": "No error",
"Code": 0,
"Path": "/UserFiles/Image/logo.png"
}
```
add
---
The `add` method adds the uploaded file to the specified path. Unlike the other methods, this method must return its JSON response wrapped in an HTML <textarea>, so the MIME type of the response is text/html instead of text/plain. The upload form in the File Manager passes the current path as a POST param along with the uploaded file. The response includes the path as well as the name used to store the file. The uploaded file's name should be safe to use as a path component in a URL, so URL-encoded at a minimum.
The `add` method adds the uploaded file to the specified path. Unlike the other methods, this method must return its JSON response wrapped in an HTML `<textarea>`, so the MIME type of the response is text/html instead of text/plain. The upload form in the File Manager passes the current path as a POST param along with the uploaded file. The response includes the path as well as the name used to store the file. The uploaded file's name should be safe to use as a path component in a URL, so URL-encoded at a minimum.
Example Response:
{
"Path": "/UserFiles/Image/",
"Name": "new_logo.png",
"Error": "No error",
"Code": 0
}
```json
{
"Path": "/UserFiles/Image/",
"Name": "new_logo.png",
"Error": "No error",
"Code": 0
}
```
replace
---
The `replace` method allow the user to replace a specific file whatever the new filename - at least, the new file should have the same extension the original has. The old file is automatically overwritten. Unlike the other methods, this method must return its JSON response wrapped in an HTML <textarea>, so the MIME type of the response is text/html instead of text/plain. The *dynamic* upload form in the File Manager passes the current file path as a POST param along with the uploaded file. The response includes the path as well as the name used to store the file.
The `replace` method allow the user to replace a specific file whatever the new filename - at least, the new file should have the same extension the original has. The old file is automatically overwritten. Unlike the other methods, this method must return its JSON response wrapped in an HTML `<textarea>`, so the MIME type of the response is text/html instead of text/plain. The *dynamic* upload form in the File Manager passes the current file path as a POST param along with the uploaded file. The response includes the path as well as the name used to store the file.
Example Response:
{
"Path": "/UserFiles/Image/",
"Name": "new_logo.png",
"Error": "No error",
"Code": 0
}
```json
{
"Path": "/UserFiles/Image/",
"Name": "new_logo.png",
"Error": "No error",
"Code": 0
}
```
editfile
--------
@@ -406,27 +421,31 @@ The `editfile` method returns the content of a given file (passed as parameter).
Example request:
[path to connector]?mode=editfile&path=/UserFiles/MyFolder/myfile.txt
Example Response:
{
"Error": "No error",
"Code": 0,
"Path": "/UserFiles/MyFolder/myfile.txt",
"Content": "Content":"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\r\n\Phasellus eu erat lorem.\r\n\r\n\Bye!"
}
```json
{
"Error": "No error",
"Code": 0,
"Path": "/UserFiles/MyFolder/myfile.txt",
"Content": "Content":"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\r\n\Phasellus eu erat lorem.\r\n\r\n\Bye!"
}
```
savefile
--------
The `save` method will overwrite the content of the current file. The edit form in the File Manager passes the mode (as `savefile`), path of the current file and the content as POST parameters.
Example Response:
{
"Error": "No error",
"Code": 0,
"Path": "/UserFiles/MyFolder/myfile.txt"
}
```json
{
"Error": "No error",
"Code": 0,
"Path": "/UserFiles/MyFolder/myfile.txt"
}
```
preview
--------
@@ -444,15 +463,17 @@ The `addfolder` method creates a new directory on the server within the given pa
Example Request:
[path to connector]?mode=addfolder&path=/UserFiles/&name=new%20logo.png
Example Response:
{
"Parent": "/UserFiles/",
"Name": "new_logo.png",
"Error": "No error",
"Code": 0
}
```json
{
"Parent": "/UserFiles/",
"Name": "new_logo.png",
"Error": "No error",
"Code": 0
}
```
download

View File

@@ -1,3 +1,11 @@
From version 2.3.0 to 2.4.0
---------------------------
- handle better language ISO 4 Letters | #428
- encode path on requests | #429
- catalan translation updated | #440
- security fix : Path Traversal Vulnerability | #453
From version 2.2.0 to 2.3.0
---------------------------
- PDF viewer added | #377 & #319

View File

@@ -31,7 +31,8 @@ $app['session']->driver()->setId($id);
$app['session']->driver()->start();
// Folder path
$folderPath = $app->basePath() . '/public/'.config('filemanager.folder_path');
$folderPath = $app->publicPath() . '/'. config('filemanager.folder_path');
$folderPath = str_replace('\\', '/', $folderPath);
// Check if user in authentified
if(!$app['auth']->check())

View File

@@ -410,7 +410,7 @@ class Filemanager {
$new_file = $this->getFullPath($path . '/' . $this->get['new']). $suffix;
$old_file = $this->getFullPath($this->get['old']) . $suffix;
if(!$this->has_permission('rename') || !$this->is_valid_path($old_file)) {
if(!$this->has_permission('rename') || !$this->is_valid_path($old_file) || !$this->is_valid_path($new_file)) {
$this->error("No way.");
}
@@ -446,7 +446,17 @@ class Filemanager {
} else {
$this->error(sprintf($this->lang('ERROR_RENAMING_FILE'),$filename,$this->get['new']));
}
}
} else {
// For image only - rename thumbnail if original image was successfully renamed
if(!is_dir($new_file) && $this->is_image($new_file)) {
$new_thumbnail = $this->get_thumbnail_path($new_file);
$old_thumbnail = $this->get_thumbnail_path($old_file);
if(file_exists($old_thumbnail)) {
rename($old_thumbnail, $new_thumbnail);
}
}
}
$array = array(
'Error'=>"",
'Code'=>0,
@@ -924,6 +934,9 @@ class Filemanager {
public function preview($thumbnail) {
$current_path = $this->getFullPath();
if(!$this->is_valid_path($current_path)) $this->error("No way.");
if(isset($this->get['path']) && file_exists($current_path)) {
@@ -1189,10 +1202,20 @@ private function is_valid_path($path) {
// return $this->startsWith($givenpath, $rootpath);
$this->__log('substr path_to_files : ' . substr(realpath($path) . DIRECTORY_SEPARATOR, 0, strlen($this->path_to_files)));
$this->__log('path_to_files : ' . realpath($this->path_to_files) . DIRECTORY_SEPARATOR);
return (substr(realpath($path) . DIRECTORY_SEPARATOR, 0, strlen(realpath($this->path_to_files))) . DIRECTORY_SEPARATOR) == (realpath($this->path_to_files) . DIRECTORY_SEPARATOR);
// handle better symlinks & network path
$patt = array('/\\\\+/','/\/+/');
$repl = array('\\\\','/');
$substrpath = substr(realpath($path) . DIRECTORY_SEPARATOR, 0, strlen($this->path_to_files)) . DIRECTORY_SEPARATOR;
$substrpath = preg_replace($patt,$repl,$substrpath); // removing double slash
$rpath = realpath($this->path_to_files) . DIRECTORY_SEPARATOR;
$rpath = preg_replace($patt,$repl,$rpath); // removing double slash
$this->__log('substr path : ' . $substrpath);
$this->__log('real path : ' . $rpath);
return ($substrpath == $rpath);
}
@@ -1530,4 +1553,4 @@ public function expandPath($path, $clean = false)
return implode('/', $fullPath);
}
}
?>
?>

View File

@@ -19,7 +19,7 @@
"dateFormat": "d M Y H:i",
"serverRoot": false,
"fileRoot": "/",
"baseUrl": "/filemanager/",
"baseUrl": "/",
"logger": false,
"capabilities": ["select", "download", "rename", "delete", "replace"],
"plugins": []

View File

@@ -158,14 +158,15 @@ $.prompt.setDefaults({
// Forces columns to fill the layout vertically.
// Called on initial page load and on resize.
var setDimensions = function(){
var bheight = 53;
var bheight = 53,
$uploader = $('#uploader');
if($.urlParam('CKEditorCleanUpFuncNum')) bheight +=60;
var newH = $(window).height() - $('#uploader').height() - bheight;
var newH = $(window).height() - $uploader.height() - $uploader.offset().top - bheight;
$('#splitter, #filetree, #fileinfo, .vsplitbar').height(newH);
var newW = $('#splitter').width() - $('div.vsplitbar').width() - $('#filetree').width();
$('#fileinfo').width(newW);
$('#fileinfo').width(newW);
};
// Display Min Path
@@ -730,7 +731,7 @@ var renameItem = function(data) {
}
var oldPath = data['Path'];
var connectString = fileConnector + '?mode=rename&old=' + data['Path'] + '&new=' + givenName + '&config=' + userconfig;
var connectString = fileConnector + '?mode=rename&old=' + encodeURIComponent(data['Path']) + '&new=' + encodeURIComponent(givenName) + '&config=' + userconfig;
$.ajax({
type: 'GET',
@@ -1221,7 +1222,7 @@ function getContextMenuOptions(elem) {
// Binds contextual menus to items in list and grid views.
var setMenus = function(action, path) {
var d = new Date(); // to prevent IE cache issues
$.getJSON(fileConnector + '?mode=getinfo&path=' + path + '&config=' + userconfig + '&time=' + d.getMilliseconds(), function(data){
$.getJSON(fileConnector + '?mode=getinfo&path=' + encodeURIComponent(path) + '&config=' + userconfig + '&time=' + d.getMilliseconds(), function(data){
if($('#fileinfo').data('view') == 'grid'){
var item = $('#fileinfo').find('img[data-path="' + data['Path'] + '"]').parent();
} else {

View File

@@ -9,7 +9,7 @@ if(!a("#"+g).length){var b=a("#itemOptions").clone().attr("id",g);c.hasClass("ca
null;"user"==("undefined"===typeof c?"user":c)?0!=a.urlParam("config")?(c="./scripts/"+a.urlParam("config"),userconfig=a.urlParam("config")):(c="./scripts/filemanager.config.js",userconfig="filemanager.config.js"):c="./scripts/filemanager.config.js.default";a.ajax({async:!1,url:c,dataType:"json",cache:!1,success:function(a){g=a}});return g},R=v("default"),f=v();null!==f&&delete f.version;f=a.extend({},R,f);if(f.options.logger)var A=(new Date).getTime();HEAD_included_files=[];loadCSS=function(c){if(-1==
a.inArray(c,HEAD_included_files)){var g=a("<link rel='stylesheet' type='text/css' href='"+c+"'>");a("head").append(g);HEAD_included_files.push(c)}};loadJS=function(c){if(-1==a.inArray(c,HEAD_included_files)){var g=a("<script type='text/javascript' src='"+c+"'>");a("head").append(g);HEAD_included_files.push(c)}};smartPath=function(a,g){var b=a.split("/"),b="/"+b[b.length-2]+"/",d=g.indexOf(b);rvalue=-1==d?a+g:a+g.substring(d+b.length);f.options.logger&&console.log("url : "+a+" - path : "+g+" - separator : "+
b+" - pos : "+d+" - returned value : "+rvalue);return rvalue};var k=f.options.fileConnector||"connectors/"+f.options.lang+"/filemanager."+f.options.lang,n=f.options.capabilities||"select download rename move delete replace".split(" ");0!=a.urlParam("langCode")&&(I("scripts/languages/"+a.urlParam("langCode")+".js")?f.options.culture=a.urlParam("langCode"):(v=a.urlParam("langCode").substring(0,2),I("scripts/languages/"+v+".js")&&(f.options.culture=v)));var b=[];a.ajax({url:"scripts/languages/"+f.options.culture+
".js",async:!1,dataType:"json",success:function(a){b=a}});a.prompt.setDefaults({overlayspeed:"fast",show:"fadeIn",opacity:.4,persistent:!1});var x=function(){var c=53;a.urlParam("CKEditorCleanUpFuncNum")&&(c+=60);c=a(window).height()-a("#uploader").height()-c;a("#splitter, #filetree, #fileinfo, .vsplitbar").height(c);c=a("#splitter").width()-a("div.vsplitbar").width()-a("#filetree").width();a("#fileinfo").width(c)},y=function(a,g){g="undefined"===typeof g?!0:!1;if(0==f.options.showFullPath){if("function"===
".js",async:!1,dataType:"json",success:function(a){b=a}});a.prompt.setDefaults({overlayspeed:"fast",show:"fadeIn",opacity:.4,persistent:!1});var x=function(){var c=53,g=a("#uploader");a.urlParam("CKEditorCleanUpFuncNum")&&(c+=60);c=a(window).height()-g.height()-g.offset().top-c;a("#splitter, #filetree, #fileinfo, .vsplitbar").height(c);c=a("#splitter").width()-a("div.vsplitbar").width()-a("#filetree").width();a("#fileinfo").width(c)},y=function(a,g){g="undefined"===typeof g?!0:!1;if(0==f.options.showFullPath){if("function"===
typeof displayPathDecorator)return displayPathDecorator(a.replace(fileRoot,"/"));a=a.replace(fileRoot,"/");if(50<a.length&&!0===g){var b=a.split("/");a="/"+b[1]+"/"+b[2]+"/(...)/"+b[b.length-2]+"/"}}return a},B=function(c){"grid"==c?(a("#grid").addClass("ON"),a("#list").removeClass("ON")):(a("#list").addClass("ON"),a("#grid").removeClass("ON"))},C=function(a){var b="",b="\u0160\u0161\u0110\u0111\u017d\u017e\u010c\u010d\u0106\u0107\u00c0\u00c1\u00c2\u00c3\u00c4\u00c5\u00c6\u00c7\u00c8\u00c9\u00ca\u00cb\u00cc\u00cd\u00ce\u00cf\u00d1\u00d2\u00d3\u00d4\u00d5\u00d6\u0150\u00d8\u00d9\u00da\u00db\u00dc\u00dd\u00de\u00df\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5\u00e6\u00e7\u00e8\u00e9\u00ea\u00eb\u00ec\u00ed\u00ee\u00ef\u00f0\u00f1\u00f2\u00f3\u00f4\u00f5\u00f6\u0151\u00f8\u00f9\u00fa\u00fb\u00fc\u00fd\u00fd\u00fe\u00ff\u0154\u0155 '/".split(""),
e="S s Dj dj Z z C c C c A A A A A A A C E E E E I I I I N O O O O O O O U U U U Y B Ss a a a a a a a c e e e e i i i i o n o o o o o o o u u u u y y b y R r _ _ ".split(" ");a=String(a);for(i=0;i<b.length;i++)a=a.replace(RegExp(b[i],"g"),e[i]);b=a;f.options.chars_only_latin&&(b=b.replace(/[^_a-zA-Z0-9]/g,""));return b=b.replace(/[_]+/g,"_")},S=function(a){filename="";-1!=a.lastIndexOf(".")?(filename=C(a.substr(0,a.lastIndexOf("."))),filename+="."+a.split(".").pop()):filename=C(a);return filename},
J=function(a){a=parseFloat(a);for(var g=0,f=[b.bytes,b.kb,b.mb,b.gb];;){if(1024>a)return a=Math.round(100*a)/100,a+f[g];a/=1024;g+=1}},K=function(c){a("#fileinfo").html("<h1>"+c+"</h1>");a("#newfile").attr("disabled","disabled");a("#upload").attr("disabled","disabled");a("#newfolder").attr("disabled","disabled")},L=function(c){c=q(c);return""==c&&1==f.security.allowNoExtension||"DISALLOW_ALL"==f.security.uploadPolicy&&-1!=a.inArray(c,f.security.uploadRestrictions)||"ALLOW_ALL"==f.security.uploadPolicy&&
@@ -24,22 +24,22 @@ k+"?mode=download&path="+encodeURIComponent(c.Path)+"&config="+userconfig}).show
g,"undefined"!=typeof c.ImageDialog&&(c.ImageDialog.getImageData&&c.ImageDialog.getImageData(),c.ImageDialog.showPreviewImage&&c.ImageDialog.showPreviewImage(g)),tinyMCEPopup.close()):(a.urlParam("field_name")?(parent.document.getElementById(a.urlParam("field_name")).value=g,"undefined"!==typeof parent.tinyMCE&&parent.tinyMCE.activeEditor.windowManager.close(),"undefined"!==typeof parent.$.fn.colorbox&&parent.$.fn.colorbox.close()):a.urlParam("CKEditor")?window.opener?window.opener.CKEDITOR.tools.callFunction(a.urlParam("CKEditorFuncNum"),
g):(parent.CKEDITOR.tools.callFunction(a.urlParam("CKEditorFuncNum"),g),parent.CKEDITOR.tools.callFunction(a.urlParam("CKEditorCleanUpFuncNum"))):""!=c.Properties.Width?window.opener.SetUrl(g,c.Properties.Width,c.Properties.Height):window.opener.SetUrl(g),window.opener&&window.close()):a.prompt(b.fck_select_integration)},M=function(c){var g="",e=f.security.allowChangeExtensions?c.Filename:T(c.Filename),e=b.new_filename+' : <input id="rname" name="rname" type="text" value="'+e+'" />',d={};d[b.rename]=
!0;d[b.cancel]=!1;a.prompt(e,{callback:function(d,e){if(1!=d)return!1;rname=e.children("#rname").val();if(""!=rname){var h=rname;if(!f.security.allowChangeExtensions){var h=S(rname),l=q(c.Filename);0<l.length&&(h=h+"."+l)}if("/"!=c.Path.charAt(c.Path.length-1)&&!L(h))return h="<p>"+b.INVALID_FILE_TYPE+"</p>","DISALLOW_ALL"==f.security.uploadPolicy&&(h+="<p>"+b.ALLOWED_FILE_TYPE+f.security.uploadRestrictions.join(", ")+".</p>"),"ALLOW_ALL"==f.security.uploadPolicy&&(h+="<p>"+b.DISALLOWED_FILE_TYPE+
f.security.uploadRestrictions.join(", ")+".</p>"),a("#filepath").val(""),a.prompt(h),!1;a.ajax({type:"GET",url:k+"?mode=rename&old="+c.Path+"&new="+h+"&config="+userconfig,dataType:"json",async:!1,success:function(d){if(0==d.Code){var e=d["New Path"],t=d["New Name"],h=d["Old Path"],p=a("#filetree").find('a[data-path="'+h+'"]'),l=p.parent().parent().prev("a");p.attr("data-path",e).text(t);0==l.length?u():l.click().click();p=a("#preview h1").attr("title");"undefined"!=typeof p&&p==h&&a("#preview h1").text(t);
"grid"==a("#fileinfo").data("view")?(a('#fileinfo img[data-path="'+h+'"]').parent().next("p").text(t),a('#fileinfo img[data-path="'+h+'"]').attr("data-path",e)):(a('#fileinfo td[data-path="'+h+'"]').text(t),a('#fileinfo td[data-path="'+h+'"]').attr("data-path",e));a("#preview h1").html(t);c.Path=e;c.Filename=t;a("#fileinfo").find("button#rename, button#delete, button#download").unbind();Q(c);f.options.showConfirmation&&a.prompt(b.successful_rename)}else a.prompt(d.Error);g=d["New Name"]}})}},buttons:d});
return g},O=function(c){a("#fileR").bind("change",function(){a(this).closest("form#toolbar").submit()});a("#toolbar").attr("action",k);a("#toolbar").attr("method","post");a("#toolbar").ajaxForm({target:"#uploadresponse",beforeSubmit:function(g,e,d){g=a("#fileR",e).val();if(""==g)return!1;if(q(g)!=c["File Type"])return a.prompt(b.ERROR_REPLACING_FILE+" ."+q(c.Filename)),!1;a("#replace").attr("disabled",!0);a("#upload span").addClass("loading").text(b.loading_data);if("undefined"!==typeof FileReader&&
"auto"!=typeof f.upload.fileSizeLimit&&a("#fileR",e).get(0).files[0].size>1048576*f.upload.fileSizeLimit)return a.prompt("<p>"+b.file_too_big+"</p><p>"+b.file_size_limit+f.upload.fileSizeLimit+" "+b.mb+".</p>"),a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(b.upload),!1},error:function(c,f,d){a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(b.upload);a.prompt(b.ERROR_UPLOADING_FILE)},success:function(c){c=jQuery.parseJSON(a("#uploadresponse").find("textarea").text());
0==c.Code?(c=c.Path+"/"+c.Name,F(c),a("#preview").find("img").hide().fadeIn("slow"),a("ul.jqueryFileTree").find('li a[data-path="'+c+'"]').parent().hide().fadeIn("slow"),f.options.showConfirmation&&a.prompt(b.successful_replace)):a.prompt(c.Error);a("#replace").removeAttr("disabled");a("#upload span").removeClass("loading").text(b.upload)}});a("#newfilepath").val(c.Path);a("#fileR").click()},N=function(c){var g="",e=b.move+' : <input id="rname" name="rname" type="text" value="" />',e=e+('<div class="prompt-info">'+
b.help_move+"</div>"),d={};d[b.move]=!0;d[b.cancel]=!1;a.prompt(e,{callback:function(d,e){if(1!=d)return!1;rname=e.children("#rname").val();if(""!=rname){var h=rname,h=k+"?mode=move&old="+encodeURIComponent(c.Path)+"&new="+encodeURIComponent(h)+"&root="+encodeURIComponent(fileRoot)+"&config="+userconfig;a.ajax({type:"GET",url:h,dataType:"json",async:!1,success:function(d){if(0==d.Code){var c=d["New Path"],e=d["New Name"];fullexpandedFolder=c;u();m(c);f.options.showConfirmation&&a.prompt(b.successful_moved)}else a.prompt(d.Error);
g=c+e}})}},buttons:d});return g},P=function(c){var g=!1,e=b.confirmation_delete,d={};d[b.yes]=!0;d[b.no]=!1;a.prompt(e,{callback:function(d,e){if(1!=d)return!1;var h=new Date,h=k+"?mode=delete&path="+encodeURIComponent(c.Path)+"&time="+h.getMilliseconds()+"&config="+userconfig,l=c.Path.split("/").reverse().slice(1).reverse().join("/")+"/";a.ajax({type:"GET",url:h,dataType:"json",async:!1,success:function(d){0==d.Code?(aa(d.Path),d=d.Path.substring(0,d.Path.length-1),d=d.substr(0,d.lastIndexOf("/")+
1),a("#uploader h1").text(b.current_folder+y(d)).attr("title",y(d,!1)).attr("data-path",d),g=!0,f.options.showConfirmation&&a.prompt(b.successful_delete),a("#filetree").find('a[data-path="'+l+'/"]').click().click()):(g=!1,a.prompt(d.Error))}})},buttons:d});return g},ba=function(c){isEdited=!1;a("#fileinfo").find("div#tools").append(' <a id="edit-file" href="#" title="'+b.edit+'"><span>'+b.edit+"</span></a>");a("#edit-file").click(function(){a(this).hide();var g=new Date,g=k+"?mode=editfile&path="+
encodeURIComponent(c.Path)+"&config="+userconfig+"&time="+g.getMilliseconds();a.ajax({type:"GET",url:g,dataType:"json",async:!1,success:function(e){0==e.Code?(e='<form id="edit-form">'+('<textarea id="edit-content" name="content">'+e.Content+"</textarea>"),e=e+'<input type="hidden" name="mode" value="savefile" />'+('<input type="hidden" name="path" value="'+c.Path+'" />'),e+='<button id="edit-cancel" class="edition" type="button">'+b.quit_editor+"</button>",e+='<button id="edit-save" class="edition" type="button">'+
b.save+"</button>",e+="</form>",a("#preview").find("img").hide(),a("#preview").prepend(e).hide().fadeIn(),a("#edit-cancel").click(function(){a("#preview").find("form#edit-form").hide();a("#preview").find("img").fadeIn();a("#edit-file").show()}),a("#edit-save").click(function(){var d=codeMirrorEditor.getValue();a("textarea#edit-content").val(d);d=a("#edit-form").serializeArray();a.ajax({type:"POST",url:k+"?config="+userconfig,dataType:"json",data:d,async:!1,success:function(d){0==d.Code?(isEdited=
!0,a.prompt(b.successful_edit)):(isEdited=!1,a.prompt(d.Error))}})}),codeMirrorEditor=instantiateCodeMirror(q(c.Path),f)):(isEdited=!1,a.prompt(e.Error),a(this).show())}})});return isEdited},aa=function(b){a("#filetree").find('a[data-path="'+b+'"]').parent().fadeOut("slow",function(){a(this).remove()});if(a("#uploader h1").attr("data-path")==b){var f=b.split("/").slice(0,length-2).join("/")+"/";m(f)}"grid"==a("#fileinfo").data("view")?a('#contents img[data-path="'+b+'"]').parent().parent().fadeOut("slow",
function(){a(this).remove()}):a("table#contents").find('td[data-path="'+b+'"]').parent().fadeOut("slow",function(){a(this).remove()});a("#preview").length&&m(b.substr(0,b.lastIndexOf("/")+1))},Y=function(c,g){var e='<li class="directory collapsed"><a data-path="'+c+g+'/" href="#">'+g+'</a><ul class="jqueryFileTree" style="display: block;"></ul></li>',d=a("#filetree").find('a[data-path="'+c+'"]');c!=fileRoot?d.next("ul").prepend(e).prev("a").click().click():(a("#filetree ul.jqueryFileTree").prepend(e),
a("#filetree").find('li a[data-path="'+c+g+'/"]').attr("class","cap_rename cap_delete").click(function(){m(c+g+"/")}).each(function(){a(this).contextMenu({menu:w(a(this))},function(d,b,c){b=a(b).attr("data-path");z(d,b)})}));f.options.showConfirmation&&a.prompt(b.successful_added_folder)},H=function(b){b.lastIndexOf("/")==b.length-1?(m(b),a("#filetree").find('a[data-path="'+b+'"]').click()):F(b)},z=function(b,f){var e=new Date;a.getJSON(k+"?mode=getinfo&path="+f+"&config="+userconfig+"&time="+e.getMilliseconds(),
function(d){"grid"==a("#fileinfo").data("view")?a("#fileinfo").find('img[data-path="'+d.Path+'"]').parent():a("#fileinfo").find('td[data-path="'+d.Path+'"]').parent();switch(b){case "select":E(d);break;case "download":window.location=k+"?mode=download&path="+d.Path+"&config="+userconfig+"&time="+e.getMilliseconds();break;case "rename":M(d);break;case "replace":O(d);break;case "move":N(d);break;case "delete":P(d)}})},F=function(c){a(".contextMenu").hide();var g=c.substr(0,c.lastIndexOf("/")+1);D(g);
var e;e='<div id="preview"><img /><div id="main-title"><h1></h1><div id="tools"></div></div><dl></dl></div><form id="toolbar">'+('<button id="parentfolder">'+b.parentfolder+"</button>");-1!=a.inArray("select",n)&&(a.urlParam("CKEditor")||window.opener||window.tinyMCEPopup||a.urlParam("field_name"))&&(e+='<button id="select" name="select" type="button" value="Select">'+b.select+"</button>");-1!=a.inArray("download",n)&&(e+='<button id="download" name="download" type="button" value="Download">'+b.download+
"</button>");-1!=a.inArray("rename",n)&&1!=f.options.browseOnly&&(e+='<button id="rename" name="rename" type="button" value="Rename">'+b.rename+"</button>");-1!=a.inArray("move",n)&&1!=f.options.browseOnly&&(e+='<button id="move" name="move" type="button" value="Move">'+b.move+"</button>");-1!=a.inArray("delete",n)&&1!=f.options.browseOnly&&(e+='<button id="delete" name="delete" type="button" value="Delete">'+b.del+"</button>");-1!=a.inArray("replace",n)&&1!=f.options.browseOnly&&(e+='<button id="replace" name="replace" type="button" value="Replace">'+
f.security.uploadRestrictions.join(", ")+".</p>"),a("#filepath").val(""),a.prompt(h),!1;h=k+"?mode=rename&old="+encodeURIComponent(c.Path)+"&new="+encodeURIComponent(h)+"&config="+userconfig;a.ajax({type:"GET",url:h,dataType:"json",async:!1,success:function(d){if(0==d.Code){var e=d["New Path"],t=d["New Name"],h=d["Old Path"],p=a("#filetree").find('a[data-path="'+h+'"]'),l=p.parent().parent().prev("a");p.attr("data-path",e).text(t);0==l.length?u():l.click().click();p=a("#preview h1").attr("title");
"undefined"!=typeof p&&p==h&&a("#preview h1").text(t);"grid"==a("#fileinfo").data("view")?(a('#fileinfo img[data-path="'+h+'"]').parent().next("p").text(t),a('#fileinfo img[data-path="'+h+'"]').attr("data-path",e)):(a('#fileinfo td[data-path="'+h+'"]').text(t),a('#fileinfo td[data-path="'+h+'"]').attr("data-path",e));a("#preview h1").html(t);c.Path=e;c.Filename=t;a("#fileinfo").find("button#rename, button#delete, button#download").unbind();Q(c);f.options.showConfirmation&&a.prompt(b.successful_rename)}else a.prompt(d.Error);
g=d["New Name"]}})}},buttons:d});return g},O=function(c){a("#fileR").bind("change",function(){a(this).closest("form#toolbar").submit()});a("#toolbar").attr("action",k);a("#toolbar").attr("method","post");a("#toolbar").ajaxForm({target:"#uploadresponse",beforeSubmit:function(g,e,d){g=a("#fileR",e).val();if(""==g)return!1;if(q(g)!=c["File Type"])return a.prompt(b.ERROR_REPLACING_FILE+" ."+q(c.Filename)),!1;a("#replace").attr("disabled",!0);a("#upload span").addClass("loading").text(b.loading_data);
if("undefined"!==typeof FileReader&&"auto"!=typeof f.upload.fileSizeLimit&&a("#fileR",e).get(0).files[0].size>1048576*f.upload.fileSizeLimit)return a.prompt("<p>"+b.file_too_big+"</p><p>"+b.file_size_limit+f.upload.fileSizeLimit+" "+b.mb+".</p>"),a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(b.upload),!1},error:function(c,f,d){a("#upload").removeAttr("disabled").find("span").removeClass("loading").text(b.upload);a.prompt(b.ERROR_UPLOADING_FILE)},success:function(c){c=
jQuery.parseJSON(a("#uploadresponse").find("textarea").text());0==c.Code?(c=c.Path+"/"+c.Name,F(c),a("#preview").find("img").hide().fadeIn("slow"),a("ul.jqueryFileTree").find('li a[data-path="'+c+'"]').parent().hide().fadeIn("slow"),f.options.showConfirmation&&a.prompt(b.successful_replace)):a.prompt(c.Error);a("#replace").removeAttr("disabled");a("#upload span").removeClass("loading").text(b.upload)}});a("#newfilepath").val(c.Path);a("#fileR").click()},N=function(c){var g="",e=b.move+' : <input id="rname" name="rname" type="text" value="" />',
e=e+('<div class="prompt-info">'+b.help_move+"</div>"),d={};d[b.move]=!0;d[b.cancel]=!1;a.prompt(e,{callback:function(d,e){if(1!=d)return!1;rname=e.children("#rname").val();if(""!=rname){var h=rname,h=k+"?mode=move&old="+encodeURIComponent(c.Path)+"&new="+encodeURIComponent(h)+"&root="+encodeURIComponent(fileRoot)+"&config="+userconfig;a.ajax({type:"GET",url:h,dataType:"json",async:!1,success:function(d){if(0==d.Code){var c=d["New Path"],e=d["New Name"];fullexpandedFolder=c;u();m(c);f.options.showConfirmation&&
a.prompt(b.successful_moved)}else a.prompt(d.Error);g=c+e}})}},buttons:d});return g},P=function(c){var g=!1,e=b.confirmation_delete,d={};d[b.yes]=!0;d[b.no]=!1;a.prompt(e,{callback:function(d,e){if(1!=d)return!1;var h=new Date,h=k+"?mode=delete&path="+encodeURIComponent(c.Path)+"&time="+h.getMilliseconds()+"&config="+userconfig,l=c.Path.split("/").reverse().slice(1).reverse().join("/")+"/";a.ajax({type:"GET",url:h,dataType:"json",async:!1,success:function(d){0==d.Code?(aa(d.Path),d=d.Path.substring(0,
d.Path.length-1),d=d.substr(0,d.lastIndexOf("/")+1),a("#uploader h1").text(b.current_folder+y(d)).attr("title",y(d,!1)).attr("data-path",d),g=!0,f.options.showConfirmation&&a.prompt(b.successful_delete),a("#filetree").find('a[data-path="'+l+'/"]').click().click()):(g=!1,a.prompt(d.Error))}})},buttons:d});return g},ba=function(c){isEdited=!1;a("#fileinfo").find("div#tools").append(' <a id="edit-file" href="#" title="'+b.edit+'"><span>'+b.edit+"</span></a>");a("#edit-file").click(function(){a(this).hide();
var g=new Date,g=k+"?mode=editfile&path="+encodeURIComponent(c.Path)+"&config="+userconfig+"&time="+g.getMilliseconds();a.ajax({type:"GET",url:g,dataType:"json",async:!1,success:function(e){0==e.Code?(e='<form id="edit-form">'+('<textarea id="edit-content" name="content">'+e.Content+"</textarea>"),e=e+'<input type="hidden" name="mode" value="savefile" />'+('<input type="hidden" name="path" value="'+c.Path+'" />'),e+='<button id="edit-cancel" class="edition" type="button">'+b.quit_editor+"</button>",
e+='<button id="edit-save" class="edition" type="button">'+b.save+"</button>",e+="</form>",a("#preview").find("img").hide(),a("#preview").prepend(e).hide().fadeIn(),a("#edit-cancel").click(function(){a("#preview").find("form#edit-form").hide();a("#preview").find("img").fadeIn();a("#edit-file").show()}),a("#edit-save").click(function(){var d=codeMirrorEditor.getValue();a("textarea#edit-content").val(d);d=a("#edit-form").serializeArray();a.ajax({type:"POST",url:k+"?config="+userconfig,dataType:"json",
data:d,async:!1,success:function(d){0==d.Code?(isEdited=!0,a.prompt(b.successful_edit)):(isEdited=!1,a.prompt(d.Error))}})}),codeMirrorEditor=instantiateCodeMirror(q(c.Path),f)):(isEdited=!1,a.prompt(e.Error),a(this).show())}})});return isEdited},aa=function(b){a("#filetree").find('a[data-path="'+b+'"]').parent().fadeOut("slow",function(){a(this).remove()});if(a("#uploader h1").attr("data-path")==b){var f=b.split("/").slice(0,length-2).join("/")+"/";m(f)}"grid"==a("#fileinfo").data("view")?a('#contents img[data-path="'+
b+'"]').parent().parent().fadeOut("slow",function(){a(this).remove()}):a("table#contents").find('td[data-path="'+b+'"]').parent().fadeOut("slow",function(){a(this).remove()});a("#preview").length&&m(b.substr(0,b.lastIndexOf("/")+1))},Y=function(c,g){var e='<li class="directory collapsed"><a data-path="'+c+g+'/" href="#">'+g+'</a><ul class="jqueryFileTree" style="display: block;"></ul></li>',d=a("#filetree").find('a[data-path="'+c+'"]');c!=fileRoot?d.next("ul").prepend(e).prev("a").click().click():
(a("#filetree ul.jqueryFileTree").prepend(e),a("#filetree").find('li a[data-path="'+c+g+'/"]').attr("class","cap_rename cap_delete").click(function(){m(c+g+"/")}).each(function(){a(this).contextMenu({menu:w(a(this))},function(d,b,c){b=a(b).attr("data-path");z(d,b)})}));f.options.showConfirmation&&a.prompt(b.successful_added_folder)},H=function(b){b.lastIndexOf("/")==b.length-1?(m(b),a("#filetree").find('a[data-path="'+b+'"]').click()):F(b)},z=function(b,f){var e=new Date;a.getJSON(k+"?mode=getinfo&path="+
encodeURIComponent(f)+"&config="+userconfig+"&time="+e.getMilliseconds(),function(d){"grid"==a("#fileinfo").data("view")?a("#fileinfo").find('img[data-path="'+d.Path+'"]').parent():a("#fileinfo").find('td[data-path="'+d.Path+'"]').parent();switch(b){case "select":E(d);break;case "download":window.location=k+"?mode=download&path="+d.Path+"&config="+userconfig+"&time="+e.getMilliseconds();break;case "rename":M(d);break;case "replace":O(d);break;case "move":N(d);break;case "delete":P(d)}})},F=function(c){a(".contextMenu").hide();
var g=c.substr(0,c.lastIndexOf("/")+1);D(g);var e;e='<div id="preview"><img /><div id="main-title"><h1></h1><div id="tools"></div></div><dl></dl></div><form id="toolbar">'+('<button id="parentfolder">'+b.parentfolder+"</button>");-1!=a.inArray("select",n)&&(a.urlParam("CKEditor")||window.opener||window.tinyMCEPopup||a.urlParam("field_name"))&&(e+='<button id="select" name="select" type="button" value="Select">'+b.select+"</button>");-1!=a.inArray("download",n)&&(e+='<button id="download" name="download" type="button" value="Download">'+
b.download+"</button>");-1!=a.inArray("rename",n)&&1!=f.options.browseOnly&&(e+='<button id="rename" name="rename" type="button" value="Rename">'+b.rename+"</button>");-1!=a.inArray("move",n)&&1!=f.options.browseOnly&&(e+='<button id="move" name="move" type="button" value="Move">'+b.move+"</button>");-1!=a.inArray("delete",n)&&1!=f.options.browseOnly&&(e+='<button id="delete" name="delete" type="button" value="Delete">'+b.del+"</button>");-1!=a.inArray("replace",n)&&1!=f.options.browseOnly&&(e+='<button id="replace" name="replace" type="button" value="Replace">'+
b.replace+"</button>",e+='<div class="hidden-file-input"><input id="fileR" name="fileR" type="file" /></div>',e+='<input id="mode" name="mode" type="hidden" value="replace" /> ',e+='<input id="newfilepath" name="newfilepath" type="hidden" />');e+="</form>";0<a("#fileinfo .mCSB_container").length?a("#fileinfo .mCSB_container").html(e):a("#fileinfo").html(e);a("#parentfolder").click(function(){m(g)});e=new Date;a.getJSON(k+"?mode=getinfo&path="+encodeURIComponent(c)+"&config="+userconfig+"&time="+e.getMilliseconds(),
function(d){if(0==d.Code){a("#fileinfo").find("h1").text(d.Filename).attr("title",c);a("#fileinfo").find("img").attr("src",d.Preview);var e;e=-1!=a.inArray(q(d.Filename),f.videos.videosExt)?!0:!1;e&&1==f.videos.showVideoPlayer&&U(d);e=-1!=a.inArray(q(d.Filename),f.audios.audiosExt)?!0:!1;e&&1==f.audios.showAudioPlayer&&V(d);e=-1!=a.inArray(q(d.Filename),f.pdfs.pdfsExt)?!0:!1;e&&1==f.pdfs.showPdfReader&&W(d);e=-1!=a.inArray(q(d.Filename),f.edit.editExt)?!0:!1;e&&1==f.edit.enabled&&0==d.Protected&&
ba(d);e=new Date;var g=!1!==f.options.baseUrl?smartPath(baseUrl,d.Path.replace(fileRoot,"")):d.Path;0==d.Protected&&(a("#fileinfo").find("div#tools").append(' <a id="copy-button" data-clipboard-text="'+g+'" title="'+b.copy_to_clipboard+'" href="#"><span>'+b.copy_to_clipboard+"</span></a>"),loadJS("./scripts/zeroclipboard/copy.js?d"+e.getMilliseconds()),a("#copy-button").click(function(){a("#fileinfo").find("div#tools").append('<span id="copied">'+b.copied+"</span>");a("#copied").delay(500).fadeOut(1E3,

View File

@@ -0,0 +1,91 @@
{
"ALLOWED_FILE_TYPE": "فقط الملفات الاتية هي المسموحة : ",
"AUTHORIZATION_REQUIRED": "غير مصرح لك باستخدام مدير الملفات.",
"DIRECTORY_ALREADY_EXISTS": "المجلد '%s' موجود مسبقا.",
"DIRECTORY_NOT_EXIST": "المجلد %s غير موجود.",
"DISALLOWED_FILE_TYPE": "الملفات الاتية غير مسموحة : ",
"ERROR_CREATING_ZIP": "خطا في انشاء الملف المضغوط",
"ERROR_OPENING_FILE": "خطا في فتح الملف.",
"ERROR_RENAMING_DIRECTORY": " حدث خطا اثناء تعديل اسم المجلد من %s الى %s.",
"ERROR_RENAMING_FILE": " حدث خطا اثناء تعديل اسم الملف من %s الى %s.",
"ERROR_REPLACING_FILE": "يرجى تقديم ملف يحمل الاختصار الاتي :",
"ERROR_SAVING_FILE": "خطاء اثناء حفظ الملف.",
"ERROR_UPLOADING_FILE": "خطاء اثناء رفع الملف.",
"ERROR_WRITING_PERM": "لم تقم بكتابة التصاريح على هذا الملف.",
"FILE_ALREADY_EXISTS": "الملف '%s' موجود مسبقاً.",
"FILE_DOES_NOT_EXIST": "الملف %s غير موجود.",
"INVALID_ACTION": "عملية غير صحيحة.",
"INVALID_DIRECTORY_OR_FILE": "ملف اومجلد غير صحيح.",
"INVALID_FILE_TYPE": "نوع الملف غير مسموح به.",
"INVALID_FILE_UPLOAD": "الملف المحمل خطىء.",
"INVALID_VAR": "متغير خطىء %s.",
"LANGUAGE_FILE_NOT_FOUND": "ملف اللغة غير موجود.",
"MODE_ERROR": "حالة خطئة.",
"NOT_ALLOWED": "غير مصرح لك باتمام العملية",
"NOT_ALLOWED_SYSTEM": "صلاحيات النظام لا تجيز لك اتمام هذه العملية",
"UNABLE_TO_CREATE_DIRECTORY": "لم اتمكن من انشاء المجلد %s.",
"UNABLE_TO_OPEN_DIRECTORY": "غير ممكن فتح المجلد %s.",
"UPLOAD_FILES_SMALLER_THAN": "يرجى فقط رفع ملفات مشابهة ل %s.",
"UPLOAD_IMAGES_ONLY": "يرجى رفع صور فقط, nباقي الملفات غير مسموحة",
"UPLOAD_IMAGES_TYPE_JPEG_GIF_PNG": "يرجى رفع ملفات من نوع JPEG, GIF او PNG.",
"browse": "تصفح...",
"bytes": " بايتس",
"cancel": "الغاء",
"close": "اقفال",
"confirmation_delete": "هل انت متاكد من انك تود خذف هذا الملف ؟",
"copied": "تم نسخ الرابط !",
"copy_to_clipboard": "تم نسخ الرابط الى الكليببورد",
"could_not_retrieve_folder": "لا يمكن احذار محتويات المجلد.",
"create_folder": "انشاء مجلد",
"created": "تم الانشاء",
"current_folder": "المجلد الحالي: ",
"default_foldername": "مجلداتي",
"del": "حذف",
"dimensions": "تجاهل",
"download": "تنزيل",
"dz_dictDefaultMessage": "ضع الملفات هنا للتحميل",
"dz_dictFallbackMessage": "متصفحك لا يدعم خاصية تحميل الملفات عن طريق الدراج دروب",
"dz_dictInvalidFileType": "لا يمكنك تحميل ملفات من هذا النوع.",
"dz_dictMaxFilesExceeded": "يمكنك فقط تحميل %s من الملفات",
"edit": "تحرير الملف",
"fck_select_integration": "الفنكشن المحددة تعمل فقط مع FCKEditor.",
"file_size_limit": "الحجم المسموح (لكل ملف) هو ",
"file_too_big": "الملف اكبر من المسموح.",
"gb": "جيجابيت",
"grid_view": "انتقال لمشاهدة مصغرات.",
"help_move": "استعمال '../' ممنوع. يمكنك الوصول للمجلد الجذر عن طريق'/'.",
"items": "ملفات",
"kb": "كيلوبيت",
"list_view": "انتقال لوضع مشاهدة القوائم.",
"loading_data": "جاري نقل البيانات ...",
"mb": "ميجا بايت",
"modified": "معدل",
"move": "انقل الى ...",
"name": "الاسم",
"new_filename": "اختر اسم جديد للملف",
"new_folder": "مجلد جديد",
"no": "لا",
"no_foldername": "لم تقم بتزود اسم المجلد.",
"parentfolder": "المجلد الام",
"prompt_foldername": "اكتب اسم المجلد الجديد",
"quit_editor": "اخرج من المحرر",
"rename": "اعادة تسمية",
"replace": "استبدال الملف",
"save": "حفظ",
"search": "بحث",
"search_reset": "اعادة",
"select": "اختيار",
"select_from_left": "اختار ملفات من اليسار.",
"size": "الحجم",
"successful_added_file": "تم اضافة الملف/ الملفات الجديدة بنجاح.",
"successful_added_folder": "تم اضافة المجلد الجديد بنجاح.",
"successful_delete": "تم الحذف.",
"successful_edit": "تم التحديث بنجاح.",
"successful_moved": "تم النقل بنجاح ",
"successful_rename": "تمت اعادة التسمية بنجاح .",
"successful_replace": "تم استبدال الملف بنجاح.",
"support_fm": "مدير الملفات برنامج مجاني يرجى دعمه !",
"upload": "رفع",
"version": "الاصدار",
"yes": "نعم"
}

View File

@@ -1,28 +1,28 @@
{
"ALLOWED_FILE_TYPE": "Only following files are allowed : ",
"ALLOWED_FILE_TYPE": "Només els següents arxius són permesos : ",
"AUTHORIZATION_REQUIRED": "No estàs autoritzat a fer ser servir l'administrador d'arxius.",
"DIRECTORY_ALREADY_EXISTS": "La carpeta '%s' ja existeix.",
"DIRECTORY_NOT_EXIST": "La carpeta %s no existeix.",
"DISALLOWED_FILE_TYPE": "Following files are not allowed : ",
"ERROR_CREATING_ZIP": "Error creating Zip archive",
"ERROR_OPENING_FILE": "Error opening file.",
"DISALLOWED_FILE_TYPE": "Els següents arxius no són permesos : ",
"ERROR_CREATING_ZIP": "Error creant l'arxiu Zip",
"ERROR_OPENING_FILE": "Error obrint l'arxiu.",
"ERROR_RENAMING_DIRECTORY": "Error al canviar el nom de la carpeta %s a %s.",
"ERROR_RENAMING_FILE": "Error al canviar el nom de l'arxiu %s a %s.",
"ERROR_REPLACING_FILE": "Please, provide a file having the following extension :",
"ERROR_SAVING_FILE": "Error saving file.",
"ERROR_UPLOADING_FILE": "Error uploading file.",
"ERROR_WRITING_PERM": "You don't have write permissions on that file.",
"FILE_ALREADY_EXISTS": "The file '%s' already exists.",
"FILE_DOES_NOT_EXIST": "L'arxiu %s no existeix.",
"ERROR_REPLACING_FILE": "Si us plau, proporciona un arxiu amb la següent extensió :",
"ERROR_SAVING_FILE": "Error guardant arxiu.",
"ERROR_UPLOADING_FILE": "Error pujant arxiu.",
"ERROR_WRITING_PERM": "No tens permisos per modificar aquest arxiu.",
"FILE_ALREADY_EXISTS": "L'arxiu '%s' ja exists.",
"FILE_DOES_NOT_EXIST": "L'arxiu '%s' no existeix.",
"INVALID_ACTION": "Acció invàlida.",
"INVALID_DIRECTORY_OR_FILE": "Carpeta o arxiu invàlid.",
"INVALID_FILE_TYPE": "File type is not allowed.",
"INVALID_FILE_TYPE": "Aquest tipus d'arxiu no és permés.",
"INVALID_FILE_UPLOAD": "Transferencia d'arxiu invàlida.",
"INVALID_VAR": "Variable %s invàlida.",
"LANGUAGE_FILE_NOT_FOUND": "No s'ha trobat l'arxiu d'idioma.",
"MODE_ERROR": "Error de mode.",
"NOT_ALLOWED": "You are not allowed to process this action",
"NOT_ALLOWED_SYSTEM": "System permissions do not allow you to perform this action",
"NOT_ALLOWED": "No pots dur a terme aquesta acció",
"NOT_ALLOWED_SYSTEM": "Els permisos del sistemta no et permeten dur a terme aquesta acció",
"UNABLE_TO_CREATE_DIRECTORY": "Impossible crear la carpeta %s.",
"UNABLE_TO_OPEN_DIRECTORY": "No s'ha pogut obrir la carpeta %s.",
"UPLOAD_FILES_SMALLER_THAN": "Si us plau, Pugeu només arxius amb tamany inferior a  %s.",
@@ -31,10 +31,10 @@
"browse": "Browse...",
"bytes": " bytes",
"cancel": "Cancel·lar",
"close": "Close",
"close": "Tancar",
"confirmation_delete": "Estàs segur de voler eliminar aquest arxiu?",
"copied": "URL copied !",
"copy_to_clipboard": "Copy to Clipboard",
"copied": "URL copiada !",
"copy_to_clipboard": "Copiar al portapapers",
"could_not_retrieve_folder": "No s'ha pogut recuperar el contingut de la carpeta.",
"create_folder": "Crear una carpeta",
"created": "Creat",
@@ -43,14 +43,14 @@
"del": "Eliminar",
"dimensions": "Dimensions",
"download": "Descarregar",
"dz_dictDefaultMessage": "Drop files here to upload",
"dz_dictDefaultMessage": "Arrossega aquí els fitxers per pujar-los",
"dz_dictFallbackMessage": "Your browser does not support drag'n'drop file uploads.",
"dz_dictInvalidFileType": "You can't upload files of this type.",
"dz_dictMaxFilesExceeded": "Only %s simultaneous uploads are allowed.",
"dz_dictInvalidFileType": "No pots pujar arxius d'aquest tipus.",
"dz_dictMaxFilesExceeded": "Només es permet pujar %s simultàneament.",
"edit": "Edit file",
"fck_select_integration": "La funció 'Seleccionar' només es far servir des de FCKEditor.",
"file_size_limit": "The file size limit is : ",
"file_too_big": "The file is too big.",
"file_size_limit": "El tamany màxim dels arxius és de : ",
"file_too_big": "L'arxiu és massa gran.",
"gb": "gb",
"grid_view": "Canviar a vista de quadricular.",
"help_move": "The use of '../' is forbidden. You can access root folder by using '/'.",
@@ -70,22 +70,22 @@
"prompt_foldername": "Introdueix el nom de la nova carpeta",
"quit_editor": "Quit editor",
"rename": "Canviar el nom",
"replace": "Replace file",
"replace": "Substituir arxiu",
"save": "Save",
"search": "Search",
"search": "Buscar",
"search_reset": "Reset",
"select": "Seleccionar",
"select_from_left": "Selecciona un element de l'esquerra.",
"size": "Tamany",
"successful_added_file": "Nou arxiu afegit satisfactòriament.",
"successful_added_folder": "Nova carpeta afegida satisfactòriament.",
"successful_delete": "Eliminació amb èxit.",
"successful_edit": "Content update successful.",
"successful_moved": "Move successful.",
"successful_rename": "Canvi de nom amb èxit.",
"successful_replace": "File replacement successful.",
"successful_added_file": "Arxiu afegit.",
"successful_added_folder": "Carpeta creada.",
"successful_delete": "Arxiu eliminat.",
"successful_edit": "Arxiu actualitzat.",
"successful_moved": "Arxiu mogut.",
"successful_rename": "Nom modificat.",
"successful_replace": "Arxiu substituit.",
"support_fm": "Filemanager is a free software, please support !",
"upload": "Pujar arxiu",
"version": "version",
"version": "versió",
"yes": "Sí"
}
}

View File

@@ -13,7 +13,9 @@
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
* 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();
*
@@ -37,8 +39,6 @@ namespace Composer\Autoload;
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
@@ -147,7 +147,7 @@ class ClassLoader
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param array|string $paths The PSR-0 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException

View File

@@ -8,24 +8,24 @@ $baseDir = dirname($vendorDir);
return array(
'Absolute_Positioner' => $vendorDir . '/dompdf/dompdf/include/absolute_positioner.cls.php',
'Abstract_Renderer' => $vendorDir . '/dompdf/dompdf/include/abstract_renderer.cls.php',
'AddForeignKeysToCannedResponseTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_canned_response_table.php',
'AddForeignKeysToDepartmentTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_department_table.php',
'AddForeignKeysToEmailsTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_emails_table.php',
'AddForeignKeysToGroupAssignDepartmentTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_group_assign_department_table.php',
'AddForeignKeysToHelpTopicTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_help_topic_table.php',
'AddForeignKeysToKbArticleRelationshipTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_kb_article_relationship_table.php',
'AddForeignKeysToKbCommentTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_kb_comment_table.php',
'AddForeignKeysToOrganizationTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_organization_table.php',
'AddForeignKeysToSettingsSystemTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_settings_system_table.php',
'AddForeignKeysToTeamAssignAgentTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_team_assign_agent_table.php',
'AddForeignKeysToTeamsTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_teams_table.php',
'AddForeignKeysToTicketAttachmentTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_ticket_attachment_table.php',
'AddForeignKeysToTicketCollaboratorTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_ticket_collaborator_table.php',
'AddForeignKeysToTicketFormDataTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_ticket_form_data_table.php',
'AddForeignKeysToTicketThreadTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_ticket_thread_table.php',
'AddForeignKeysToTicketsTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_tickets_table.php',
'AddForeignKeysToUserAssignOrganizationTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_user_assign_organization_table.php',
'AddForeignKeysToUsersTable' => $baseDir . '/database/migrations/2016_01_25_075612_add_foreign_keys_to_users_table.php',
'AddForeignKeysToCannedResponseTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_canned_response_table.php',
'AddForeignKeysToDepartmentTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_department_table.php',
'AddForeignKeysToEmailsTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_emails_table.php',
'AddForeignKeysToGroupAssignDepartmentTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_group_assign_department_table.php',
'AddForeignKeysToHelpTopicTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_help_topic_table.php',
'AddForeignKeysToKbArticleRelationshipTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_kb_article_relationship_table.php',
'AddForeignKeysToKbCommentTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_kb_comment_table.php',
'AddForeignKeysToOrganizationTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_organization_table.php',
'AddForeignKeysToSettingsSystemTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_settings_system_table.php',
'AddForeignKeysToTeamAssignAgentTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_team_assign_agent_table.php',
'AddForeignKeysToTeamsTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_teams_table.php',
'AddForeignKeysToTicketAttachmentTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_ticket_attachment_table.php',
'AddForeignKeysToTicketCollaboratorTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_ticket_collaborator_table.php',
'AddForeignKeysToTicketFormDataTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_ticket_form_data_table.php',
'AddForeignKeysToTicketThreadTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_ticket_thread_table.php',
'AddForeignKeysToTicketsTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_tickets_table.php',
'AddForeignKeysToUserAssignOrganizationTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_user_assign_organization_table.php',
'AddForeignKeysToUsersTable' => $baseDir . '/database/migrations/2016_02_16_140454_add_foreign_keys_to_users_table.php',
'Adobe_Font_Metrics' => $vendorDir . '/phenx/php-font-lib/classes/Adobe_Font_Metrics.php',
'Attribute_Translator' => $vendorDir . '/dompdf/dompdf/include/attribute_translator.cls.php',
'Block_Frame_Decorator' => $vendorDir . '/dompdf/dompdf/include/block_frame_decorator.cls.php',
@@ -38,54 +38,55 @@ return array(
'Canvas' => $vendorDir . '/dompdf/dompdf/include/canvas.cls.php',
'Canvas_Factory' => $vendorDir . '/dompdf/dompdf/include/canvas_factory.cls.php',
'Cellmap' => $vendorDir . '/dompdf/dompdf/include/cellmap.cls.php',
'CreateBanlistTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_banlist_table.php',
'CreateCannedResponseTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_canned_response_table.php',
'CreateCustomFormFieldsTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_custom_form_fields_table.php',
'CreateCustomFormsTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_custom_forms_table.php',
'CreateDateFormatTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_date_format_table.php',
'CreateDateTimeFormatTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_date_time_format_table.php',
'CreateDepartmentTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_department_table.php',
'CreateEmailsTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_emails_table.php',
'CreateGroupAssignDepartmentTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_group_assign_department_table.php',
'CreateGroupsTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_groups_table.php',
'CreateHelpTopicTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_help_topic_table.php',
'CreateKbArticleRelationshipTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_kb_article_relationship_table.php',
'CreateKbArticleTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_kb_article_table.php',
'CreateKbCategoryTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_kb_category_table.php',
'CreateKbCommentTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_kb_comment_table.php',
'CreateKbPagesTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_kb_pages_table.php',
'CreateKbSettingsTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_kb_settings_table.php',
'CreateLanguagesTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_languages_table.php',
'CreateLogNotificationTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_log_notification_table.php',
'CreateMailboxProtocolTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_mailbox_protocol_table.php',
'CreateOrganizationTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_organization_table.php',
'CreatePasswordResetsTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_password_resets_table.php',
'CreatePluginsTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_plugins_table.php',
'CreateSendMailTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_send_mail_table.php',
'CreateSettingsAlertNoticeTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_settings_alert_notice_table.php',
'CreateSettingsAutoResponseTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_settings_auto_response_table.php',
'CreateSettingsCompanyTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_settings_company_table.php',
'CreateSettingsEmailTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_settings_email_table.php',
'CreateSettingsSystemTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_settings_system_table.php',
'CreateSettingsTicketTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_settings_ticket_table.php',
'CreateSlaPlanTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_sla_plan_table.php',
'CreateTeamAssignAgentTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_team_assign_agent_table.php',
'CreateTeamsTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_teams_table.php',
'CreateTemplateTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_template_table.php',
'CreateTicketAttachmentTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_ticket_attachment_table.php',
'CreateTicketCollaboratorTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_ticket_collaborator_table.php',
'CreateTicketFormDataTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_ticket_form_data_table.php',
'CreateTicketPriorityTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_ticket_priority_table.php',
'CreateTicketSourceTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_ticket_source_table.php',
'CreateTicketStatusTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_ticket_status_table.php',
'CreateTicketThreadTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_ticket_thread_table.php',
'CreateTicketsTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_tickets_table.php',
'CreateTimeFormatTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_time_format_table.php',
'CreateTimezoneTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_timezone_table.php',
'CreateUserAssignOrganizationTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_user_assign_organization_table.php',
'CreateUsersTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_users_table.php',
'CreateVersionCheckTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_version_check_table.php',
'CreateWidgetsTable' => $baseDir . '/database/migrations/2016_01_25_075608_create_widgets_table.php',
'CreateBanlistTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_banlist_table.php',
'CreateCannedResponseTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_canned_response_table.php',
'CreateCustomFormFieldsTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_custom_form_fields_table.php',
'CreateCustomFormsTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_custom_forms_table.php',
'CreateDateFormatTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_date_format_table.php',
'CreateDateTimeFormatTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_date_time_format_table.php',
'CreateDepartmentTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_department_table.php',
'CreateEmailsTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_emails_table.php',
'CreateGroupAssignDepartmentTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_group_assign_department_table.php',
'CreateGroupsTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_groups_table.php',
'CreateHelpTopicTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_help_topic_table.php',
'CreateKbArticleRelationshipTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_kb_article_relationship_table.php',
'CreateKbArticleTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_kb_article_table.php',
'CreateKbCategoryTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_kb_category_table.php',
'CreateKbCommentTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_kb_comment_table.php',
'CreateKbPagesTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_kb_pages_table.php',
'CreateKbSettingsTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_kb_settings_table.php',
'CreateLanguagesTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_languages_table.php',
'CreateLogNotificationTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_log_notification_table.php',
'CreateMailboxProtocolTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_mailbox_protocol_table.php',
'CreateOrganizationTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_organization_table.php',
'CreatePasswordResetsTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_password_resets_table.php',
'CreatePluginsTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_plugins_table.php',
'CreateSendMailTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_send_mail_table.php',
'CreateSettingsAlertNoticeTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_settings_alert_notice_table.php',
'CreateSettingsAutoResponseTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_settings_auto_response_table.php',
'CreateSettingsCompanyTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_settings_company_table.php',
'CreateSettingsEmailTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_settings_email_table.php',
'CreateSettingsRatingsTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_settings_ratings_table.php',
'CreateSettingsSystemTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_settings_system_table.php',
'CreateSettingsTicketTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_settings_ticket_table.php',
'CreateSlaPlanTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_sla_plan_table.php',
'CreateTeamAssignAgentTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_team_assign_agent_table.php',
'CreateTeamsTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_teams_table.php',
'CreateTemplateTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_template_table.php',
'CreateTicketAttachmentTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_ticket_attachment_table.php',
'CreateTicketCollaboratorTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_ticket_collaborator_table.php',
'CreateTicketFormDataTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_ticket_form_data_table.php',
'CreateTicketPriorityTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_ticket_priority_table.php',
'CreateTicketSourceTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_ticket_source_table.php',
'CreateTicketStatusTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_ticket_status_table.php',
'CreateTicketThreadTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_ticket_thread_table.php',
'CreateTicketsTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_tickets_table.php',
'CreateTimeFormatTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_time_format_table.php',
'CreateTimezoneTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_timezone_table.php',
'CreateUserAssignOrganizationTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_user_assign_organization_table.php',
'CreateUsersTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_users_table.php',
'CreateVersionCheckTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_version_check_table.php',
'CreateWidgetsTable' => $baseDir . '/database/migrations/2016_02_16_140450_create_widgets_table.php',
'DOMPDF' => $vendorDir . '/dompdf/dompdf/include/dompdf.cls.php',
'DOMPDF_Exception' => $vendorDir . '/dompdf/dompdf/include/dompdf_exception.cls.php',
'DOMPDF_Image_Exception' => $vendorDir . '/dompdf/dompdf/include/dompdf_image_exception.cls.php',

View File

@@ -6,18 +6,18 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'9f7f3f9b1f82484e76bcd07b985a2d2f' => $vendorDir . '/symfony/var-dumper/Symfony/Component/VarDumper/Resources/functions/dump.php',
'fe1bcd0336136e435eaf197895daf81a' => $vendorDir . '/nikic/php-parser/lib/bootstrap.php',
'e40631d46120a9c38ea139981f8dab26' => $vendorDir . '/ircmaxell/password-compat/lib/password.php',
'2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
'5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
'bd9634f2d41831496de0d3dfe4c94881' => $vendorDir . '/symfony/polyfill-php56/bootstrap.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'3919eeb97e98d4648304477f8ef734ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
'e7223560d890eab89cda23685e711e2c' => $vendorDir . '/psy/psysh/src/Psy/functions.php',
'65fec9ebcfbb3cbb4fd0d519687aea01' => $vendorDir . '/danielstjules/stringy/src/Create.php',
'f0906e6318348a765ffb6eb24e0d0938' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
'58571171fd5812e6e447dce228f52f4d' => $vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php',
'752af1c2bdb339e8474c3c31b22b7d54' => $vendorDir . '/illuminate/html/helpers.php',
'017b24472353920ed42bb364f7653c43' => $vendorDir . '/propaganistas/laravel-phone/src/helpers.php',
$vendorDir . '/symfony/var-dumper/Symfony/Component/VarDumper/Resources/functions/dump.php',
$vendorDir . '/nikic/php-parser/lib/bootstrap.php',
$vendorDir . '/ircmaxell/password-compat/lib/password.php',
$vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
$vendorDir . '/paragonie/random_compat/lib/random.php',
$vendorDir . '/symfony/polyfill-php56/bootstrap.php',
$vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
$vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
$vendorDir . '/psy/psysh/src/Psy/functions.php',
$vendorDir . '/danielstjules/stringy/src/Create.php',
$vendorDir . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
$vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php',
$vendorDir . '/illuminate/html/helpers.php',
$vendorDir . '/propaganistas/laravel-phone/src/helpers.php',
);

View File

@@ -45,19 +45,15 @@ class ComposerAutoloaderInit1bacc9bd2a82216bf11bc15e6aee6c79
$loader->register(true);
$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire1bacc9bd2a82216bf11bc15e6aee6c79($fileIdentifier, $file);
foreach ($includeFiles as $file) {
composerRequire1bacc9bd2a82216bf11bc15e6aee6c79($file);
}
return $loader;
}
}
function composerRequire1bacc9bd2a82216bf11bc15e6aee6c79($fileIdentifier, $file)
function composerRequire1bacc9bd2a82216bf11bc15e6aee6c79($file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
require $file;
}

File diff suppressed because it is too large Load Diff

View File

@@ -2,4 +2,4 @@
# It can be a commit, branch or tag of the https://github.com/googlei18n/libphonenumber project
#
# For more information, look at the phing tasks in build.xml
libphonenumber-7.2.5
libphonenumber-7.2.6

View File

@@ -24,7 +24,12 @@ return array (
),
'mobile' =>
array (
'NationalNumberPattern' => '77[6-8]\\d{5}',
'NationalNumberPattern' => '
77(?:
08|
[6-8]\\d
)\\d{4}
',
'PossibleNumberPattern' => '\\d{8}',
'ExampleNumber' => '77831001',
),

View File

@@ -18,7 +18,7 @@ return array (
2(?:
(?:
[015-7]\\d|
2[2-9]|
2[02-9]|
3[2-57]|
4[2-8]|
8[235-7]

View File

@@ -62,7 +62,7 @@ return array (
)|
4(?:
[06]|
1\\d
1\\d?
)|
5(?:
[01357]|

View File

@@ -34,7 +34,7 @@ return array (
4[67]|
5[12]|
6[014]|
8[56]
8[056]
)|
4(?:
0[124-9]|
@@ -128,7 +128,7 @@ return array (
4[67]|
5[12]|
6[014]|
8[56]
8[056]
)|
4(?:
0[124-9]|

View File

@@ -27,10 +27,11 @@ return array (
1(?:
1[78]|
28|
330|
82
)
',
'PossibleNumberPattern' => '\\d{3}',
'PossibleNumberPattern' => '\\d{3,4}',
'ExampleNumber' => '118',
),
'premiumRate' =>
@@ -83,7 +84,10 @@ return array (
2[01389]|
3(?:
2|
39|
3[039]|
45|
66|
88|
9[18]
)|
82

View File

@@ -0,0 +1,9 @@
<?php
/**
* This file is automatically @generated by {@link GeneratePhonePrefixData}.
* Please don't modify it directly.
*/
return array (
1380 => 'Ohio',
);

View File

@@ -7,6 +7,7 @@
return array (
212520 => 'Casablanca',
212521 => 'Casablanca/Central Morocco',
2125220 => 'Casablanca',
2125222 => 'Casablanca',
2125223 => 'Casablanca',
2125224 => 'Casablanca',

View File

@@ -7,6 +7,7 @@
return array (
212520 => 'Casablanca',
212521 => 'Casablanca/Maroc Central',
2125220 => 'Casablanca',
2125222 => 'Casablanca',
2125223 => 'Casablanca',
2125224 => 'Casablanca',

View File

@@ -1,5 +1,11 @@
# CHANGELOG
## 1.2.3 - 2016-02-18
* Fixed support in `GuzzleHttp\Psr7\CachingStream` for seeking forward on remote
streams, which can sometimes return fewer bytes than requested with `fread`.
* Fixed handling of gzipped responses with FNAME headers.
## 1.2.2 - 2016-01-22
* Added support for URIs without any authority.

View File

@@ -38,7 +38,7 @@ echo $composed(); // abc, 123. Above all listen to me.
`GuzzleHttp\Psr7\BufferStream`
Provides a buffer stream that can be written to to fill a buffer, and read
Provides a buffer stream that can be written to fill a buffer, and read
from to remove bytes from the buffer.
This stream returns a "hwm" metadata value that tells upstream consumers
@@ -106,7 +106,7 @@ echo $stream; // 0123456789
Compose stream implementations based on a hash of functions.
Allows for easy testing and extension of a provided stream without needing to
Allows for easy testing and extension of a provided stream without needing
to create a concrete class for a simple extension point.
```php

View File

@@ -60,9 +60,12 @@ class CachingStream implements StreamInterface
$diff = $byte - $this->stream->getSize();
if ($diff > 0) {
// If the seek byte is greater the number of read bytes, then read
// the difference of bytes to cache the bytes and inherently seek.
$this->read($diff);
// Read the remoteStream until we have read in at least the amount
// of bytes requested, or we reach the end of the file.
while ($diff > 0 && !$this->remoteStream->eof()) {
$this->read($diff);
$diff = $byte - $this->stream->getSize();
}
} else {
// We can just do a normal seek since we've already seen this byte.
$this->stream->seek($byte);

View File

@@ -20,10 +20,33 @@ class InflateStream implements StreamInterface
public function __construct(StreamInterface $stream)
{
// Skip the first 10 bytes
$stream = new LimitStream($stream, -1, 10);
// read the first 10 bytes, ie. gzip header
$header = $stream->read(10);
$filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header);
// Skip the header, that is 10 + length of filename + 1 (nil) bytes
$stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength);
$resource = StreamWrapper::getResource($stream);
stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
$this->stream = new Stream($resource);
}
/**
* @param StreamInterface $stream
* @param $header
* @return int
*/
private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
{
$filename_header_length = 0;
if (substr(bin2hex($header), 6, 2) === '08') {
// we have a filename, read until nil
$filename_header_length = 1;
while ($stream->read(1) !== chr(0)) {
$filename_header_length++;
}
}
return $filename_header_length;
}
}

View File

@@ -98,6 +98,33 @@ class CachingStreamTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('ing', $this->body->read(3));
}
public function testCanSeekToReadBytesWithPartialBodyReturned()
{
$stream = fopen('php://temp', 'r+');
fwrite($stream, 'testing');
fseek($stream, 0);
$this->decorated = $this->getMockBuilder('\GuzzleHttp\Psr7\Stream')
->setConstructorArgs([$stream])
->setMethods(['read'])
->getMock();
$this->decorated->expects($this->exactly(2))
->method('read')
->willReturnCallback(function($length) use ($stream){
return fread($stream, 2);
});
$this->body = new CachingStream($this->decorated);
$this->assertEquals(0, $this->body->tell());
$this->body->seek(4, SEEK_SET);
$this->assertEquals(4, $this->body->tell());
$this->body->seek(0);
$this->assertEquals('test', $this->body->read(4));
}
public function testWritesToBufferStream()
{
$this->body->read(2);

View File

@@ -13,4 +13,27 @@ class InflateStreamtest extends \PHPUnit_Framework_TestCase
$b = new InflateStream($a);
$this->assertEquals('test', (string) $b);
}
public function testInflatesStreamsWithFilename()
{
$content = $this->getGzipStringWithFilename('test');
$a = Psr7\stream_for($content);
$b = new InflateStream($a);
$this->assertEquals('test', (string) $b);
}
private function getGzipStringWithFilename($original_string)
{
$gzipped = bin2hex(gzencode($original_string));
$header = substr($gzipped, 0, 20);
// set FNAME flag
$header[6]=0;
$header[7]=8;
// make a dummy filename
$filename = "64756d6d7900";
$rest = substr($gzipped, 20);
return hex2bin($header . $filename . $rest);
}
}

View File

@@ -154,7 +154,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
[self::RFC3986_BASE, 'g;x=1/../y', 'http://a/b/c/y'],
['http://u@a/b/c/d;p?q', '.', 'http://u@a/b/c/'],
['http://u:p@a/b/c/d;p?q', '.', 'http://u:p@a/b/c/'],
//[self::RFC3986_BASE, 'http:g', 'http:g'],
['http://a/b/c/d/', 'e', 'http://a/b/c/d/e'],
];
}

View File

@@ -1,4 +1,4 @@
Copyright (c) 2013-2015 Frank de Jonge
Copyright (c) 2013-2016 Frank de Jonge
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -18,10 +18,9 @@
},
"require-dev": {
"ext-fileinfo": "*",
"phpunit/phpunit": "~4.8",
"phpunit/phpunit": "~4.8 || ~5.0",
"mockery/mockery": "~0.9",
"phpspec/phpspec": "^2.2",
"phpspec/prophecy-phpunit": "~1.0"
"phpspec/phpspec": "^2.2"
},
"autoload": {
"psr-4": {

View File

@@ -305,8 +305,8 @@ class Ftp extends AbstractFtpAdapter
protected function createActualDirectory($directory, $connection)
{
// List the current directory
$listing = ftp_nlist($connection, '.');
$listing = ftp_nlist($connection, '.') ?: [];
foreach ($listing as $key => $item) {
if (preg_match('~^\./.*~', $item)) {
$listing[$key] = substr($item, 2);
@@ -337,7 +337,7 @@ class Ftp extends AbstractFtpAdapter
return ['type' => 'dir', 'path' => $path];
}
$listing = ftp_rawlist($connection, str_replace('*', '\\*', $path));
$listing = ftp_rawlist($connection, '-A ' . str_replace('*', '\\*', $path));
if (empty($listing)) {
return false;

View File

@@ -29,7 +29,7 @@ class NullAdapter extends AbstractAdapter
public function write($path, $contents, Config $config)
{
$type = 'file';
$result = compact('contents', 'type', 'size', 'path');
$result = compact('contents', 'type', 'path');
if ($visibility = $config->get('visibility')) {
$result['visibility'] = $visibility;

View File

@@ -31,11 +31,7 @@ class Util
*/
public static function normalizeDirname($dirname)
{
if ($dirname === '.') {
return '';
}
return $dirname;
return $dirname === '.' ? '' : $dirname;
}
/**
@@ -159,7 +155,7 @@ class Util
{
$mimeType = MimeType::detectByContent($content);
if (empty($mimeType) || in_array($mimeType, ['text/plain', 'application/x-empty'])) {
if (empty($mimeType) || in_array($mimeType, ['application/x-empty', 'text/plain', 'text/x-asm'])) {
$extension = pathinfo($path, PATHINFO_EXTENSION);
if ($extension) {

View File

@@ -22,10 +22,7 @@ class MimeType
return;
}
$finfo = new Finfo(FILEINFO_MIME_TYPE);
$mimeType = $finfo->buffer($content);
return $mimeType ?: null;
return (new Finfo(FILEINFO_MIME_TYPE))->buffer($content) ?: null;
}
/**
@@ -124,6 +121,7 @@ class MimeType
'bmp' => 'image/bmp',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'css' => 'text/css',
'html' => 'text/html',
'htm' => 'text/html',

View File

@@ -0,0 +1,36 @@
<?php
namespace League\Flysystem\Util;
class StreamHasher
{
/**
* @var string
*/
private $algo;
/**
* StreamHasher constructor.
*
* @param string $algo
*/
public function __construct($algo)
{
$this->algo = $algo;
}
/**
* @param $resource
*
* @return string
*/
public function hash($resource)
{
rewind($resource);
$context = hash_init($this->algo);
hash_update_stream($context, $resource);
fclose($resource);
return hash_final($context);
}
}

View File

@@ -1,3 +1,21 @@
1.6.0 / 2016-02-15
==================
* Add Variadics support (thanks @pamil)
* Add ProphecyComparator for comparing objects that need revealing (thanks @jon-acker)
* Add ApproximateValueToken (thanks @dantleech)
* Add support for 'self' and 'parent' return type (thanks @bendavies)
* Add __invoke to allowed reflectable methods list (thanks @ftrrtf)
* Updated ExportUtil to reflect the latest changes by Sebastian (thanks @jakari)
* Specify the required php version for composer (thanks @jakzal)
* Exclude 'args' in the generated backtrace (thanks @oradwell)
* Fix code generation for scalar parameters (thanks @trowski)
* Fix missing sprintf in InvalidArgumentException __construct call (thanks @emmanuelballery)
* Fix phpdoc for magic methods (thanks @Tobion)
* Fix PhpDoc for interfaces usage (thanks @ImmRanneft)
* Prevent final methods from being manually extended (thanks @kamioftea)
* Enhance exception for invalid argument to ThrowPromise (thanks @Tobion)
1.5.0 / 2015-04-27
==================

View File

@@ -2,7 +2,7 @@ Contributing
------------
Prophecy is an open source, community-driven project. If you'd like to contribute,
feel free to do this, but remember to follow this few simple rules:
feel free to do this, but remember to follow these few simple rules:
- Make your feature addition or bug fix,
- Add either specs or examples for any changes you're making (bugfixes or additions)
@@ -16,6 +16,6 @@ Running tests
Make sure that you don't break anything with your changes by running:
```bash
$> composer install --dev --prefer-dist
$> composer install --prefer-dist
$> vendor/bin/phpspec run
```

View File

@@ -1,5 +1,6 @@
# Prophecy
[![Stable release](https://poser.pugx.org/phpspec/prophecy/version.svg)](https://packagist.org/packages/phpspec/prophecy)
[![Build Status](https://travis-ci.org/phpspec/prophecy.svg?branch=master)](https://travis-ci.org/phpspec/prophecy)
Prophecy is a highly opinionated yet very powerful and flexible PHP object mocking

View File

@@ -17,9 +17,11 @@
}
],
"require": {
"php": "^5.3|^7.0",
"phpdocumentor/reflection-docblock": "~2.0",
"sebastian/comparator": "~1.1",
"doctrine/instantiator": "^1.0.2"
"doctrine/instantiator": "^1.0.2",
"sebastian/recursion-context": "~1.0"
},
"require-dev": {
@@ -34,7 +36,7 @@
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
"dev-master": "1.5.x-dev"
}
}
}

View File

@@ -4,7 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "642fa332c5fa99e1d5086035641b5a74",
"hash": "0cb11a8d8108277277f9931f6e4fa947",
"content-hash": "d2c6dc828e1217dfa154bc2dbb431edb",
"packages": [
{
"name": "doctrine/instantiator",
@@ -382,16 +383,16 @@
},
{
"name": "phpspec/phpspec",
"version": "2.2.1",
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/phpspec/phpspec.git",
"reference": "e9a40577323e67f1de2e214abf32976a0352d8f8"
"reference": "36635a903bdeb54899d7407bc95610501fd98559"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/phpspec/zipball/e9a40577323e67f1de2e214abf32976a0352d8f8",
"reference": "e9a40577323e67f1de2e214abf32976a0352d8f8",
"url": "https://api.github.com/repos/phpspec/phpspec/zipball/36635a903bdeb54899d7407bc95610501fd98559",
"reference": "36635a903bdeb54899d7407bc95610501fd98559",
"shasum": ""
},
"require": {
@@ -403,15 +404,14 @@
"symfony/console": "~2.3",
"symfony/event-dispatcher": "~2.1",
"symfony/finder": "~2.1",
"symfony/process": "~2.1",
"symfony/process": "^2.6",
"symfony/yaml": "~2.1"
},
"require-dev": {
"behat/behat": "^3.0.11",
"bossa/phpspec2-expect": "~1.0",
"phpunit/phpunit": "~4.4",
"symfony/filesystem": "~2.1",
"symfony/process": "~2.1"
"symfony/filesystem": "~2.1"
},
"suggest": {
"phpspec/nyan-formatters": "~1.0 Adds Nyan formatters"
@@ -456,20 +456,20 @@
"testing",
"tests"
],
"time": "2015-05-30 15:21:40"
"time": "2015-09-07 07:07:37"
},
{
"name": "symfony/console",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/Console.git",
"reference": "d6cf02fe73634c96677e428f840704bfbcaec29e"
"url": "https://github.com/symfony/console.git",
"reference": "5efd632294c8320ea52492db22292ff853a43766"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Console/zipball/d6cf02fe73634c96677e428f840704bfbcaec29e",
"reference": "d6cf02fe73634c96677e428f840704bfbcaec29e",
"url": "https://api.github.com/repos/symfony/console/zipball/5efd632294c8320ea52492db22292ff853a43766",
"reference": "5efd632294c8320ea52492db22292ff853a43766",
"shasum": ""
},
"require": {
@@ -478,7 +478,6 @@
"require-dev": {
"psr/log": "~1.0",
"symfony/event-dispatcher": "~2.1",
"symfony/phpunit-bridge": "~2.7",
"symfony/process": "~2.1"
},
"suggest": {
@@ -513,20 +512,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2015-07-28 15:18:12"
"time": "2015-10-20 14:38:46"
},
{
"name": "symfony/event-dispatcher",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/EventDispatcher.git",
"reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3"
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "87a5db5ea887763fa3a31a5471b512ff1596d9b8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/9310b5f9a87ec2ea75d20fec0b0017c77c66dac3",
"reference": "9310b5f9a87ec2ea75d20fec0b0017c77c66dac3",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/87a5db5ea887763fa3a31a5471b512ff1596d9b8",
"reference": "87a5db5ea887763fa3a31a5471b512ff1596d9b8",
"shasum": ""
},
"require": {
@@ -537,7 +536,6 @@
"symfony/config": "~2.0,>=2.0.5",
"symfony/dependency-injection": "~2.6",
"symfony/expression-language": "~2.6",
"symfony/phpunit-bridge": "~2.7",
"symfony/stopwatch": "~2.3"
},
"suggest": {
@@ -571,28 +569,25 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2015-06-18 19:21:56"
"time": "2015-10-11 09:39:48"
},
{
"name": "symfony/finder",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/Finder.git",
"reference": "ae0f363277485094edc04c9f3cbe595b183b78e4"
"url": "https://github.com/symfony/finder.git",
"reference": "2ffb4e9598db3c48eb6d0ae73b04bbf09280c59d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Finder/zipball/ae0f363277485094edc04c9f3cbe595b183b78e4",
"reference": "ae0f363277485094edc04c9f3cbe595b183b78e4",
"url": "https://api.github.com/repos/symfony/finder/zipball/2ffb4e9598db3c48eb6d0ae73b04bbf09280c59d",
"reference": "2ffb4e9598db3c48eb6d0ae73b04bbf09280c59d",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
@@ -620,28 +615,25 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2015-07-09 16:07:40"
"time": "2015-10-11 09:39:48"
},
{
"name": "symfony/process",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/Process.git",
"reference": "48aeb0e48600321c272955132d7606ab0a49adb3"
"url": "https://github.com/symfony/process.git",
"reference": "4a959dd4e19c2c5d7512689413921e0a74386ec7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Process/zipball/48aeb0e48600321c272955132d7606ab0a49adb3",
"reference": "48aeb0e48600321c272955132d7606ab0a49adb3",
"url": "https://api.github.com/repos/symfony/process/zipball/4a959dd4e19c2c5d7512689413921e0a74386ec7",
"reference": "4a959dd4e19c2c5d7512689413921e0a74386ec7",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
@@ -669,28 +661,25 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2015-07-01 11:25:50"
"time": "2015-10-23 14:47:27"
},
{
"name": "symfony/yaml",
"version": "v2.7.3",
"version": "v2.7.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
"reference": "71340e996171474a53f3d29111d046be4ad8a0ff"
"url": "https://github.com/symfony/yaml.git",
"reference": "eca9019c88fbe250164affd107bc8057771f3f4d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/71340e996171474a53f3d29111d046be4ad8a0ff",
"reference": "71340e996171474a53f3d29111d046be4ad8a0ff",
"url": "https://api.github.com/repos/symfony/yaml/zipball/eca9019c88fbe250164affd107bc8057771f3f4d",
"reference": "eca9019c88fbe250164affd107bc8057771f3f4d",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
@@ -718,7 +707,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2015-07-28 14:07:07"
"time": "2015-10-11 09:39:48"
}
],
"aliases": [],

View File

@@ -0,0 +1,55 @@
<?php
namespace spec\Prophecy\Argument\Token;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class ApproximateValueTokenSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith(10.12345678, 4);
}
function it_is_initializable()
{
$this->shouldHaveType('Prophecy\Argument\Token\ApproximateValueToken');
}
function it_implements_TokenInterface()
{
$this->shouldBeAnInstanceOf('Prophecy\Argument\Token\TokenInterface');
}
function it_is_not_last()
{
$this->shouldNotBeLast();
}
function it_scores_10_if_rounded_argument_matches_rounded_value()
{
$this->scoreArgument(10.12345)->shouldReturn(10);
}
function it_does_not_score_if_rounded_argument_does_not_match_rounded_value()
{
$this->scoreArgument(10.1234)->shouldReturn(false);
}
function it_uses_a_default_precision_of_zero()
{
$this->beConstructedWith(10.7);
$this->scoreArgument(11.4)->shouldReturn(10);
}
function it_does_not_score_if_rounded_argument_is_not_numeric()
{
$this->scoreArgument('hello')->shouldReturn(false);
}
function it_has_simple_string_representation()
{
$this->__toString()->shouldBe('≅10.1235');
}
}

View File

@@ -98,4 +98,10 @@ class ArgumentSpec extends ObjectBehavior
$token = $this->containingString('string');
$token->shouldBeAnInstanceOf('Prophecy\Argument\Token\StringContainsToken');
}
function it_has_a_shortcut_for_approximate_token()
{
$token = $this->approximate(10);
$token->shouldBeAnInstanceOf('Prophecy\Argument\Token\ApproximateValueToken');
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace spec\Prophecy\Comparator;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Prophecy\Prophet;
class ProphecyComparatorSpec extends ObjectBehavior
{
function it_is_a_comparator()
{
$this->shouldHaveType('SebastianBergmann\Comparator\ObjectComparator');
}
function it_accepts_only_prophecy_objects()
{
$this->accepts(123, 321)->shouldReturn(false);
$this->accepts('string', 'string')->shouldReturn(false);
$this->accepts(false, true)->shouldReturn(false);
$this->accepts(true, false)->shouldReturn(false);
$this->accepts((object)array(), (object)array())->shouldReturn(false);
$this->accepts(function(){}, (object)array())->shouldReturn(false);
$this->accepts(function(){}, function(){})->shouldReturn(false);
$prophet = new Prophet();
$prophecy = $prophet->prophesize('Prophecy\Prophecy\ObjectProphecy');
$this->accepts($prophecy, $prophecy)->shouldReturn(true);
}
function it_asserts_that_an_object_is_equal_to_its_revealed_prophecy()
{
$prophet = new Prophet();
$prophecy = $prophet->prophesize('Prophecy\Prophecy\ObjectProphecy');
$this->shouldNotThrow()->duringAssertEquals($prophecy->reveal(), $prophecy);
}
}

View File

@@ -46,6 +46,19 @@ class MagicCallPatchSpec extends ObjectBehavior
$this->apply($node);
}
/**
* @param \Prophecy\Doubler\Generator\Node\ClassNode $node
*/
function it_discovers_api_using_phpdoc_from_interface($node)
{
$node->getParentClass()->willReturn('spec\Prophecy\Doubler\ClassPatch\MagicalApiImplemented');
$node->addMethod(new MethodNode('implementedMethod'))->shouldBeCalled();
$this->apply($node);
}
function it_has_50_priority()
{
$this->getPriority()->shouldReturn(50);
@@ -73,4 +86,19 @@ class MagicalApi
class MagicalApiExtended extends MagicalApi
{
}
}
/**
*/
class MagicalApiImplemented implements MagicalApiInterface
{
}
/**
* @method void implementedMethod()
*/
interface MagicalApiInterface
{
}

View File

@@ -57,26 +57,32 @@ class ClassCodeGeneratorSpec extends ObjectBehavior
$argument11->isOptional()->willReturn(true);
$argument11->getDefault()->willReturn(null);
$argument11->isPassedByReference()->willReturn(false);
$argument11->isVariadic()->willReturn(false);
$argument12->getName()->willReturn('class');
$argument12->getTypeHint()->willReturn('ReflectionClass');
$argument12->isOptional()->willReturn(false);
$argument12->isPassedByReference()->willReturn(false);
$argument12->isVariadic()->willReturn(false);
$argument21->getName()->willReturn('default');
$argument21->getTypeHint()->willReturn(null);
$argument21->getTypeHint()->willReturn('string');
$argument21->isOptional()->willReturn(true);
$argument21->getDefault()->willReturn('ever.zet@gmail.com');
$argument21->isPassedByReference()->willReturn(false);
$argument21->isVariadic()->willReturn(false);
$argument31->getName()->willReturn('refValue');
$argument31->getTypeHint()->willReturn(null);
$argument31->isOptional()->willReturn(false);
$argument31->getDefault()->willReturn();
$argument31->isPassedByReference()->willReturn(false);
$argument31->isVariadic()->willReturn(false);
$code = $this->generate('CustomClass', $class);
$expected = <<<'PHP'
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$expected = <<<'PHP'
namespace {
class CustomClass extends \RuntimeException implements \Prophecy\Doubler\Generator\MirroredInterface, \ArrayAccess, \ArrayIterator {
public $name;
@@ -85,13 +91,138 @@ private $email;
public static function getName(array $fullname = NULL, \ReflectionClass $class): string {
return $this->name;
}
protected function getEmail( $default = 'ever.zet@gmail.com') {
protected function getEmail(string $default = 'ever.zet@gmail.com') {
return $this->email;
}
public function &getRefValue( $refValue) {
return $this->refValue;
}
}
}
PHP;
} else {
$expected = <<<'PHP'
namespace {
class CustomClass extends \RuntimeException implements \Prophecy\Doubler\Generator\MirroredInterface, \ArrayAccess, \ArrayIterator {
public $name;
private $email;
public static function getName(array $fullname = NULL, \ReflectionClass $class) {
return $this->name;
}
protected function getEmail(\string $default = 'ever.zet@gmail.com') {
return $this->email;
}
public function &getRefValue( $refValue) {
return $this->refValue;
}
}
}
PHP;
}
$expected = strtr($expected, array("\r\n" => "\n", "\r" => "\n"));
$code->shouldBe($expected);
}
/**
* @param \Prophecy\Doubler\Generator\Node\ClassNode $class
* @param \Prophecy\Doubler\Generator\Node\MethodNode $method1
* @param \Prophecy\Doubler\Generator\Node\MethodNode $method2
* @param \Prophecy\Doubler\Generator\Node\MethodNode $method3
* @param \Prophecy\Doubler\Generator\Node\MethodNode $method4
* @param \Prophecy\Doubler\Generator\Node\ArgumentNode $argument1
* @param \Prophecy\Doubler\Generator\Node\ArgumentNode $argument2
* @param \Prophecy\Doubler\Generator\Node\ArgumentNode $argument3
* @param \Prophecy\Doubler\Generator\Node\ArgumentNode $argument4
*/
function it_generates_proper_php_code_for_variadics(
$class, $method1, $method2, $method3, $method4, $argument1, $argument2,
$argument3, $argument4
)
{
$class->getParentClass()->willReturn('stdClass');
$class->getInterfaces()->willReturn(array('Prophecy\Doubler\Generator\MirroredInterface'));
$class->getProperties()->willReturn(array());
$class->getMethods()->willReturn(array(
$method1, $method2, $method3, $method4
));
$method1->getName()->willReturn('variadic');
$method1->getVisibility()->willReturn('public');
$method1->returnsReference()->willReturn(false);
$method1->isStatic()->willReturn(false);
$method1->getArguments()->willReturn(array($argument1));
$method1->hasReturnType()->willReturn(false);
$method1->getCode()->willReturn('');
$method2->getName()->willReturn('variadicByRef');
$method2->getVisibility()->willReturn('public');
$method2->returnsReference()->willReturn(false);
$method2->isStatic()->willReturn(false);
$method2->getArguments()->willReturn(array($argument2));
$method2->hasReturnType()->willReturn(false);
$method2->getCode()->willReturn('');
$method3->getName()->willReturn('variadicWithType');
$method3->getVisibility()->willReturn('public');
$method3->returnsReference()->willReturn(false);
$method3->isStatic()->willReturn(false);
$method3->getArguments()->willReturn(array($argument3));
$method3->hasReturnType()->willReturn(false);
$method3->getCode()->willReturn('');
$method4->getName()->willReturn('variadicWithTypeByRef');
$method4->getVisibility()->willReturn('public');
$method4->returnsReference()->willReturn(false);
$method4->isStatic()->willReturn(false);
$method4->getArguments()->willReturn(array($argument4));
$method4->hasReturnType()->willReturn(false);
$method4->getCode()->willReturn('');
$argument1->getName()->willReturn('args');
$argument1->getTypeHint()->willReturn(null);
$argument1->isOptional()->willReturn(false);
$argument1->isPassedByReference()->willReturn(false);
$argument1->isVariadic()->willReturn(true);
$argument2->getName()->willReturn('args');
$argument2->getTypeHint()->willReturn(null);
$argument2->isOptional()->willReturn(false);
$argument2->isPassedByReference()->willReturn(true);
$argument2->isVariadic()->willReturn(true);
$argument3->getName()->willReturn('args');
$argument3->getTypeHint()->willReturn('\ReflectionClass');
$argument3->isOptional()->willReturn(false);
$argument3->isPassedByReference()->willReturn(false);
$argument3->isVariadic()->willReturn(true);
$argument4->getName()->willReturn('args');
$argument4->getTypeHint()->willReturn('\ReflectionClass');
$argument4->isOptional()->willReturn(false);
$argument4->isPassedByReference()->willReturn(true);
$argument4->isVariadic()->willReturn(true);
$code = $this->generate('CustomClass', $class);
$expected = <<<'PHP'
namespace {
class CustomClass extends \stdClass implements \Prophecy\Doubler\Generator\MirroredInterface {
public function variadic( ...$args) {
}
public function variadicByRef( &...$args) {
}
public function variadicWithType(\\ReflectionClass ...$args) {
}
public function variadicWithTypeByRef(\\ReflectionClass &...$args) {
}
}
}
PHP;
@@ -126,6 +257,7 @@ PHP;
$argument->isOptional()->willReturn(true);
$argument->getDefault()->willReturn(null);
$argument->isPassedByReference()->willReturn(true);
$argument->isVariadic()->willReturn(false);
$code = $this->generate('CustomClass', $class);
$expected =<<<'PHP'

View File

@@ -2,9 +2,8 @@
namespace spec\Prophecy\Doubler\Generator;
use PhpSpec\ObjectBehavior;
use I\Simply;
use PhpSpec\ObjectBehavior;
use ReflectionClass;
use ReflectionMethod;
use ReflectionParameter;
@@ -13,15 +12,17 @@ class ClassMirrorSpec extends ObjectBehavior
{
/**
* @param ReflectionClass $class
* @param ReflectionClass $parent
* @param ReflectionMethod $method1
* @param ReflectionMethod $method2
* @param ReflectionMethod $method3
*/
function it_reflects_a_class_by_mirroring_all_its_public_methods(
$class, $method1, $method2, $method3
$class, $parent, $method1, $method2, $method3
)
{
$class->getName()->willReturn('Custom\ClassName');
$class->getParentClass()->willReturn($parent);
$class->isInterface()->willReturn(false);
$class->isFinal()->willReturn(false);
$class->getMethods(ReflectionMethod::IS_ABSTRACT)->willReturn(array());
@@ -29,9 +30,15 @@ class ClassMirrorSpec extends ObjectBehavior
$method1, $method2, $method3
));
$parent->getName()->willReturn('Custom\ParentClassName');
$method1->getDeclaringClass()->willReturn($class);
$method2->getDeclaringClass()->willReturn($class);
$method3->getDeclaringClass()->willReturn($class);
$method1->getName()->willReturn('getName');
$method2->getName()->willReturn('isPublic');
$method3->getName()->willReturn('isAbstract');
$method2->getName()->willReturn('getSelf');
$method3->getName()->willReturn('getParent');
$method1->isFinal()->willReturn(false);
$method2->isFinal()->willReturn(false);
@@ -54,9 +61,12 @@ class ClassMirrorSpec extends ObjectBehavior
$method3->getParameters()->willReturn(array());
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$method1->hasReturnType()->willReturn(false);
$method2->hasReturnType()->willReturn(false);
$method3->hasReturnType()->willReturn(false);
$method1->hasReturnType()->willReturn(true);
$method1->getReturnType()->willReturn('string');
$method2->hasReturnType()->willReturn(true);
$method2->getReturnType()->willReturn('self');
$method3->hasReturnType()->willReturn(true);
$method3->getReturnType()->willReturn('parent');
}
$classNode = $this->reflect($class, array());
@@ -67,8 +77,14 @@ class ClassMirrorSpec extends ObjectBehavior
$methodNodes->shouldHaveCount(3);
$classNode->hasMethod('getName')->shouldReturn(true);
$classNode->hasMethod('isPublic')->shouldReturn(true);
$classNode->hasMethod('isAbstract')->shouldReturn(true);
$classNode->hasMethod('getSelf')->shouldReturn(true);
$classNode->hasMethod('getParent')->shouldReturn(true);
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$classNode->getMethod('getName')->getReturnType()->shouldReturn('string');
$classNode->getMethod('getSelf')->getReturnType()->shouldReturn('\Custom\ClassName');
$classNode->getMethod('getParent')->getReturnType()->shouldReturn('\Custom\ParentClassName');
}
}
/**
@@ -101,6 +117,9 @@ class ClassMirrorSpec extends ObjectBehavior
$parameter->getDefaultValue()->willReturn(null);
$parameter->isPassedByReference()->willReturn(false);
$parameter->getClass()->willReturn($class);
if (version_compare(PHP_VERSION, '5.6', '>=')) {
$parameter->isVariadic()->willReturn(false);
}
$classNode = $this->reflect($class, array());
@@ -177,6 +196,92 @@ class ClassMirrorSpec extends ObjectBehavior
$methodNodes['innerDetail']->isStatic()->shouldReturn(true);
}
/**
* @param ReflectionClass $class
* @param ReflectionMethod $constructMethod
* @param ReflectionMethod $destructMethod
* @param ReflectionMethod $sleepMethod
* @param ReflectionMethod $wakeupMethod
* @param ReflectionMethod $toStringMethod
* @param ReflectionMethod $callMethod
* @param ReflectionMethod $invokeMethod
*/
function it_reflects_allowed_magic_methods($class, $constructMethod, $destructMethod, $sleepMethod, $wakeupMethod, $toStringMethod, $callMethod, $invokeMethod)
{
$class->getName()->willReturn('Custom\ClassName');
$class->isInterface()->willReturn(false);
$class->isFinal()->willReturn(false);
$class->getMethods(ReflectionMethod::IS_ABSTRACT)->willReturn(array());
$class->getMethods(ReflectionMethod::IS_PUBLIC)->willReturn(array(
$constructMethod, $destructMethod, $sleepMethod, $wakeupMethod, $toStringMethod, $callMethod, $invokeMethod
));
$constructMethod->getName()->willReturn('__construct');
$destructMethod->getName()->willReturn('__destruct');
$sleepMethod->getName()->willReturn('__sleep');
$wakeupMethod->getName()->willReturn('__wakeup');
$toStringMethod->getName()->willReturn('__toString');
$callMethod->getName()->willReturn('__call');
$invokeMethod->getName()->willReturn('__invoke');
$constructMethod->isFinal()->willReturn(false);
$destructMethod->isFinal()->willReturn(false);
$sleepMethod->isFinal()->willReturn(false);
$wakeupMethod->isFinal()->willReturn(false);
$toStringMethod->isFinal()->willReturn(false);
$callMethod->isFinal()->willReturn(false);
$invokeMethod->isFinal()->willReturn(false);
$constructMethod->isProtected()->willReturn(false);
$destructMethod->isProtected()->willReturn(false);
$sleepMethod->isProtected()->willReturn(false);
$wakeupMethod->isProtected()->willReturn(false);
$toStringMethod->isProtected()->willReturn(false);
$callMethod->isProtected()->willReturn(false);
$invokeMethod->isProtected()->willReturn(false);
$constructMethod->isStatic()->willReturn(false);
$destructMethod->isStatic()->willReturn(false);
$sleepMethod->isStatic()->willReturn(false);
$wakeupMethod->isStatic()->willReturn(false);
$toStringMethod->isStatic()->willReturn(false);
$callMethod->isStatic()->willReturn(false);
$invokeMethod->isStatic()->willReturn(false);
$constructMethod->returnsReference()->willReturn(false);
$destructMethod->returnsReference()->willReturn(false);
$sleepMethod->returnsReference()->willReturn(false);
$wakeupMethod->returnsReference()->willReturn(false);
$toStringMethod->returnsReference()->willReturn(false);
$callMethod->returnsReference()->willReturn(false);
$invokeMethod->returnsReference()->willReturn(false);
$constructMethod->getParameters()->willReturn(array());
$destructMethod->getParameters()->willReturn(array());
$sleepMethod->getParameters()->willReturn(array());
$wakeupMethod->getParameters()->willReturn(array());
$toStringMethod->getParameters()->willReturn(array());
$callMethod->getParameters()->willReturn(array());
$invokeMethod->getParameters()->willReturn(array());
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$constructMethod->hasReturnType()->willReturn(false);
$destructMethod->hasReturnType()->willReturn(false);
$sleepMethod->hasReturnType()->willReturn(false);
$wakeupMethod->hasReturnType()->willReturn(false);
$toStringMethod->hasReturnType()->willReturn(false);
$callMethod->hasReturnType()->willReturn(false);
$invokeMethod->hasReturnType()->willReturn(false);
}
$classNode = $this->reflect($class, array());
$classNode->shouldBeAnInstanceOf('Prophecy\Doubler\Generator\Node\ClassNode');
$classNode->getParentClass()->shouldReturn('Custom\ClassName');
$methodNodes = $classNode->getMethods();
$methodNodes->shouldHaveCount(7);
}
/**
* @param ReflectionClass $class
* @param ReflectionMethod $method
@@ -184,9 +289,10 @@ class ClassMirrorSpec extends ObjectBehavior
* @param ReflectionParameter $param2
* @param ReflectionClass $typeHint
* @param ReflectionParameter $param3
* @param ReflectionParameter $param4
*/
function it_properly_reads_methods_arguments_with_types(
$class, $method, $param1, $param2, $typeHint, $param3
$class, $method, $param1, $param2, $typeHint, $param3, $param4
)
{
$class->getName()->willReturn('Custom\ClassName');
@@ -200,7 +306,7 @@ class ClassMirrorSpec extends ObjectBehavior
$method->isProtected()->willReturn(true);
$method->isStatic()->willReturn(false);
$method->returnsReference()->willReturn(false);
$method->getParameters()->willReturn(array($param1, $param2, $param3));
$method->getParameters()->willReturn(array($param1, $param2, $param3, $param4));
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$method->hasReturnType()->willReturn(false);
@@ -234,6 +340,22 @@ class ClassMirrorSpec extends ObjectBehavior
$param3->isPassedByReference()->willReturn(false);
$param3->allowsNull()->willReturn(true);
$param4->getName()->willReturn('arg_4');
$param4->isArray()->willReturn(false);
$param4->getClass()->willReturn($typeHint);
$param4->isPassedByReference()->willReturn(false);
$param4->allowsNull()->willReturn(true);
if (version_compare(PHP_VERSION, '5.6', '>=')) {
$param1->isVariadic()->willReturn(false);
$param2->isVariadic()->willReturn(false);
$param3->isVariadic()->willReturn(false);
$param4->isVariadic()->willReturn(true);
} else {
$param4->isOptional()->willReturn(true);
$param4->isDefaultValueAvailable()->willReturn(false);
}
$classNode = $this->reflect($class, array());
$methodNodes = $classNode->getMethods();
$argNodes = $methodNodes['methodWithArgs']->getArguments();
@@ -255,6 +377,15 @@ class ClassMirrorSpec extends ObjectBehavior
} else {
$argNodes[2]->isOptional()->shouldReturn(false);
}
$argNodes[3]->getName()->shouldReturn('arg_4');
$argNodes[3]->getTypeHint()->shouldReturn('ArrayAccess');
if (version_compare(PHP_VERSION, '5.6', '>=')) {
$argNodes[3]->isVariadic()->shouldReturn(true);
} else {
$argNodes[3]->isOptional()->shouldReturn(true);
$argNodes[3]->getDefault()->shouldReturn(null);
}
}
/**
@@ -294,6 +425,9 @@ class ClassMirrorSpec extends ObjectBehavior
$param1->hasType()->willReturn(false);
}
if (version_compare(PHP_VERSION, '5.6', '>=')) {
$param1->isVariadic()->willReturn(false);
}
$param1->isDefaultValueAvailable()->willReturn(false);
$param1->isOptional()->willReturn(false);
$param1->isPassedByReference()->willReturn(false);
@@ -314,10 +448,11 @@ class ClassMirrorSpec extends ObjectBehavior
* @param ReflectionMethod $method
* @param ReflectionParameter $param1
* @param ReflectionParameter $param2
* @param ReflectionParameter $param3
* @param ReflectionClass $typeHint
*/
function it_marks_passed_by_reference_args_as_passed_by_reference(
$class, $method, $param1, $param2, $typeHint
$class, $method, $param1, $param2, $param3, $typeHint
)
{
$class->getName()->willReturn('Custom\ClassName');
@@ -331,7 +466,7 @@ class ClassMirrorSpec extends ObjectBehavior
$method->isProtected()->willReturn(false);
$method->isStatic()->willReturn(false);
$method->returnsReference()->willReturn(false);
$method->getParameters()->willReturn(array($param1, $param2));
$method->getParameters()->willReturn(array($param1, $param2, $param3));
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$method->hasReturnType()->willReturn(false);
@@ -343,6 +478,9 @@ class ClassMirrorSpec extends ObjectBehavior
$param1->isCallable()->willReturn(false);
}
$param1->getClass()->willReturn(null);
if (version_compare(PHP_VERSION, '5.6', '>=')) {
$param1->isVariadic()->willReturn(false);
}
$param1->isDefaultValueAvailable()->willReturn(false);
$param1->isOptional()->willReturn(true);
$param1->isPassedByReference()->willReturn(true);
@@ -359,6 +497,9 @@ class ClassMirrorSpec extends ObjectBehavior
$param2->getName()->willReturn('arg2');
$param2->isArray()->willReturn(false);
$param2->getClass()->willReturn($typeHint);
if (version_compare(PHP_VERSION, '5.6', '>=')) {
$param2->isVariadic()->willReturn(false);
}
$param2->isDefaultValueAvailable()->willReturn(false);
$param2->isOptional()->willReturn(false);
$param2->isPassedByReference()->willReturn(false);
@@ -370,12 +511,25 @@ class ClassMirrorSpec extends ObjectBehavior
$param2->allowsNull()->willReturn(false);
$typeHint->getName()->willReturn('ArrayAccess');
$param3->getName()->willReturn('arg2');
$param3->isArray()->willReturn(false);
$param3->getClass()->willReturn($typeHint);
if (version_compare(PHP_VERSION, '5.6', '>=')) {
$param3->isVariadic()->willReturn(true);
} else {
$param3->isOptional()->willReturn(true);
$param3->isDefaultValueAvailable()->willReturn(false);
}
$param3->isPassedByReference()->willReturn(true);
$param3->allowsNull()->willReturn(true);
$classNode = $this->reflect($class, array());
$methodNodes = $classNode->getMethods();
$argNodes = $methodNodes['methodWithArgs']->getArguments();
$argNodes[0]->isPassedByReference()->shouldReturn(true);
$argNodes[1]->isPassedByReference()->shouldReturn(false);
$argNodes[2]->isPassedByReference()->shouldReturn(true);
}
/**
@@ -410,6 +564,26 @@ class ClassMirrorSpec extends ObjectBehavior
$classNode->getMethods()->shouldHaveCount(0);
}
/**
* @param ReflectionClass $class
* @param ReflectionMethod $method
*/
function it_marks_final_methods_as_unextendable($class, $method)
{
$class->getName()->willReturn('Custom\ClassName');
$class->isInterface()->willReturn(false);
$class->isFinal()->willReturn(false);
$class->getMethods(ReflectionMethod::IS_ABSTRACT)->willReturn(array());
$class->getMethods(ReflectionMethod::IS_PUBLIC)->willReturn(array($method));
$method->isFinal()->willReturn(true);
$method->getName()->willReturn('finalImplementation');
$classNode = $this->reflect($class, array());
$classNode->getUnextendableMethods()->shouldHaveCount(1);
$classNode->isExtendable('finalImplementation')->shouldReturn(false);
}
/**
* @param ReflectionClass $interface
*/

View File

@@ -22,6 +22,36 @@ class ArgumentNodeSpec extends ObjectBehavior
$this->shouldBePassedByReference();
}
function it_is_not_variadic_by_default()
{
$this->shouldNotBeVariadic();
}
function it_is_variadic_if_marked()
{
$this->setAsVariadic();
$this->shouldBeVariadic();
}
function it_does_not_have_default_by_default()
{
$this->shouldNotHaveDefault();
}
function it_does_not_have_default_if_variadic()
{
$this->setDefault(null);
$this->setAsVariadic();
$this->shouldNotHaveDefault();
}
function it_does_have_default_if_not_variadic()
{
$this->setDefault(null);
$this->setAsVariadic(false);
$this->hasDefault()->shouldReturn(true);
}
function it_has_name_with_which_it_was_been_constructed()
{
$this->getName()->shouldReturn('name');

View File

@@ -3,6 +3,7 @@
namespace spec\Prophecy\Doubler\Generator\Node;
use PhpSpec\ObjectBehavior;
use Prophecy\Exception\Doubler\MethodNotExtendableException;
class ClassNodeSpec extends ObjectBehavior
{
@@ -151,4 +152,49 @@ class ClassNodeSpec extends ObjectBehavior
$this->addProperty('text', 'PRIVATE');
$this->getProperties()->shouldReturn(array('text' => 'private'));
}
function its_has_no_unextendable_methods_by_default()
{
$this->getUnextendableMethods()->shouldHaveCount(0);
}
function its_addUnextendableMethods_adds_an_unextendable_method()
{
$this->addUnextendableMethod('testMethod');
$this->getUnextendableMethods()->shouldHaveCount(1);
}
function its_methods_are_extendable_by_default()
{
$this->isExtendable('testMethod')->shouldReturn(true);
}
function its_unextendable_methods_are_not_extendable()
{
$this->addUnextendableMethod('testMethod');
$this->isExtendable('testMethod')->shouldReturn(false);
}
function its_addUnextendableMethods_doesnt_create_duplicates()
{
$this->addUnextendableMethod('testMethod');
$this->addUnextendableMethod('testMethod');
$this->getUnextendableMethods()->shouldHaveCount(1);
}
/**
* @param \Prophecy\Doubler\Generator\Node\MethodNode $method
*/
function it_throws_an_exception_when_adding_a_method_that_isnt_extendable($method)
{
$this->addUnextendableMethod('testMethod');
$method->getName()->willReturn('testMethod');
$expectedException = new MethodNotExtendableException(
"Method `testMethod` is not extendable, so can not be added.",
"stdClass",
"testMethod"
);
$this->shouldThrow($expectedException)->duringAddMethod($method);
}
}

View File

@@ -69,13 +69,16 @@ class MethodNodeSpec extends ObjectBehavior
$argument1->getName()->willReturn('objectName');
$argument2->getName()->willReturn('default');
$argument1->isVariadic()->willReturn(false);
$argument2->isVariadic()->willReturn(true);
$this->addArgument($argument1);
$this->addArgument($argument2);
$this->useParentCode();
$this->getCode()->shouldReturn(
'return parent::getTitle($objectName, $default);'
'return parent::getTitle($objectName, ...$default);'
);
}

View File

@@ -0,0 +1,29 @@
<?php
namespace spec\Prophecy\Exception\Doubler;
use PhpSpec\ObjectBehavior;
use spec\Prophecy\Exception\Prophecy;
class MethodNotExtendableExceptionSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('', 'User', 'getName');
}
function it_is_DoubleException()
{
$this->shouldHaveType('Prophecy\Exception\Doubler\DoubleException');
}
function it_has_MethodName()
{
$this->getMethodName()->shouldReturn('getName');
}
function it_has_classname()
{
$this->getClassName()->shouldReturn('User');
}
}

View File

@@ -195,4 +195,18 @@ class Argument
{
return new Token\IdenticalValueToken($value);
}
/**
* Check that argument is same value when rounding to the
* given precision.
*
* @param float $value
* @param float $precision
*
* @return Token\ApproximateValueToken
*/
public static function approximate($value, $precision = 0)
{
return new Token\ApproximateValueToken($value, $precision);
}
}

View File

@@ -0,0 +1,55 @@
<?php
/*
* This file is part of the Prophecy.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
* Marcello Duarte <marcello.duarte@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Prophecy\Argument\Token;
/**
* Approximate value token
*
* @author Daniel Leech <daniel@dantleech.com>
*/
class ApproximateValueToken implements TokenInterface
{
private $value;
private $precision;
public function __construct($value, $precision = 0)
{
$this->value = $value;
$this->precision = $precision;
}
/**
* {@inheritdoc}
*/
public function scoreArgument($argument)
{
return round($argument, $this->precision) === round($this->value, $this->precision) ? 10 : false;
}
/**
* {@inheritdoc}
*/
public function isLast()
{
return false;
}
/**
* Returns string representation for token.
*
* @return string
*/
public function __toString()
{
return sprintf('≅%s', round($this->value, $this->precision));
}
}

View File

@@ -54,7 +54,17 @@ class CallCenter
*/
public function makeCall(ObjectProphecy $prophecy, $methodName, array $arguments)
{
$backtrace = debug_backtrace();
// For efficiency exclude 'args' from the generated backtrace
if (PHP_VERSION_ID >= 50400) {
// Limit backtrace to last 3 calls as we don't use the rest
// Limit argument was introduced in PHP 5.4.0
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
} elseif (defined('DEBUG_BACKTRACE_IGNORE_ARGS')) {
// DEBUG_BACKTRACE_IGNORE_ARGS was introduced in PHP 5.3.6
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
} else {
$backtrace = debug_backtrace();
}
$file = $line = null;
if (isset($backtrace[2]) && isset($backtrace[2]['file'])) {

View File

@@ -30,6 +30,7 @@ final class Factory extends BaseFactory
parent::__construct();
$this->register(new ClosureComparator());
$this->register(new ProphecyComparator());
}
/**

View File

@@ -0,0 +1,28 @@
<?php
/*
* This file is part of the Prophecy.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
* Marcello Duarte <marcello.duarte@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Prophecy\Comparator;
use Prophecy\Prophecy\ProphecyInterface;
use SebastianBergmann\Comparator\ObjectComparator;
class ProphecyComparator extends ObjectComparator
{
public function accepts($expected, $actual)
{
return is_object($expected) && is_object($actual) && $actual instanceof ProphecyInterface;
}
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array())
{
parent::assertEquals($expected, $actual->reveal(), $delta, $canonicalize, $ignoreCase, $processed);
}
}

View File

@@ -48,6 +48,12 @@ class MagicCallPatch implements ClassPatchInterface
$tagList = $phpdoc->getTagsByName('method');
$interfaces = $reflectionClass->getInterfaces();
foreach($interfaces as $interface) {
$phpdoc = new DocBlock($interface);
$tagList = array_merge($tagList, $phpdoc->getTagsByName('method'));
}
foreach($tagList as $tag) {
$methodName = $tag->getMethodName();

View File

@@ -60,7 +60,9 @@ class ClassCodeGenerator
$method->returnsReference() ? '&':'',
$method->getName(),
implode(', ', $this->generateArguments($method->getArguments())),
$method->hasReturnType() ? sprintf(': %s', $method->getReturnType()) : ''
version_compare(PHP_VERSION, '7.0', '>=') && $method->hasReturnType()
? sprintf(': %s', $method->getReturnType())
: ''
);
$php .= $method->getCode()."\n";
@@ -73,16 +75,34 @@ class ClassCodeGenerator
$php = '';
if ($hint = $argument->getTypeHint()) {
if ('array' === $hint || 'callable' === $hint) {
$php .= $hint;
} else {
$php .= '\\'.$hint;
switch ($hint) {
case 'array':
case 'callable':
$php .= $hint;
break;
case 'string':
case 'int':
case 'float':
case 'bool':
if (version_compare(PHP_VERSION, '7.0', '>=')) {
$php .= $hint;
break;
}
// Fall-through to default case for PHP 5.x
default:
$php .= '\\'.$hint;
}
}
$php .= ' '.($argument->isPassedByReference() ? '&' : '').'$'.$argument->getName();
$php .= ' '.($argument->isPassedByReference() ? '&' : '');
if ($argument->isOptional()) {
$php .= $argument->isVariadic() ? '...' : '';
$php .= '$'.$argument->getName();
if ($argument->isOptional() && !$argument->isVariadic()) {
$php .= ' = '.var_export($argument->getDefault(), true);
}

View File

@@ -32,6 +32,7 @@ class ClassMirror
'__wakeup',
'__toString',
'__call',
'__invoke'
);
/**
@@ -109,6 +110,7 @@ class ClassMirror
}
if (true === $method->isFinal()) {
$node->addUnextendableMethod($method->getName());
continue;
}
@@ -142,7 +144,17 @@ class ClassMirror
}
if (version_compare(PHP_VERSION, '7.0', '>=') && true === $method->hasReturnType()) {
$node->setReturnType((string) $method->getReturnType());
$returnType = (string) $method->getReturnType();
$returnTypeLower = strtolower($returnType);
if ('self' === $returnTypeLower) {
$returnType = $method->getDeclaringClass()->getName();
}
if ('parent' === $returnTypeLower) {
$returnType = $method->getDeclaringClass()->getParentClass()->getName();
}
$node->setReturnType($returnType);
}
if (is_array($params = $method->getParameters()) && count($params)) {
@@ -159,23 +171,45 @@ class ClassMirror
$name = $parameter->getName() == '...' ? '__dot_dot_dot__' : $parameter->getName();
$node = new Node\ArgumentNode($name);
$typeHint = $this->getTypeHint($parameter);
$node->setTypeHint($typeHint);
$node->setTypeHint($this->getTypeHint($parameter));
if (true === $parameter->isDefaultValueAvailable()) {
$node->setDefault($parameter->getDefaultValue());
} elseif (true === $parameter->isOptional()
|| (true === $parameter->allowsNull() && $typeHint)) {
$node->setDefault(null);
if ($this->isVariadic($parameter)) {
$node->setAsVariadic();
}
if (true === $parameter->isPassedByReference()) {
if ($this->hasDefaultValue($parameter)) {
$node->setDefault($this->getDefaultValue($parameter));
}
if ($parameter->isPassedByReference()) {
$node->setAsPassedByReference();
}
$methodNode->addArgument($node);
}
private function hasDefaultValue(ReflectionParameter $parameter)
{
if ($this->isVariadic($parameter)) {
return false;
}
if ($parameter->isDefaultValueAvailable()) {
return true;
}
return $parameter->isOptional() || $this->isNullable($parameter);
}
private function getDefaultValue(ReflectionParameter $parameter)
{
if (!$parameter->isDefaultValueAvailable()) {
return null;
}
return $parameter->getDefaultValue();
}
private function getTypeHint(ReflectionParameter $parameter)
{
if (null !== $className = $this->getParameterClassName($parameter)) {
@@ -197,6 +231,16 @@ class ClassMirror
return null;
}
private function isVariadic(ReflectionParameter $parameter)
{
return PHP_VERSION_ID >= 50600 && $parameter->isVariadic();
}
private function isNullable(ReflectionParameter $parameter)
{
return $parameter->allowsNull() && null !== $this->getTypeHint($parameter);
}
private function getParameterClassName(ReflectionParameter $parameter)
{
try {

View File

@@ -23,6 +23,7 @@ class ArgumentNode
private $default;
private $optional = false;
private $byReference = false;
private $isVariadic = false;
/**
* @param string $name
@@ -47,6 +48,11 @@ class ArgumentNode
$this->typeHint = $typeHint;
}
public function hasDefault()
{
return $this->isOptional() && !$this->isVariadic();
}
public function getDefault()
{
return $this->default;
@@ -72,4 +78,14 @@ class ArgumentNode
{
return $this->byReference;
}
public function setAsVariadic($isVariadic = true)
{
$this->isVariadic = $isVariadic;
}
public function isVariadic()
{
return $this->isVariadic;
}
}

View File

@@ -11,6 +11,7 @@
namespace Prophecy\Doubler\Generator\Node;
use Prophecy\Exception\Doubler\MethodNotExtendableException;
use Prophecy\Exception\InvalidArgumentException;
/**
@@ -23,6 +24,7 @@ class ClassNode
private $parentClass = 'stdClass';
private $interfaces = array();
private $properties = array();
private $unextendableMethods = array();
/**
* @var MethodNode[]
@@ -100,6 +102,12 @@ class ClassNode
public function addMethod(MethodNode $method)
{
if (!$this->isExtendable($method->getName())){
$message = sprintf(
'Method `%s` is not extendable, so can not be added.', $method->getName()
);
throw new MethodNotExtendableException($message, $this->getParentClass(), $method->getName());
}
$this->methods[$method->getName()] = $method;
}
@@ -127,4 +135,32 @@ class ClassNode
{
return isset($this->methods[$name]);
}
/**
* @return string[]
*/
public function getUnextendableMethods()
{
return $this->unextendableMethods;
}
/**
* @param string $unextendableMethod
*/
public function addUnextendableMethod($unextendableMethod)
{
if (!$this->isExtendable($unextendableMethod)){
return;
}
$this->unextendableMethods[] = $unextendableMethod;
}
/**
* @param string $method
* @return bool
*/
public function isExtendable($method)
{
return !in_array($method, $this->unextendableMethods);
}
}

View File

@@ -170,8 +170,19 @@ class MethodNode
{
$this->code = sprintf(
'return parent::%s(%s);', $this->getName(), implode(', ',
array_map(function (ArgumentNode $arg) { return '$'.$arg->getName(); }, $this->arguments)
array_map(array($this, 'generateArgument'), $this->arguments)
)
);
}
private function generateArgument(ArgumentNode $arg)
{
$argument = '$'.$arg->getName();
if ($arg->isVariadic()) {
$argument = '...'.$argument;
}
return $argument;
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Created by PhpStorm.
* User: jeff
* Date: 25/08/2015
* Time: 19:14
*/
namespace Prophecy\Exception\Doubler;
class MethodNotExtendableException extends DoubleException
{
private $methodName;
private $className;
/**
* @param string $message
* @param string $className
* @param string $methodName
*/
public function __construct($message, $className, $methodName)
{
parent::__construct($message);
$this->methodName = $methodName;
$this->className = $className;
}
/**
* @return string
*/
public function getMethodName()
{
return $this->methodName;
}
/**
* @return string
*/
public function getClassName()
{
return $this->className;
}
}

View File

@@ -37,10 +37,10 @@ class ReturnArgumentPromise implements PromiseInterface
public function __construct($index = 0)
{
if (!is_int($index) || $index < 0) {
throw new InvalidArgumentException(
throw new InvalidArgumentException(sprintf(
'Zero-based index expected as argument to ReturnArgumentPromise, but got %s.',
$index
);
));
}
$this->index = $index;
}

View File

@@ -46,13 +46,13 @@ class ThrowPromise implements PromiseInterface
&& !is_subclass_of($exception, 'Exception')) {
throw new InvalidArgumentException(sprintf(
'Exception class or instance expected as argument to ThrowPromise, but got %s.',
gettype($exception)
$exception
));
}
} elseif (!$exception instanceof \Exception) {
throw new InvalidArgumentException(sprintf(
'Exception class or instance expected as argument to ThrowPromise, but got %s.',
gettype($exception)
is_object($exception) ? get_class($exception) : gettype($exception)
));
}

View File

@@ -260,6 +260,8 @@ class ObjectProphecy implements ProphecyInterface
* Tries to get property value from double.
*
* @param string $name
*
* @return mixed
*/
public function __get($name)
{
@@ -270,7 +272,7 @@ class ObjectProphecy implements ProphecyInterface
* Tries to set property value to double.
*
* @param string $name
* @param string $value
* @param mixed $value
*/
public function __set($name, $value)
{

View File

@@ -3,7 +3,7 @@
namespace Prophecy\Util;
use Prophecy\Prophecy\ProphecyInterface;
use SplObjectStorage;
use SebastianBergmann\RecursionContext\Context;
/*
* This file is part of the Prophecy.
@@ -15,73 +15,85 @@ use SplObjectStorage;
*/
/**
* Exporting utility.
*
* This class is derived from the PHPUnit testing framework.
*
* @author Sebastiaan Stok <s.stok@rollerscapes.net
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License>
* This class is a modification from sebastianbergmann/exporter
* @see https://github.com/sebastianbergmann/exporter
*/
class ExportUtil
{
/**
* Exports a value into a string.
* Exports a value as a string
*
* The output of this method is similar to the output of print_r(), but
* improved in various aspects:
*
* - NULL is rendered as "null" (instead of "")
* - true is rendered as "true" (instead of "1")
* - TRUE is rendered as "true" (instead of "1")
* - FALSE is rendered as "false" (instead of "")
* - Strings are always quoted with single quotes
* - Carriage returns and newlines are normalized to \n
* - Recursion and repeated rendering is treated properly
*
* @param mixed $value The value to export
* @param integer $indentation The indentation level of the 2nd+ line
*
* @param mixed $value
* @param int $indentation The indentation level of the 2nd+ line
* @return string
*/
public static function export($value, $indentation = 0)
{
return static::recursiveExport($value, $indentation);
return self::recursiveExport($value, $indentation);
}
/**
* Converts an object to an array containing all of its private, protected
* and public properties.
*
* @param object $object
*
* @param mixed $value
* @return array
*/
public static function toArray($object)
public static function toArray($value)
{
if (!is_object($value)) {
return (array) $value;
}
$array = array();
foreach ((array) $object as $key => $value) {
foreach ((array) $value as $key => $val) {
// properties are transformed to keys in the following way:
// private $property => "\0Classname\0property"
// protected $property => "\0*\0property"
// public $property => "property"
if (preg_match('/^\0.+\0(.+)$/', $key, $matches)) {
$key = $matches[1];
}
$array[$key] = $value;
// See https://github.com/php/php-src/commit/5721132
if ($key === "\0gcdata") {
continue;
}
$array[$key] = $val;
}
// Some internal classes like SplObjectStorage don't work with the
// above (fast) mechanism nor with reflection
// above (fast) mechanism nor with reflection in Zend.
// Format the output similarly to print_r() in this case
if ($object instanceof SplObjectStorage) {
foreach ($object as $key => $value) {
$array[spl_object_hash($value)] = array(
'obj' => $value,
'inf' => $object->getInfo(),
if ($value instanceof \SplObjectStorage) {
// However, the fast method does work in HHVM, and exposes the
// internal implementation. Hide it again.
if (property_exists('\SplObjectStorage', '__storage')) {
unset($array['__storage']);
} elseif (property_exists('\SplObjectStorage', 'storage')) {
unset($array['storage']);
}
if (property_exists('\SplObjectStorage', '__key')) {
unset($array['__key']);
}
foreach ($value as $key => $val) {
$array[spl_object_hash($val)] = array(
'obj' => $val,
'inf' => $value->getInfo(),
);
}
}
@@ -90,16 +102,15 @@ class ExportUtil
}
/**
* Recursive implementation of export.
*
* @param mixed $value The value to export
* @param integer $indentation The indentation level of the 2nd+ line
* @param array $processedObjects Contains all objects that were already
* rendered
* Recursive implementation of export
*
* @param mixed $value The value to export
* @param int $indentation The indentation level of the 2nd+ line
* @param \SebastianBergmann\RecursionContext\Context $processed Previously processed objects
* @return string
* @see SebastianBergmann\Exporter\Exporter::export
*/
protected static function recursiveExport($value, $indentation, &$processedObjects = array())
protected static function recursiveExport(&$value, $indentation, $processed = null)
{
if ($value === null) {
return 'null';
@@ -113,73 +124,88 @@ class ExportUtil
return 'false';
}
if (is_float($value) && floatval(intval($value)) === $value) {
return "$value.0";
}
if (is_resource($value)) {
return sprintf(
'resource(%d) of type (%s)',
$value,
get_resource_type($value)
);
}
if (is_string($value)) {
// Match for most non printable chars somewhat taking multibyte chars into account
if (preg_match('/[^\x09-\x0d\x20-\xff]/', $value)) {
return 'Binary String: 0x' . bin2hex($value);
}
return "'" . str_replace(array("\r\n", "\n\r", "\r"), array("\n", "\n", "\n"), $value) . "'";
return "'" .
str_replace(array("\r\n", "\n\r", "\r"), array("\n", "\n", "\n"), $value) .
"'";
}
$origValue = $value;
$whitespace = str_repeat(' ', 4 * $indentation);
if (is_object($value)) {
if ($value instanceof ProphecyInterface) {
return sprintf('%s Object (*Prophecy*)', get_class($value));
} elseif (in_array($value, $processedObjects, true)) {
return sprintf('%s Object (*RECURSION*)', get_class($value));
}
$processedObjects[] = $value;
// Convert object to array
$value = self::toArray($value);
if (!$processed) {
$processed = new Context;
}
if (is_array($value)) {
$whitespace = str_repeat(' ', $indentation);
// There seems to be no other way to check arrays for recursion
// http://www.php.net/manual/en/language.types.array.php#73936
preg_match_all('/\n \[(\w+)\] => Array\s+\*RECURSION\*/', print_r($value, true), $matches);
$recursiveKeys = array_unique($matches[1]);
// Convert to valid array keys
// Numeric integer strings are automatically converted to integers
// by PHP
foreach ($recursiveKeys as $key => $recursiveKey) {
if ((string) (integer) $recursiveKey === $recursiveKey) {
$recursiveKeys[$key] = (integer) $recursiveKey;
}
if (($key = $processed->contains($value)) !== false) {
return 'Array &' . $key;
}
$content = '';
$key = $processed->add($value);
$values = '';
foreach ($value as $key => $val) {
if (in_array($key, $recursiveKeys, true)) {
$val = 'Array (*RECURSION*)';
} else {
$val = self::recursiveExport($val, $indentation + 1, $processedObjects);
if (count($value) > 0) {
foreach ($value as $k => $v) {
$values .= sprintf(
'%s %s => %s' . "\n",
$whitespace,
self::recursiveExport($k, $indentation),
self::recursiveExport($value[$k], $indentation + 1, $processed)
);
}
$content .= $whitespace . ' ' . self::export($key) . ' => ' . $val . "\n";
$values = "\n" . $values . $whitespace;
}
if (strlen($content) > 0) {
$content = "\n" . $content . $whitespace;
return sprintf('Array &%s (%s)', $key, $values);
}
if (is_object($value)) {
$class = get_class($value);
if ($value instanceof ProphecyInterface) {
return sprintf('%s Object (*Prophecy*)', $class);
} elseif ($hash = $processed->contains($value)) {
return sprintf('%s:%s Object', $class, $hash);
}
return sprintf(
"%s (%s)",
is_object($origValue) ? sprintf('%s:%s', get_class($origValue), spl_object_hash($origValue)) . ' Object' : 'Array', $content
);
$hash = $processed->add($value);
$values = '';
$array = self::toArray($value);
if (count($array) > 0) {
foreach ($array as $k => $v) {
$values .= sprintf(
'%s %s => %s' . "\n",
$whitespace,
self::recursiveExport($k, $indentation),
self::recursiveExport($v, $indentation + 1, $processed)
);
}
$values = "\n" . $values . $whitespace;
}
return sprintf('%s:%s Object (%s)', $class, $hash, $values);
}
if (is_double($value) && (double)(integer) $value === $value) {
return $value . '.0';
}
return (string) $value;
return var_export($value, true);
}
}

View File

@@ -98,7 +98,7 @@ You can also enable more lenient validation (for example, fixed lines without ar
```
### Display
Format a fetched phone value using the helper function:
Format a fetched phone value using the helper function. `$country_code` is the country the phone number belongs to.
```php
phone_format($phone_number, $country_code, $format = PhoneNumberFormat::INTERNATIONAL)

View File

@@ -123,7 +123,7 @@ class PhoneValidator
*/
protected function checkCountries($attribute, $validator)
{
$data = $validator->getData();
$data = array_dot($validator->getData());
$countryField = $attribute . '_country';
if (isset($data[$countryField])) {

View File

@@ -18,8 +18,16 @@ class PhoneValidatorTest extends TestCase
private function performValidation($data)
{
$rule = 'phone' . (isset($data['rule']) ? ':' . $data['rule'] : '');
$validator = $this->validator->make(
array_only($data, ['field', 'field_country']), ['field' => $rule]
$input = array_only($data, ['field', 'field_country']);
$input['nested']['field'] = $input['field'];
if (isset($input['field_country'])) {
$input['nested']['field_country'] = $input['field_country'];
}
$validator = $this->validator->make($input,
['field' => $rule,
'nested.field' => $rule]
);
return $validator->passes();

View File

@@ -46,10 +46,38 @@ class Console
*/
public function getNumberOfColumns()
{
// Windows terminals have a fixed size of 80
// but one column is used for the cursor.
if (DIRECTORY_SEPARATOR == '\\') {
return 79;
$columns = 80;
if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) {
$columns = $matches[1];
} elseif (function_exists('proc_open')) {
$process = proc_open(
'mode CON',
array(
1 => array('pipe', 'w'),
2 => array('pipe', 'w')
),
$pipes,
null,
null,
array('suppress_errors' => true)
);
if (is_resource($process)) {
$info = stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
$columns = $matches[2];
}
}
}
return $columns - 1;
}
if (!$this->isInteractive(self::STDIN)) {
@@ -57,11 +85,15 @@ class Console
}
if (preg_match('#\d+ (\d+)#', shell_exec('stty size'), $match) === 1) {
return (int) $match[1];
if ((int) $match[1] > 0) {
return (int) $match[1];
}
}
if (preg_match('#columns = (\d+);#', shell_exec('stty'), $match) === 1) {
return (int) $match[1];
if ((int) $match[1] > 0) {
return (int) $match[1];
}
}
return 80;

View File

@@ -235,12 +235,12 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
private function preProcess($eventName)
{
foreach ($this->dispatcher->getListeners($eventName) as $listener) {
$this->dispatcher->removeListener($eventName, $listener);
$info = $this->getListenerInfo($listener, $eventName);
$name = isset($info['class']) ? $info['class'] : $info['type'];
$wrappedListener = new WrappedListener($listener, $name, $this->stopwatch, $this);
$this->wrappedListeners[$eventName][] = $wrappedListener;
$this->dispatcher->addListener($eventName, $wrappedListener);
$this->dispatcher->removeListener($eventName, $listener);
$this->dispatcher->addListener($eventName, $wrappedListener, $info['priority']);
}
}
@@ -253,8 +253,9 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
continue;
}
// Unwrap listener
$priority = $this->getListenerPriority($eventName, $listener);
$this->dispatcher->removeListener($eventName, $listener);
$this->dispatcher->addListener($eventName, $listener->getWrappedListener());
$this->dispatcher->addListener($eventName, $listener->getWrappedListener(), $priority);
$info = $this->getListenerInfo($listener->getWrappedListener(), $eventName);
if ($listener->wasCalled()) {

View File

@@ -59,6 +59,18 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
->with($event)
;
$service
->expects($this->once())
->method('onEventWithPriority')
->with($event)
;
$service
->expects($this->once())
->method('onEventNested')
->with($event)
;
$container = new Container();
$container->set('service.subscriber', $service);
@@ -66,6 +78,8 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
$dispatcher->addSubscriberService('service.subscriber', 'Symfony\Component\EventDispatcher\Tests\SubscriberService');
$dispatcher->dispatch('onEvent', $event);
$dispatcher->dispatch('onEventWithPriority', $event);
$dispatcher->dispatch('onEventNested', $event);
}
public function testPreventDuplicateListenerService()
@@ -243,11 +257,21 @@ class SubscriberService implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
'onEvent' => array('onEvent'),
'onEvent' => 'onEvent',
'onEventWithPriority' => array('onEventWithPriority', 10),
'onEventNested' => array(array('onEventNested')),
);
}
public function onEvent(Event $e)
{
}
public function onEventWithPriority(Event $e)
{
}
public function onEventNested(Event $e)
{
}
}

View File

@@ -56,6 +56,23 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($tdispatcher->hasListeners('foo'));
}
public function testGetListenerPriority()
{
$dispatcher = new EventDispatcher();
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
$tdispatcher->addListener('foo', function () {}, 123);
$listeners = $dispatcher->getListeners('foo');
$this->assertSame(123, $tdispatcher->getListenerPriority('foo', $listeners[0]));
// Verify that priority is preserved when listener is removed and re-added
// in preProcess() and postProcess().
$tdispatcher->dispatch('foo', new Event());
$listeners = $dispatcher->getListeners('foo');
$this->assertSame(123, $tdispatcher->getListenerPriority('foo', $listeners[0]));
}
public function testAddRemoveSubscriber()
{
$dispatcher = new EventDispatcher();
@@ -138,12 +155,12 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase
$dispatcher = new EventDispatcher();
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
$tdispatcher->addListener('foo', $listener1 = function () use (&$called) { $called[] = 'foo1'; });
$tdispatcher->addListener('foo', $listener2 = function () use (&$called) { $called[] = 'foo2'; });
$tdispatcher->addListener('foo', function () use (&$called) { $called[] = 'foo1'; }, 10);
$tdispatcher->addListener('foo', function () use (&$called) { $called[] = 'foo2'; }, 20);
$tdispatcher->dispatch('foo');
$this->assertEquals(array('foo1', 'foo2'), $called);
$this->assertSame(array('foo2', 'foo1'), $called);
}
public function testDispatchNested()

View File

@@ -115,6 +115,10 @@ class Filesystem
public function exists($files)
{
foreach ($this->toIterator($files) as $file) {
if ('\\' === DIRECTORY_SEPARATOR && strlen($file) > 258) {
throw new IOException('Could not check if file exist because path length exceeds 258 characters.', 0, null, $file);
}
if (!file_exists($file)) {
return false;
}
@@ -154,7 +158,7 @@ class Filesystem
$files = iterator_to_array($this->toIterator($files));
$files = array_reverse($files);
foreach ($files as $file) {
if (!file_exists($file) && !is_link($file)) {
if (!$this->exists($file) && !is_link($file)) {
continue;
}
@@ -268,7 +272,7 @@ class Filesystem
public function rename($origin, $target, $overwrite = false)
{
// we check that target does not exist
if (!$overwrite && is_readable($target)) {
if (!$overwrite && $this->isReadable($target)) {
throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
}
@@ -277,6 +281,22 @@ class Filesystem
}
}
/**
* Tells whether a file exists and is readable.
*
* @param string $filename Path to the file.
*
* @throws IOException When windows path is longer than 258 characters
*/
private function isReadable($filename)
{
if ('\\' === DIRECTORY_SEPARATOR && strlen($filename) > 258) {
throw new IOException('Could not check if file is readable because path length exceeds 258 characters.', 0, null, $filename);
}
return is_readable($filename);
}
/**
* Creates a symbolic link or copy a directory.
*

View File

@@ -69,7 +69,7 @@ class LockHandler
}
// Silence error reporting
set_error_handler(function() {});
set_error_handler(function () {});
if (!$this->handle = fopen($this->file, 'r')) {
if ($this->handle = fopen($this->file, 'x')) {

View File

@@ -358,6 +358,28 @@ class FilesystemTest extends FilesystemTestCase
$this->assertTrue($this->filesystem->exists($basePath.'folder'));
}
/**
* @expectedException \Symfony\Component\Filesystem\Exception\IOException
*/
public function testFilesExistsFails()
{
if ('\\' !== DIRECTORY_SEPARATOR) {
$this->markTestSkipped('Test covers edge case on Windows only.');
}
$basePath = $this->workspace.'\\directory\\';
$oldPath = getcwd();
mkdir($basePath);
chdir($basePath);
$file = str_repeat('T', 259 - strlen($basePath));
$path = $basePath.$file;
exec('TYPE NUL >>'.$file); // equivalent of touch, we can not use the php touch() here because it suffers from the same limitation
self::$longPathNamesWindows[] = $path; // save this so we can clean up later
chdir($oldPath);
$this->filesystem->exists($path);
}
public function testFilesExistsTraversableObjectOfFilesAndDirectories()
{
$basePath = $this->workspace.DIRECTORY_SEPARATOR;
@@ -893,7 +915,7 @@ class FilesystemTest extends FilesystemTestCase
public function testMirrorCopiesLinkedDirectoryContents()
{
$this->markAsSkippedIfSymlinkIsMissing();
$this->markAsSkippedIfSymlinkIsMissing(true);
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
@@ -913,7 +935,7 @@ class FilesystemTest extends FilesystemTestCase
public function testMirrorCopiesRelativeLinkedContents()
{
$this->markAsSkippedIfSymlinkIsMissing();
$this->markAsSkippedIfSymlinkIsMissing(true);
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
$oldPath = getcwd();
@@ -1005,7 +1027,6 @@ class FilesystemTest extends FilesystemTestCase
// The compress.zlib:// stream does not support mode x: creates the file, errors "failed to open stream: operation failed" and returns false
$this->filesystem->tempnam($dirname, 'bar');
}
public function testTempnamWithPHPTempSchemeFails()
@@ -1151,8 +1172,8 @@ class FilesystemTest extends FilesystemTestCase
{
$this->markAsSkippedIfChmodIsMissing();
$sourceFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_source_file';
$targetFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_target_file';
$sourceFilePath = $this->workspace . DIRECTORY_SEPARATOR . 'copy_source_file';
$targetFilePath = $this->workspace . DIRECTORY_SEPARATOR . 'copy_target_file';
file_put_contents($sourceFilePath, 'SOURCE FILE');
chmod($sourceFilePath, 0745);

View File

@@ -17,6 +17,8 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
{
private $umask;
static protected $longPathNamesWindows = array();
/**
* @var \Symfony\Component\Filesystem\Filesystem
*/
@@ -31,6 +33,12 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
public static function setUpBeforeClass()
{
if (!empty(self::$longPathNamesWindows)) {
foreach (self::$longPathNamesWindows as $path) {
exec('DEL '.$path);
}
}
if ('\\' === DIRECTORY_SEPARATOR && null === self::$symlinkOnWindows) {
$target = tempnam(sys_get_temp_dir(), 'sl');
$link = sys_get_temp_dir().'/sl'.microtime(true).mt_rand();
@@ -92,7 +100,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Unable to retrieve file group name');
}
protected function markAsSkippedIfSymlinkIsMissing()
protected function markAsSkippedIfSymlinkIsMissing($relative = false)
{
if (!function_exists('symlink')) {
$this->markTestSkipped('Function symlink is required.');
@@ -101,6 +109,11 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
if ('\\' === DIRECTORY_SEPARATOR && false === self::$symlinkOnWindows) {
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on Windows');
}
// https://bugs.php.net/bug.php?id=69473
if ($relative && '\\' === DIRECTORY_SEPARATOR && 1 === PHP_ZTS) {
$this->markTestSkipped('symlink does not support relative paths on thread safe Windows PHP versions');
}
}
protected function markAsSkippedIfChmodIsMissing()

View File

@@ -519,7 +519,12 @@ class Inline
case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
return (float) str_replace(',', '', $scalar);
case preg_match(self::getTimestampRegex(), $scalar):
return strtotime($scalar);
$timeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$time = strtotime($scalar);
date_default_timezone_set($timeZone);
return $time;
}
default:
return (string) $scalar;

View File

@@ -301,8 +301,14 @@ class Parser
mb_internal_encoding($mbEncoding);
}
if ($objectForMap && !is_object($data)) {
$data = (object) $data;
if ($objectForMap && !is_object($data) && 'mapping' === $context) {
$object = new \stdClass();
foreach ($data as $key => $value) {
$object->$key = $value;
}
$data = $object;
}
return empty($data) ? null : $data;

View File

@@ -754,7 +754,7 @@ yaml: |
Billsmer @ 338-4338.
php: |
array(
'invoice' => 34843, 'date' => mktime(0, 0, 0, 1, 23, 2001),
'invoice' => 34843, 'date' => gmmktime(0, 0, 0, 1, 23, 2001),
'bill-to' =>
array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
, 'ship-to' =>
@@ -879,7 +879,7 @@ yaml: |
php: |
array(
'invoice' => 34843,
'date' => mktime(0, 0, 0, 1, 23, 2001),
'date' => gmmktime(0, 0, 0, 1, 23, 2001),
'total' => 4443.52
)
---

View File

@@ -251,7 +251,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
array("'on'", 'on'),
array("'off'", 'off'),
array('2007-10-30', mktime(0, 0, 0, 10, 30, 2007)),
array('2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)),
array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)),
array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)),
array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)),
@@ -318,7 +318,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
array("'#cfcfcf'", '#cfcfcf'),
array('::form_base.html.twig', '::form_base.html.twig'),
array('2007-10-30', mktime(0, 0, 0, 10, 30, 2007)),
array('2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)),
array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)),
array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)),
array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)),

View File

@@ -442,35 +442,75 @@ EOF;
$this->assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects');
}
public function testObjectForMapEnabledWithMapping()
/**
* @dataProvider getObjectForMapTests
*/
public function testObjectForMap($yaml, $expected)
{
$this->assertEquals($expected, $this->parser->parse($yaml, false, false, true));
}
public function getObjectForMapTests()
{
$tests = array();
$yaml = <<<EOF
foo:
fiz: [cat]
EOF;
$result = $this->parser->parse($yaml, false, false, true);
$expected = new \stdClass();
$expected->foo = new \stdClass();
$expected->foo->fiz = array('cat');
$tests['mapping'] = array($yaml, $expected);
$this->assertInstanceOf('stdClass', $result);
$this->assertInstanceOf('stdClass', $result->foo);
$this->assertEquals(array('cat'), $result->foo->fiz);
}
$yaml = '{ "foo": "bar", "fiz": "cat" }';
$expected = new \stdClass();
$expected->foo = 'bar';
$expected->fiz = 'cat';
$tests['inline-mapping'] = array($yaml, $expected);
public function testObjectForMapEnabledWithInlineMapping()
{
$result = $this->parser->parse('{ "foo": "bar", "fiz": "cat" }', false, false, true);
$this->assertInstanceOf('stdClass', $result);
$this->assertEquals('bar', $result->foo);
$this->assertEquals('cat', $result->fiz);
}
public function testObjectForMapIsAppliedAfterParsing()
{
$yaml = "foo: bar\nbaz: foobar";
$expected = new \stdClass();
$expected->foo = 'bar';
$expected->baz = 'foobar';
$tests['object-for-map-is-applied-after-parsing'] = array($yaml, $expected);
$this->assertEquals($expected, $this->parser->parse("foo: bar\nbaz: foobar", false, false, true));
$yaml = <<<EOT
array:
- key: one
- key: two
EOT;
$expected = new \stdClass();
$expected->array = array();
$expected->array[0] = new \stdClass();
$expected->array[0]->key = 'one';
$expected->array[1] = new \stdClass();
$expected->array[1]->key = 'two';
$tests['nest-map-and-sequence'] = array($yaml, $expected);
$yaml = <<<YAML
map:
1: one
2: two
YAML;
$expected = new \stdClass();
$expected->map = new \stdClass();
$expected->map->{1} = 'one';
$expected->map->{2} = 'two';
$tests['numeric-keys'] = array($yaml, $expected);
$yaml = <<<YAML
map:
0: one
1: two
YAML;
$expected = new \stdClass();
$expected->map = new \stdClass();
$expected->map->{0} = 'one';
$expected->map->{1} = 'two';
$tests['zero-indexed-numeric-keys'] = array($yaml, $expected);
return $tests;
}
/**

View File

@@ -1 +1,6 @@
preset: psr2
preset: laravel
enabled:
- unalign_double_arrow
linting: true

View File

@@ -18,7 +18,3 @@ before_script:
script:
- phpunit --coverage-text --coverage-clover=coverage.clover
after_script:
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi;'
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi;'

View File

@@ -1,34 +0,0 @@
filter:
excluded_paths: [tests/*]
checks:
php:
code_rating: true
remove_extra_empty_lines: true
remove_php_closing_tag: true
remove_trailing_whitespace: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: true
order_alphabetically: true
fix_php_opening_tag: true
fix_linefeed: true
fix_line_ending: true
fix_identation_4spaces: true
fix_doc_comments: true
tools:
external_code_coverage:
timeout: 1800
runs: 3
php_code_coverage: false
php_code_sniffer:
config:
standard: PSR2
filter:
paths: ['src']
php_loc:
enabled: true
excluded_dirs: [vendor, tests]
php_cpd:
enabled: true
excluded_dirs: [vendor, tests]

View File

@@ -1,5 +1,14 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth;
use Tymon\JWTAuth\Providers\Storage\StorageInterface;
@@ -11,6 +20,13 @@ class Blacklist
*/
protected $storage;
/**
* Number of minutes from issue date in which a JWT can be refreshed.
*
* @var int
*/
protected $refreshTTL = 20160;
/**
* @param \Tymon\JWTAuth\Providers\Storage\StorageInterface $storage
*/
@@ -20,34 +36,38 @@ class Blacklist
}
/**
* Add the token (jti claim) to the blacklist
* Add the token (jti claim) to the blacklist.
*
* @param \Tymon\JWTAuth\Payload $payload
* @return boolean
* @return bool
*/
public function add(Payload $payload)
{
$exp = Utils::timestamp($payload['exp']);
$refreshExp = Utils::timestamp($payload['iat'])->addMinutes($this->refreshTTL);
// there is no need to add the token to the blacklist
// if the token has already expired
if ($exp->isPast()) {
// if the token has already expired AND the refresh_ttl
// has gone by
if ($exp->isPast() && $refreshExp->isPast()) {
return false;
}
// add a minute to abate potential overlap
$minutes = $exp->diffInMinutes(Utils::now()->subMinute());
// Set the cache entry's lifetime to be equal to the amount
// of refreshable time it has remaining (which is the larger
// of `exp` and `iat+refresh_ttl`), rounded up a minute
$cacheLifetime = $exp->max($refreshExp)->addMinute()->diffInMinutes();
$this->storage->add($payload['jti'], [], $minutes);
$this->storage->add($payload['jti'], [], $cacheLifetime);
return true;
}
/**
* Determine whether the token has been blacklisted
* Determine whether the token has been blacklisted.
*
* @param \Tymon\JWTAuth\Payload $payload
* @return boolean
* @return bool
*/
public function has(Payload $payload)
{
@@ -55,10 +75,10 @@ class Blacklist
}
/**
* Remove the token (jti claim) from the blacklist
* Remove the token (jti claim) from the blacklist.
*
* @param \Tymon\JWTAuth\Payload $payload
* @return boolean
* @return bool
*/
public function remove(Payload $payload)
{
@@ -66,9 +86,9 @@ class Blacklist
}
/**
* Remove all tokens from the blacklist
* Remove all tokens from the blacklist.
*
* @return boolean
* @return bool
*/
public function clear()
{
@@ -76,4 +96,18 @@ class Blacklist
return true;
}
/**
* Set the refresh time limit.
*
* @param int
*
* @return $this
*/
public function setRefreshTTL($ttl)
{
$this->refreshTTL = (int) $ttl;
return $this;
}
}

View File

@@ -1,11 +1,20 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Claims;
class Audience extends Claim
{
/**
* The claim name
* The claim name.
*
* @var string
*/

View File

@@ -1,5 +1,14 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Claims;
use Tymon\JWTAuth\Exceptions\InvalidClaimException;
@@ -7,14 +16,14 @@ use Tymon\JWTAuth\Exceptions\InvalidClaimException;
abstract class Claim implements ClaimInterface
{
/**
* The claim name
* The claim name.
*
* @var string
*/
protected $name;
/**
* The claim value
* The claim value.
*
* @var mixed
*/
@@ -29,7 +38,7 @@ abstract class Claim implements ClaimInterface
}
/**
* Set the claim value, and call a validate method if available
* Set the claim value, and call a validate method if available.
*
* @param $value
* @throws \Tymon\JWTAuth\Exceptions\InvalidClaimException
@@ -38,7 +47,7 @@ abstract class Claim implements ClaimInterface
public function setValue($value)
{
if (! $this->validate($value)) {
throw new InvalidClaimException('Invalid value provided for claim "' . $this->getName() . '": ' . $value);
throw new InvalidClaimException('Invalid value provided for claim "'.$this->getName().'": '.$value);
}
$this->value = $value;
@@ -47,7 +56,7 @@ abstract class Claim implements ClaimInterface
}
/**
* Get the claim value
* Get the claim value.
*
* @return mixed
*/
@@ -57,7 +66,7 @@ abstract class Claim implements ClaimInterface
}
/**
* Set the claim name
* Set the claim name.
*
* @param string $name
* @return $this
@@ -70,7 +79,7 @@ abstract class Claim implements ClaimInterface
}
/**
* Get the claim name
* Get the claim name.
*
* @return string
*/
@@ -80,10 +89,10 @@ abstract class Claim implements ClaimInterface
}
/**
* Validate the Claim value
* Validate the Claim value.
*
* @param $value
* @return boolean
* @return bool
*/
protected function validate($value)
{
@@ -91,7 +100,7 @@ abstract class Claim implements ClaimInterface
}
/**
* Build a key value array comprising of the claim name and value
* Build a key value array comprising of the claim name and value.
*
* @return array
*/
@@ -101,7 +110,7 @@ abstract class Claim implements ClaimInterface
}
/**
* Get the claim as a string
* Get the claim as a string.
*
* @return string
*/

View File

@@ -1,11 +1,20 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Claims;
interface ClaimInterface
{
/**
* Set the claim value, and call a validate method if available
* Set the claim value, and call a validate method if available.
*
* @param mixed
* @return Claim
@@ -13,14 +22,14 @@ interface ClaimInterface
public function setValue($value);
/**
* Get the claim value
* Get the claim value.
*
* @return mixed
*/
public function getValue();
/**
* Set the claim name
* Set the claim name.
*
* @param string $name
* @return Claim
@@ -28,7 +37,7 @@ interface ClaimInterface
public function setName($name);
/**
* Get the claim name
* Get the claim name.
*
* @return string
*/

View File

@@ -1,5 +1,14 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Claims;
class Custom extends Claim

View File

@@ -1,21 +1,30 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Claims;
class Expiration extends Claim
{
/**
* The claim name
* The claim name.
*
* @var string
*/
protected $name = 'exp';
/**
* Validate the expiry claim
* Validate the expiry claim.
*
* @param mixed $value
* @return boolean
* @return bool
*/
protected function validate($value)
{

View File

@@ -1,5 +1,14 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Claims;
class Factory
@@ -14,11 +23,11 @@ class Factory
'iss' => 'Tymon\JWTAuth\Claims\Issuer',
'jti' => 'Tymon\JWTAuth\Claims\JwtId',
'nbf' => 'Tymon\JWTAuth\Claims\NotBefore',
'sub' => 'Tymon\JWTAuth\Claims\Subject'
'sub' => 'Tymon\JWTAuth\Claims\Subject',
];
/**
* Get the instance of the claim when passing the name and value
* Get the instance of the claim when passing the name and value.
*
* @param string $name
* @param mixed $value
@@ -34,10 +43,10 @@ class Factory
}
/**
* Check whether the claim exists
* Check whether the claim exists.
*
* @param string $name
* @return boolean
* @return bool
*/
public function has($name)
{

View File

@@ -1,21 +1,30 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Claims;
class IssuedAt extends Claim
{
/**
* The claim name
* The claim name.
*
* @var string
*/
protected $name = 'iat';
/**
* Validate the issued at claim
* Validate the issued at claim.
*
* @param mixed $value
* @return boolean
* @return bool
*/
protected function validate($value)
{

View File

@@ -1,11 +1,20 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Claims;
class Issuer extends Claim
{
/**
* The claim name
* The claim name.
*
* @var string
*/

View File

@@ -1,11 +1,20 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Claims;
class JwtId extends Claim
{
/**
* The claim name
* The claim name.
*
* @var string
*/

View File

@@ -1,21 +1,30 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Claims;
class NotBefore extends Claim
{
/**
* The claim name
* The claim name.
*
* @var string
*/
protected $name = 'nbf';
/**
* Validate the not before claim
* Validate the not before claim.
*
* @param mixed $value
* @return boolean
* @return bool
*/
protected function validate($value)
{

Some files were not shown because too many files have changed in this diff Show More