chore: une passe de rector UP_TO_PHP_74

à voir s'il ne faudra pas revenir sur les `JSON_THROW_ON_ERROR` pour les passer dans des try/catch
pull/54/head
b_b 8 months ago committed by Gitea
parent edf3917cab
commit 544d64f93a

@ -8,7 +8,7 @@ if (!defined('_ECRIRE_INC_VERSION')) {
function action_editer_lien_gis_dist() {
$securiser_action = charger_fonction('securiser_action', 'inc');
$arg = $securiser_action();
list($action,$id_gis, $objet, $id_objet) = explode('/', $arg);
[$action, $id_gis, $objet, $id_objet] = explode('/', $arg);
include_spip('inc/autoriser');
if (intval($id_gis) and autoriser('lier', 'gis', $id_gis, $GLOBALS['visiteur_session'], ['objet' => $objet,'id_objet' => $id_objet])) {

@ -23,7 +23,8 @@ function action_kml_infos_dist() {
}
function action_kml_infos_post($r) {
list(, $sign, $id_objet, $objet, $id_document, $suite) = $r;
$config = [];
[, $sign, $id_objet, $objet, $id_document, $suite] = $r;
if (intval($id_document)) {
$recuperer_info = charger_fonction('kml_infos', 'inc');
@ -55,7 +56,7 @@ function action_kml_infos_post($r) {
}
unset($infos['longitude']);
unset($infos['latitude']);
if (count($infos) > 0) {
if ((is_countable($infos) ? count($infos) : 0) > 0) {
include_spip('action/editer_document');
document_modifier($id_document, $infos);
}

@ -10,7 +10,7 @@ function action_supprimer_gis_dist() {
$securiser_action = charger_fonction('securiser_action', 'inc');
$arg = $securiser_action();
list($id_gis) = preg_split(',[^0-9],', $arg);
[$id_gis] = preg_split(',[^0-9],', $arg);
include_spip('inc/autoriser');
if (intval($id_gis) and autoriser('supprimer', 'gis', $id_gis)) {
include_spip('action/editer_gis');

@ -20,6 +20,7 @@ include_spip('inc/editer');
* @param string $recherche
*/
function formulaires_rechercher_gis_charger_dist($objet = '', $id_objet = '', $retour = '', $recherche = '') {
$valeurs = [];
$valeurs['recherche_gis'] = _request('recherche_gis');
$valeurs['objet'] = $objet;
$valeurs['id_objet'] = $id_objet;

@ -139,7 +139,7 @@ function critere_distancefrom_dist($idb, &$boucles, $crit) {
if (
($id_table == 'gis' or isset($boucle->join['gis'])) // Soit depuis une boucle (GIS) soit un autre objet mais avec {gis}
and count($crit->param) == 3 // Il faut aussi qu'il y ait 3 critères obligatoires
and (is_countable($crit->param) ? count($crit->param) : 0) == 3 // Il faut aussi qu'il y ait 3 critères obligatoires
) {
$point_reference = calculer_liste($crit->param[0], [], $boucles, $boucles[$idb]->id_parent);
$operateur = calculer_liste($crit->param[1], [], $boucles, $boucles[$idb]->id_parent);
@ -494,26 +494,26 @@ function gis_icon_properties($img = '') {
}
if ($icon) {
$props .= ",\n\t\t\t\"icon\": " . json_encode(url_absolue($icon)) . ',';
list($h,$w) = taille_image($icon);
$props .= "\n\t\t\t\"icon_size\": " . json_encode([$w,$h]) . ',';
$props .= ",\n\t\t\t\"icon\": " . json_encode(url_absolue($icon), JSON_THROW_ON_ERROR) . ',';
[$h, $w] = taille_image($icon);
$props .= "\n\t\t\t\"icon_size\": " . json_encode([$w,$h], JSON_THROW_ON_ERROR) . ',';
/**
* Si l'icone est carrée, on considère que c'est soit un point soit un carré qui pointe un lieu et non une "goutte"
* On centre donc au milieu de l'icone
*/
if ($w == $h) {
$props .= "\n\t\t\t\"icon_anchor\": " . json_encode([$w / 2, $h / 2]) . ',';
$props .= "\n\t\t\t\"icon_anchor\": " . json_encode([$w / 2, $h / 2], JSON_THROW_ON_ERROR) . ',';
$props .= "\n\t\t\t\"popup_anchor\": " . json_encode([0,0]);
} else {
$props .= "\n\t\t\t\"icon_anchor\": " . json_encode([$w / 2, $h]) . ',';
$props .= "\n\t\t\t\"popup_anchor\": " . json_encode([1, -round($h / 1.2, 2)]);
$props .= "\n\t\t\t\"icon_anchor\": " . json_encode([$w / 2, $h], JSON_THROW_ON_ERROR) . ',';
$props .= "\n\t\t\t\"popup_anchor\": " . json_encode([1, -round($h / 1.2, 2)], JSON_THROW_ON_ERROR);
}
}
if ($shadow = find_in_path('images/marker_defaut_shadow.png')) {
$props .= ",\n\t\t\t\"shadow\": " . json_encode(url_absolue($shadow));
list($h,$w) = taille_image($shadow);
$props .= ",\n\t\t\t\"shadow_size\": " . json_encode([$w,$h]);
$props .= ",\n\t\t\t\"shadow\": " . json_encode(url_absolue($shadow), JSON_THROW_ON_ERROR);
[$h, $w] = taille_image($shadow);
$props .= ",\n\t\t\t\"shadow_size\": " . json_encode([$w,$h], JSON_THROW_ON_ERROR);
}
return $props;
@ -548,23 +548,24 @@ if (!defined('_TAILLE_MAX_GIS_STATIC')) {
**/
function gis_static_map($id_gis, $width, $height, $maptype = false, $zoom = null, $markers = null, $lat = 0, $lon = 0) {
$markers_ = [];
$gis = [];
if ($id_gis) {
$gis = sql_fetsel('lat,lon,zoom', 'spip_gis', 'id_gis=' . intval($id_gis));
}
$zoom = isset($zoom) ? $zoom : $gis['zoom'];
$zoom ??= $gis['zoom'];
$lat = isset($gis['lat']) ? $gis['lat'] : $lat;
$lon = isset($gis['lon']) ? $gis['lon'] : $lon;
$lat = $gis['lat'] ?? $lat;
$lon = $gis['lon'] ?? $lon;
if (intval($id_gis) and !$markers) {
$markers_[] = ['lat' => (float) $lat, 'lon' => (float) $lon];
} else {
$markers = explode('|', $markers);
foreach ($markers as $marker) {
list($markerLat, $markerLon, $markerUrl) = explode(';', $marker);
[$markerLat, $markerLon, $markerUrl] = explode(';', $marker);
$markers_[] = ['lat' => (float) $markerLat, 'lon' => (float) $markerLon, 'url' => $markerUrl];
}
}

@ -40,7 +40,7 @@ function gis_insert_head($flux) {
// insertion des scripts pour google si nécessaire
if (count(array_intersect(['google_roadmap', 'google_satellite', 'google_terrain'], $config['layers'])) > 0) {
$flux .= "\n" . '<script type="text/javascript" src="//maps.google.com/maps/api/js?language=' . $GLOBALS['spip_lang'] . '&amp;key=' . (isset($config['api_key_google']) ? $config['api_key_google'] : '') . '"></script>';
$flux .= "\n" . '<script type="text/javascript" src="//maps.google.com/maps/api/js?language=' . $GLOBALS['spip_lang'] . '&amp;key=' . ($config['api_key_google'] ?? '') . '"></script>';
}
return $flux;
@ -151,7 +151,7 @@ function gis_post_edition($flux) {
'lat' => $latitude,
'lon' => $longitude
]);
$geocoder = json_decode($json, true);
$geocoder = json_decode($json, true, 512, JSON_THROW_ON_ERROR);
if (is_array($geocoder)) {
$pays = $geocoder['address']['country'];
$code_pays = $geocoder['address']['country_code'];
@ -196,7 +196,7 @@ function gis_post_edition($flux) {
'accept-language' => $GLOBALS['meta']['langue_site'],
'q' => $string_recherche
]);
$geocoder = json_decode($json, true);
$geocoder = json_decode($json, true, 512, JSON_THROW_ON_ERROR);
if (is_array($geocoder[0])) {
$latitude = $geocoder[0]['lat'];
$longitude = $geocoder[0]['lon'];
@ -277,7 +277,7 @@ function gis_post_edition($flux) {
}
unset($infos['longitude']);
unset($infos['latitude']);
if (count($infos) > 0) {
if ((is_countable($infos) ? count($infos) : 0) > 0) {
include_spip('action/editer_document');
document_modifier($id_document, $infos);
}

@ -20,6 +20,7 @@ if (!defined('_ECRIRE_INC_VERSION')) {
* -* limite int : le nombre d'éléments maximum à retourner
*/
function spip_liste_gis($args) {
$what = [];
global $spip_xmlrpc_serveur;
if (!$spip_xmlrpc_serveur) {
@ -54,7 +55,7 @@ function spip_liste_gis($args) {
*/
if (is_string($args['recherche']) and strlen($args['recherche']) > 3) {
$prepare_recherche = charger_fonction('prepare_recherche', 'inc');
list($rech_select, $rech_where) = $prepare_recherche($args['recherche'], $objet . 's', $where);
[$rech_select, $rech_where] = $prepare_recherche($args['recherche'], $objet . 's', $where);
$what[] = $rech_select;
$from .= ' INNER JOIN spip_resultats AS resultats ON ( resultats.id = gis.id_gis ) ';
$where[] = 'resultats.' . $rech_where;
@ -90,6 +91,8 @@ function spip_liste_gis($args) {
* -* lon : si disponible avec lat, on ajoute la distance dans les infos
*/
function spip_lire_gis($args) {
$what = [];
$wkt = null;
global $spip_xmlrpc_serveur;
if (!$spip_xmlrpc_serveur) {

@ -42,9 +42,9 @@ class class_IPTC
/* VARIABLES statics */
var $h_codesIptc; /* $h_codesIptc : (tableau associatif) contient les codes des champs IPTC associés à un libellé */
var $h_cheminImg; /* $h_cheminImg : (chaine) contient le chemin complet du fichier d'image */
var $h_iptcData; /* $h_iptcData : (chaine) contient les données encodées de l'iptc de l'image */
public $h_codesIptc; /* $h_codesIptc : (tableau associatif) contient les codes des champs IPTC associés à un libellé */
public $h_cheminImg; /* $h_cheminImg : (chaine) contient le chemin complet du fichier d'image */
public $h_iptcData; /* $h_iptcData : (chaine) contient les données encodées de l'iptc de l'image */
/* FIN VARIABLES statics
@ -215,6 +215,7 @@ FIN INFOS SUR LA FONCTION */
function fct_ecrireIPTC($tblIPTC_util, $cheminImgAModifier = "")
{
$iptcData_new = null;
// La tableau devant contenir des IPTC est vide ou n'est pas un tableau associatif
if( (empty($tblIPTC_util)) || (!is_array($tblIPTC_util)) ) return false;

@ -128,7 +128,7 @@ function inc_kml_infos($id_document) {
if (!$infos['titre'] or ($infos['titre'] == basename($chemin)) or (preg_match(',\.km.,', $infos['titre']) > 0)) {
$folders = [];
spip_xml_match_nodes(',^Folder,', $arbre, $folders);
if (count($folders['Folder']) == 1) {
if ((is_countable($folders['Folder']) ? count($folders['Folder']) : 0) == 1) {
foreach ($folders['Folder'] as $dossier) {
if ($dossier['name'][0]) {
$infos['titre'] = $dossier['name'][0];
@ -141,9 +141,9 @@ function inc_kml_infos($id_document) {
if (!is_array($placemarks)) {
spip_xml_match_nodes(',^Placemark,', $arbre, $placemarks);
}
if (count($placemarks) == 1) {
if (count((array) $placemarks) == 1) {
foreach ($placemarks as $places) {
if (count($places) == 1) {
if ((is_countable($places) ? count($places) : 0) == 1) {
foreach ($places as $lieu) {
if ($lieu['name'][0]) {
$infos['titre'] = $lieu['name'][0];

@ -168,11 +168,11 @@ class staticMapGis
}
public function lonToTile($long, $zoom) {
return (($long + 180) / 360) * pow(2, $zoom);
return (($long + 180) / 360) * 2 ** $zoom;
}
public function latToTile($lat, $zoom) {
return (1 - log(tan($lat * pi() / 180) + 1 / cos($lat * pi() / 180)) / pi()) / 2 * pow(2, $zoom);
return (1 - log(tan($lat * pi() / 180) + 1 / cos($lat * pi() / 180)) / pi()) / 2 * 2 ** $zoom;
}
public function latLngToPixels($lat, $lon, $zoom) {
@ -270,14 +270,14 @@ class staticMapGis
// set some local variables
$markerLat = $marker['lat'];
$markerLon = $marker['lon'];
$markerUrl = isset($marker['url']) ? $marker['url'] : '';
$markerUrl = $marker['url'] ?? '';
// clear variables from previous loops
$markerShadow = false;
// marker perso ou par défaut ?
if ($markerUrl) {
include_spip('inc/distant');
$markerPath = copie_locale($markerUrl);
list($h,$w) = taille_image($markerPath);
[$h, $w] = taille_image($markerPath);
$markerOffsetX = -$w / 2;
$markerOffsetY = -$h;
} else {
@ -394,12 +394,12 @@ class staticMapGis
}
public function makeMap() {
if (count($this->markers)) {
if (is_countable($this->markers) ? count($this->markers) : 0) {
$this->getBoundsZoom();
}
$this->initCoords();
$this->createBaseMap();
if (count($this->markers)) {
if (is_countable($this->markers) ? count($this->markers) : 0) {
$this->placeMarkers();
}
$this->copyrightNotice();

Loading…
Cancel
Save