Closed jelleroorda closed 3 years ago
Thanks for the report!
I think I will adjust the default behavior of custom/unknown items so that the behavior is less obnoxious by default. It's pulling the return type of modifier to it's left (string), and comparing it to the known list of input types for the current modifier sanitize_fixed
. If it doesn't have any information on those types, it assumes void
at the moment.
If you see a .antlers.json
file at the root of your project, that means the PHP analyzer is working on your project. If so, you can use IDE hints in your PHP comment's to let the Antlers language server know about your custom input/return types:
https://antlers.dev/docs/php-tag-ide-hints#specifying-parameter-input-variable-types
For modifiers, these would go on the modifier's class docblock instead of the method. The language server looks for different docblock properties to not conflict with any future behavior of Statamic (@input
identifies input to tags and modifiers, and @returns
specifies the possible return types):
<?php
namespace App\Modifiers;
use Statamic\Facades\Config;
use Statamic\Modifiers\Modifier;
/**
* @input string value The value to sanitize.
* @returns string
*/
class SanitizeFixed extends Modifier
{
}
Even though nothing is being supplied to the modifier? See the error here:
Modifier:
Thanks for the awesome extension!