Osnova modula za volitve

This commit is contained in:
pero1203 2021-03-10 11:24:00 +01:00
parent 6569d4be6f
commit 617b8b2f44
25 changed files with 257 additions and 186 deletions

View File

@ -37,6 +37,7 @@
* slideshow (prezentacija)
* social_network (socialna omrežja - generator imen)
* quiz (kviz s pravilnimi/napacnimi odgovori)
* voting (volitve z anonimnimi vabili)
* uporabnost (evalvacija strani - split screen)
* panel (povezovanje ankete s panelom - npr. Valicon, GFK...)
* 360_stopinj (adecco)
@ -1168,6 +1169,18 @@ class SurveyAdmin
echo '<span class="module_icon quiz"></span>';
echo '</a>';
echo '</li>';
}
# volitve
if (isset($modules['voting'])) {
$css = ($this->first_action == A_VOTING) ? 'on' : 'off';
echo '<li class="space">&nbsp;</li>';
echo '<li>';
echo '<a href="index.php?anketa=' . $this->anketa . '&amp;a=' . A_VOTING . '" title="' . $lang['srv_vrsta_survey_type_18'] . '">';
echo '<span class="module_icon voting"></span>';
echo '</a>';
echo '</li>';
}
# napredni parapodatki
if (isset($modules['advanced_paradata'])) {
@ -1776,6 +1789,14 @@ class SurveyAdmin
|| isset($modules['slideshow'])) ? '' : ' side-right';
echo '<li class="space"></li>';
echo '<li><a class="no-img' . $_right . $_active . '" href="' . $site_url . 'admin/survey/index.php?anketa=' . $this->anketa . '&amp;a=' . A_KVIZ . '" title="' . $lang['srv_kviz'] . '">' . $lang['srv_kviz'] . '</a></li>';
}
#volitve
if (isset($modules['voting'])) {
$_active = ($_GET['a'] == A_VOTING) ? ' active' : '';
$_right = (isset($modules['social_network'])
|| isset($modules['slideshow'])) ? '' : ' side-right';
echo '<li class="space"></li>';
echo '<li><a class="no-img' . $_right . $_active . '" href="' . $site_url . 'admin/survey/index.php?anketa=' . $this->anketa . '&amp;a=' . A_VOTING . '" title="' . $lang['srv_voting'] . '">' . $lang['srv_voting'] . '</a></li>';
}
#napredni parapodatki
if (isset($modules['advanced_paradata'])) {
@ -2183,6 +2204,7 @@ class SurveyAdmin
|| $_GET['a'] == 'uporabnost'
|| ($_GET['a'] == 'hierarhija_superadmin' && $hierarhija_type < 5)
|| $_GET['a'] == 'kviz'
|| $_GET['a'] == 'voting'
|| $_GET['a'] == 'slideshow'
|| $_GET['a'] == 'vnos'
|| $_GET['a'] == A_TELEPHONE
@ -2433,6 +2455,7 @@ class SurveyAdmin
elseif ($_GET['a'] == 'uporabnost'
|| ($_GET['a'] == 'hierarhija_superadmin' && $hierarhija_type < 5)
|| $_GET['a'] == 'kviz'
|| $_GET['a'] == 'voting'
|| $_GET['a'] == 'slideshow'
|| $_GET['a'] == 'vnos'
|| $_GET['a'] == A_TELEPHONE
@ -3143,6 +3166,10 @@ class SurveyAdmin
echo '<li ' . ($get == A_KVIZ ? ' class="highlightLineTab"' : ' class="nonhighlight"') . '>';
echo '<a href="index.php?anketa=' . $this->anketa . '&amp;a='.A_KVIZ.'" title="' . $lang['srv_vrsta_survey_type_6'] . '" '.(!$userAccess->checkUserAccess($what='kviz') ? 'class="user_access_locked"' : '').'><span>' . $lang['srv_vrsta_survey_type_6'] . '</span></a></li> ';
# Volitve
echo '<li ' . ($get == A_VOTING ? ' class="highlightLineTab"' : ' class="nonhighlight"') . '>';
echo '<a href="index.php?anketa=' . $this->anketa . '&amp;a='.A_VOTING.'" title="' . $lang['srv_vrsta_survey_type_18'] . '" '.(!$userAccess->checkUserAccess($what='voting') ? 'class="user_access_locked"' : '').'><span>' . $lang['srv_vrsta_survey_type_18'] . '</span></a></li> ';
# Socialna omrezja
echo '<li ' . ($get == A_SOCIAL_NETWORK ? ' class="highlightLineTab"' : ' class="nonhighlight"') . '>';
echo '<a href="index.php?anketa=' . $this->anketa . '&amp;a=' . A_SOCIAL_NETWORK . '" title="' . $lang['srv_vrsta_survey_type_8'] . '" '.(!$userAccess->checkUserAccess($what='social_network') ? 'class="user_access_locked"' : '').'><span>' . $lang['srv_vrsta_survey_type_8'] . '</span></a></li> ';

View File

@ -6119,6 +6119,11 @@ class SurveyAdminAjax {
$sq = new SurveyQuiz($this->anketa);
$sq->displaySettings();
}
elseif ($what == 'voting' && $value == '1'){
// volitve
$sv = new SurveyVoting($this->anketa);
$sv->displaySettings();
}
elseif ($what == 'advanced_paradata' && $value == '1'){
// kviz
$sap = new SurveyAdvancedParadata($this->anketa);

View File

@ -8697,6 +8697,22 @@ class SurveyAdminSettings {
}
echo '</div>';
}
elseif ($_GET['a'] == 'voting'){
echo '<fieldset><legend>'.$lang['srv_voting'].'</legend>';
echo '<label class="strong'.$css_disabled.'"><input type="checkbox" id="advanced_module_voting" name="voting" value="1" '. (isset($modules['voting']) ? ' checked="checked"' : '').$disabled.' onChange="toggleAdvancedModule(\'voting\');" />';
echo $lang['srv_vrsta_survey_type_18'] . '</label>';
echo '</fieldset>';
echo '<br />';
echo '<div id="globalSettingsInner">';
if(isset($modules['voting'])){
$sv = new SurveyVoting($this->anketa);
$sv->displaySettings();
}
echo '</div>';
}
elseif ($_GET['a'] == 'advanced_paradata'){
echo '<fieldset><legend>'.$lang['srv_advanced_paradata'].'</legend>';

View File

@ -725,6 +725,11 @@ class SurveyInfo
$module_availible = false;
break;
case 'voting':
if(!$userAccess->checkUserAccess($what='voting'))
$module_availible = false;
break;
case 'social_network':
if(!$userAccess->checkUserAccess($what='social_network'))
$module_availible = false;
@ -792,6 +797,11 @@ class SurveyInfo
return false;
break;
case 'voting':
if(!$userAccess->checkUserAccess($what='voting'))
return false;
break;
case 'social_network':
if(!$userAccess->checkUserAccess($what='social_network'))
return false;

View File

@ -929,6 +929,10 @@ class SurveyStatistic {
$enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_6'];
$prefix = ', ';
}
if (isset($modules['voting'])) {
$enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_18'];
$prefix = ', ';
}
if (isset($modules['phone'])) {
$enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_7'];
$prefix = ', ';

View File

@ -183,6 +183,7 @@ class CrossRoad {
case A_UPORABNOST:
case A_HIERARHIJA_SUPERADMIN:
case A_KVIZ:
case A_VOTING:
case A_ADVANCED_PARADATA:
case A_JSON_SURVEY_EXPORT:
case A_VNOS:

View File

@ -39,6 +39,7 @@
define("NAVI_HIERARHIJA_SUPERADMIN", "NAVI_HIERARHIJA_SUPERADMIN");
define("NAVI_HIERARHIJA", "NAVI_HIERARHIJA");
define("NAVI_KVIZ", "NAVI_KVIZ");
define("NAVI_VOTING", "NAVI_VOTING");
define("NAVI_VNOS", "NAVI_VNOS");
define("NAVI_PHONE", "NAVI_PHONE");
define("NAVI_360", "NAVI_360");
@ -178,6 +179,7 @@
define('A_UPORABNOST', 'uporabnost');
define('A_HIERARHIJA_SUPERADMIN', 'hierarhija_superadmin');
define('A_KVIZ', 'kviz');
define('A_VOTING', 'voting');
define('A_VNOS', 'vnos');
define('A_PHONE', 'telefon'); # Telefon
define('T_PHONE', 'telefon'); # Telefon

View File

@ -261,6 +261,10 @@ class LatexStatus {
$enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_6'];
$prefix = ', ';
}
if ($row['voting'] == 1) {
$enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_18'];
$prefix = ', ';
}
if ($row['phone'] == 1) {
$enabled_advanced .= $prefix . $lang['srv_vrsta_survey_type_7'];
$prefix = ', ';

View File

@ -0,0 +1,104 @@
<?php
/*
* Modul za volitve
*/
class SurveyVoting{
var $anketa; # id ankete
function __construct($anketa){
global $site_url;
// Ce imamo anketo
if ((int)$anketa > 0){
$this->anketa = $anketa;
}
}
// Nastavitve volitev
public function displaySettings(){
global $lang;
echo 'Nastavitve volitev';
// Posebne opcije in navodile za anketo kviz
/*echo '<fieldset><legend>'.$lang['srv_kviz_navodila_1'].'</legend>';
echo '<p>'.$lang['srv_kviz_navodila_2'].'</p>';
echo '<p>'.$lang['srv_kviz_navodila_3'].'</p>';
echo '<p>'.$lang['srv_kviz_navodila_4'].'</p>';
echo '<p>'.$lang['srv_kviz_navodila_6'].' '.Help::display('DataPiping').'</p>';
echo '<p>'.$lang['srv_kviz_navodila_7'].'</p>';
echo '</fieldset>';*/
/*echo '<fieldset><legend>'.$lang['settings'].'</legend>';
// Pridobimo trenutne nastavitve
$settings = $this->getSettings();
// Prikaz rezultatov v zakljucku
echo '<span class="nastavitveSpan1" >'.$lang['srv_quiz_results'].':</span>';
echo '<label for="quiz_results_0"><input type="radio" name="quiz_results" id="quiz_results_0" value="0" '.(($settings['results'] == 0) ? ' checked="checked" ' : '').' />'.$lang['no1'].'</label>';
echo '<label for="quiz_results_1"><input type="radio" name="quiz_results" id="quiz_results_1" value="1" '.(($settings['results'] == 1) ? ' checked="checked" ' : '').' />'.$lang['yes'].'</label>';
echo '<br />';
// Prikaz grafa rezultatov v zakljucku
echo '<span class="nastavitveSpan1" >'.$lang['srv_quiz_results_chart'].':</span>';
echo '<label for="quiz_results_chart_0"><input type="radio" name="quiz_results_chart" id="quiz_results_chart_0" value="0" '.(($settings['results_chart'] == 0) ? ' checked="checked" ' : '').' />'.$lang['no1'].'</label>';
echo '<label for="quiz_results_chart_1"><input type="radio" name="quiz_results_chart" id="quiz_results_chart_1" value="1" '.(($settings['results_chart'] == 1) ? ' checked="checked" ' : '').' />'.$lang['yes'].'</label>';
echo '<br /><br />';
echo '</fieldset>';
// Gumb shrani
echo '<br class="clr" />';
echo '<span class="floatLeft spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_orange btn_savesettings" href="#" onclick="quiz_save_settings(); return false;"><span>';
echo $lang['edit1337'] . '</span></a></div></span>';
echo '<div class="clr"></div>';
echo '<div id="success_save"></div>'; */
}
// Pridobimo trenutne nastavitve kviza za anketo
public function getSettings(){
$settings = array();
// Default vrednosti
/* $settings['results'] = '1';
$settings['results_chart'] = '0';
$sql = sisplet_query("SELECT * FROM srv_quiz_settings WHERE ank_id='".$this->anketa."'");
if(mysqli_num_rows($sql) > 0){
$row = mysqli_fetch_array($sql);
$settings['results'] = $row['results'];
$settings['results_chart'] = $row['results_chart'];
}*/
return $settings;
}
public function ajax() {
if(isset($_GET['a']) && $_GET['a'] == 'save_settings'){
/*$results = isset($_POST['results']) ? $_POST['results'] : '';
$results_chart = isset($_POST['results_chart']) ? $_POST['results_chart'] : '0';
$sql = sisplet_query("INSERT INTO srv_quiz_settings
(ank_id, results, results_chart) VALUES ('".$this->anketa."', '".$results."', '".$results_chart."')
ON DUPLICATE KEY UPDATE results='".$results."', results_chart='".$results_chart."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);*/
}
}
}

12
composer.lock generated
View File

@ -257,16 +257,16 @@
},
{
"name": "guzzlehttp/promises",
"version": "1.4.0",
"version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "60d379c243457e073cff02bc323a2a86cb355631"
"reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/60d379c243457e073cff02bc323a2a86cb355631",
"reference": "60d379c243457e073cff02bc323a2a86cb355631",
"url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d",
"reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d",
"shasum": ""
},
"require": {
@ -304,7 +304,7 @@
"keywords": [
"promise"
],
"time": "2020-09-30 07:37:28"
"time": "2021-03-07 09:25:29"
},
{
"name": "guzzlehttp/psr7",
@ -2261,7 +2261,7 @@
},
{
"name": "symfony/var-dumper",
"version": "v4.4.19",
"version": "v4.4.20",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",

View File

@ -74,6 +74,7 @@ class UserAccess{
'uporabnost' => 3, // Evalvacija strani (split screen)
//'vnos' => 2, // Vnos vprasalnikov
'kviz' => 2, // Kviz
'voting' => 3, // Volitve
'social_network' => 3, // Socialna omrezja
'slideshow' => 3, // Prezentacija
'telephone' => 3, // Telefonska anketa

View File

@ -3034,6 +3034,7 @@ $lang = array (
"srv_vrsta_survey_type_15" => "Panel",
"srv_vrsta_survey_type_16" => "Napredni parapodatki",
"srv_vrsta_survey_type_17" => "JSON izvoz ankete",
"srv_vrsta_survey_type_18" => "Volitve",
"srv_vrsta_survey_with_pool" => "Dodajanje glasovanja",
"srv_vrsta_survey_with_form" => "Dodajanje forme",
"srv_vrsta_survey_with_conditions" => "Dodajanje pogojev",
@ -3108,6 +3109,7 @@ $lang = array (
"srv_kviz_interpretacije" => "Razli&#269;ne interpretacije",
"srv_zakljucek_vprasalnika" => "Zaklju&#269;ek vpra&#353;alnika",
"srv_kviz_konec_note" => "&#268;e ni izbrana nobena opcija, vidi rezultate samo administrator",
"srv_voting" => "Volitve",
"srv_advanced_paradata" => "Napredni parapodatki",
"srv_advanced_paradata_collect_post_time" => "Beleži \"post time\"",
"srv_json_survey_export" => "JSON izvoz ankete",

View File

@ -3010,6 +3010,7 @@ $lang = array (
"srv_vrsta_survey_type_15" => "Panel",
"srv_vrsta_survey_type_16" => "Advanced paradata",
"srv_vrsta_survey_type_17" => "JSON survey export",
"srv_vrsta_survey_type_18" => "Voting",
"srv_vrsta_survey_with_pool" => "Add vote",
"srv_vrsta_survey_with_form" => "Add Form",
"srv_vrsta_survey_with_conditions" => "Add conditions",
@ -3080,6 +3081,7 @@ $lang = array (
"srv_kviz_interpretacije" => "Different interpretations",
"srv_zakljucek_vprasalnika" => "Survey end",
"srv_kviz_konec_note" => "If no option is selected, only administrator can view results",
"srv_voting" => "Voting",
"srv_advanced_paradata" => "Advanced paradata",
"srv_advanced_paradata_collect_post_time" => "Collect \"post time\"",
"srv_json_survey_export" => "JSON survey export",

View File

@ -7561,6 +7561,10 @@ span.module_icon.quiz::before {
content: "Q";
}
span.module_icon.voting::before {
content: "VOTE";
}
span.module_icon.advanced_paradata::before {
content: "AP";
}

View File

@ -48,6 +48,9 @@ span.module_icon.social::before{
span.module_icon.quiz::before{
content: "Q";
}
span.module_icon.voting::before{
content: "VOTE";
}
span.module_icon.advanced_paradata::before{
content: "AP";
}

View File

@ -999,6 +999,7 @@ return array(
'SurveyUserSetting' => $baseDir . '/admin/survey/classes/class.SurveyUserSetting.php',
'SurveyVariablesProfiles' => $baseDir . '/admin/survey/classes/class.SurveyVariablesProfiles.php',
'SurveyVizualizacija' => $baseDir . '/admin/survey/modules/mod_vizualizacija/class.SurveyVizualizacija.php',
'SurveyVoting' => $baseDir . '/admin/survey/modules/mod_voting/class.SurveyVoting.php',
'SurveyZankaProfiles' => $baseDir . '/admin/survey/classes/class.SurveyZankaProfiles.php',
'SurveyZoom' => $baseDir . '/admin/survey/classes/class.SurveyZoom.php',
'Symfony\\Polyfill\\Intl\\Idn\\Idn' => $vendorDir . '/symfony/polyfill-intl-idn/Idn.php',

View File

@ -11,8 +11,8 @@ return array(
'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php',
'3109cb1a231dcd04bee1f9f620d46975' => $vendorDir . '/paragonie/sodium_compat/autoload.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'f598d06aa772fa33d905e87be6398fb1' => $vendorDir . '/symfony/polyfill-intl-idn/bootstrap.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'2bf0564df058fbe21b5554296cc8571a' => $baseDir . '/main/survey/class.EvalvacijaMain.php',
'5bc35216aa4f6cb823ce4a5cec52fdce' => $baseDir . '/main/survey/mobile-detect/Mobile_Detect.php',

View File

@ -12,8 +12,8 @@ class ComposerStaticInit6b03163c371c5541881b55b762b8c779
'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php',
'3109cb1a231dcd04bee1f9f620d46975' => __DIR__ . '/..' . '/paragonie/sodium_compat/autoload.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'f598d06aa772fa33d905e87be6398fb1' => __DIR__ . '/..' . '/symfony/polyfill-intl-idn/bootstrap.php',
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'2bf0564df058fbe21b5554296cc8571a' => __DIR__ . '/../..' . '/main/survey/class.EvalvacijaMain.php',
'5bc35216aa4f6cb823ce4a5cec52fdce' => __DIR__ . '/../..' . '/main/survey/mobile-detect/Mobile_Detect.php',
@ -1203,6 +1203,7 @@ class ComposerStaticInit6b03163c371c5541881b55b762b8c779
'SurveyUserSetting' => __DIR__ . '/../..' . '/admin/survey/classes/class.SurveyUserSetting.php',
'SurveyVariablesProfiles' => __DIR__ . '/../..' . '/admin/survey/classes/class.SurveyVariablesProfiles.php',
'SurveyVizualizacija' => __DIR__ . '/../..' . '/admin/survey/modules/mod_vizualizacija/class.SurveyVizualizacija.php',
'SurveyVoting' => __DIR__ . '/../..' . '/admin/survey/modules/mod_voting/class.SurveyVoting.php',
'SurveyZankaProfiles' => __DIR__ . '/../..' . '/admin/survey/classes/class.SurveyZankaProfiles.php',
'SurveyZoom' => __DIR__ . '/../..' . '/admin/survey/classes/class.SurveyZoom.php',
'Symfony\\Polyfill\\Intl\\Idn\\Idn' => __DIR__ . '/..' . '/symfony/polyfill-intl-idn/Idn.php',

View File

@ -1204,59 +1204,6 @@
"url"
]
},
{
"name": "guzzlehttp/promises",
"version": "1.4.0",
"version_normalized": "1.4.0.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "60d379c243457e073cff02bc323a2a86cb355631"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/60d379c243457e073cff02bc323a2a86cb355631",
"reference": "60d379c243457e073cff02bc323a2a86cb355631",
"shasum": ""
},
"require": {
"php": ">=5.5"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.4 || ^5.1"
},
"time": "2020-09-30 07:37:28",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
]
},
{
"name": "symfony/polyfill-php72",
"version": "v1.22.1",
@ -1961,5 +1908,58 @@
"rest",
"sdk"
]
},
{
"name": "guzzlehttp/promises",
"version": "1.4.1",
"version_normalized": "1.4.1.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d",
"reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d",
"shasum": ""
},
"require": {
"php": ">=5.5"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.4 || ^5.1"
},
"time": "2021-03-07 09:25:29",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
]
}
]

View File

@ -1,88 +0,0 @@
<?php
$config = PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['operators' => ['=>' => null]],
'blank_line_after_opening_tag' => true,
'class_attributes_separation' => ['elements' => ['method']],
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'declare_strict_types' => false,
'dir_constant' => true,
'final_static_access' => true,
'fully_qualified_strict_types' => true,
'function_to_constant' => true,
'function_typehint_space' => true,
'header_comment' => false,
'is_null' => ['use_yoda_style' => false],
'list_syntax' => ['syntax' => 'short'],
'lowercase_cast' => true,
'magic_method_casing' => true,
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
//'native_constant_invocation' => true,
'no_alias_functions' => true,
'no_alternative_syntax' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_spaces_around_offset' => true,
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'no_trailing_comma_in_singleline_array' => true,
'no_unneeded_control_parentheses' => true,
'no_unset_cast' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'ordered_imports' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => ['target' => 'newest'],
'php_unit_dedicate_assert_internal_type' => ['target' => 'newest'],
'php_unit_expectation' => ['target' => 'newest'],
'php_unit_mock' => ['target' => 'newest'],
'php_unit_mock_short_will_return' => true,
'php_unit_no_expectation_annotation' => ['target' => 'newest'],
'php_unit_test_annotation' => ['style' => 'prefix'],
//'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'phpdoc_align' => ['align' => 'vertical'],
//'phpdoc_line_span' => ['method' => 'multi', 'property' => 'multi'],
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'phpdoc_var_without_name' => true,
'return_assignment' => true,
'short_scalar_cast' => true,
'single_trait_insert_per_statement' => true,
'standardize_not_equals' => true,
//'static_lambda' => true,
'ternary_to_null_coalescing' => true,
'trim_array_spaces' => true,
'visibility_required' => true,
'yoda_style' => false,
// 'native_function_invocation' => true,
'braces' => ['allow_single_line_closure'=>true],
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
->name('*.php')
)
;
return $config;

View File

@ -1,5 +1,8 @@
# CHANGELOG
## 1.4.1 - 2021-02-18
- Fixed `each_limit` skipping promises and failing
## 1.4.0 - 2020-09-30

View File

@ -1,7 +0,0 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$function of function register_shutdown_function expects callable\\(\\)\\: void, Closure\\(\\)\\: mixed given\\.$#"
count: 1
path: src/TaskQueue.php

View File

@ -1,10 +0,0 @@
includes:
- phpstan-baseline.neon
parameters:
level: 5
paths:
- src
ignoreErrors:
- "#^Dead catch - Exception is already caught by Throwable above\\.$#"

View File

@ -1,15 +0,0 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>

View File

@ -10,6 +10,8 @@ class EachPromise implements PromisorInterface
{
private $pending = [];
private $nextPendingIndex = 0;
/** @var \Iterator|null */
private $iterable;
@ -121,6 +123,7 @@ class EachPromise implements PromisorInterface
$clearFn = function () {
$this->iterable = $this->concurrency = $this->pending = null;
$this->onFulfilled = $this->onRejected = null;
$this->nextPendingIndex = 0;
};
$this->aggregate->then($clearFn, $clearFn);
@ -163,11 +166,9 @@ class EachPromise implements PromisorInterface
$promise = Create::promiseFor($this->iterable->current());
$key = $this->iterable->key();
// Iterable keys may not be unique, so we add the promises at the end
// of the pending array and retrieve the array index being used
$this->pending[] = null;
end($this->pending);
$idx = key($this->pending);
// Iterable keys may not be unique, so we use a counter to
// guarantee uniqueness
$idx = $this->nextPendingIndex++;
$this->pending[$idx] = $promise->then(
function ($value) use ($idx, $key) {