Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow File Reference injection via meta php #25

Open
King2500 opened this issue Feb 28, 2020 · 1 comment
Open

Allow File Reference injection via meta php #25

King2500 opened this issue Feb 28, 2020 · 1 comment
Labels

Comments

@King2500
Copy link
Owner

King2500 commented Feb 28, 2020

.phpstorm.meta.php:

<?php
namespace PHPSTORM_META {
    xAdvancedInjectFileReference(\My\Stuff\Example::dump(), 1);  // relative to doc root or current file (see below)
    xAdvancedInjectFileReference(\My\Stuff\Example::dump(), 1, '/'); // relative to doc root
    xAdvancedInjectFileReference(\My\Stuff\Example::dump(), 1, '.'); // relative to current file
    xAdvancedInjectFileReference(\My\Stuff\Example::dump(), 1, '/dir'); // relative to /dir/
}

User code:

$x = new Example();
$x->dump('bla', '<ref>path/to/file.ext</ref>');

If inside class always go relative from doc root.
If not inside class always go relative from current file.

Plugin's built-in .phpstorm.meta.php:

<?php
namespace PHPSTORM_META {
    function xAdvancedInjectFileReference($functionReference, $argumentIndex, $relativeMode = null) {
        return "xAdvancedInjectFileReference " . $functionReference . " at " . $argumentIndex . ": " . $relativeMode;
    }

    registerArgumentsSet('x_advanced_fileref_relative_modes', '/', '.');
    expectedArguments(\PHPSTORM_META\xAdvancedInjectFileReference(), 2, argumentsSet('x_advanced_fileref_relative_modes');
}
@King2500
Copy link
Owner Author

Open:

xAdvancedInjectFileReference(\My\Stuff\Example::dump(), 1, '/dir'); // relative to /dir/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant