Relative Content

Tag Archive for phpphpstorm

PhpStorm inspections on __call magic methods without knowing the name of the dynamic functions

The short version of this is, I want phpstorm to know the datatype returned by a dynamic function call that is handled by __call. There is no way to know the name of the dynamic functions reasonably because __call is in my code, a “framework” of sorts, and the dynamic function names are created at runtime by developers using my class. My class will not have access to those names so adding @method wont work. I understand the other developers can add their own annotations, but my question is how to do this without requiring them to do that.

A php script I wrote to produce a CSV file is giving an error – PHP Fatal error: fputcsv(): Argument #2 ($fields) must be of type array

<?php use someapiconnectionPersons; try { require_once(‘autoload.php’); $PersonsAPI = new Persons(); $data = $PersonsAPI->get(); if (!empty($data)) { header(‘Content-Type: text/csv’); header(‘Content-Disposition: attachment;filename=offline_persons.csv’); $fp = fopen(‘php://output’, ‘wb’); fputcsv($fp, array_keys($data)); foreach ($data as $line) { $val = explode(“,”,$line); fputcsv($fp, $line); } fclose($fp); } else { echo “No data found”; } } catch (Exception $e) { echo “Error fetching data: […]