Skip to content

Instantly share code, notes, and snippets.

@rainder
Last active August 29, 2015 14:04
Show Gist options
  • Save rainder/6a1307aeca209211ef19 to your computer and use it in GitHub Desktop.
Save rainder/6a1307aeca209211ef19 to your computer and use it in GitHub Desktop.
fs = require 'fs'
_ = require 'lodash'
###
* @link http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata
###
wrap = (data) -> """
<?php
/**
* @AUTOGENERATED
* DO NOT EDIT
*/
namespace PHPSTORM_META {
/** @noinspection PhpUnusedLocalVariableInspection */
/** @noinspection PhpIllegalArrayKeyTypeInspection */
$STATIC_METHOD_TYPES = [
\\Doctrine::getTable('') => [
#{data}
],
];
}
"""
generate = (files) ->
_(files)
.filter (name) ->
name.match /Table.class.php$/
.map (name) ->
key = name.replace 'Table.class.php', ''
value = name.replace '.class.php', ''
"'#{key}' instanceof \\#{value}"
.value()
.join(',\n ')
fs.readdir "#{__dirname}/lib/model/doctrine", (err, files) ->
throw err if err
fs.writeFile "#{__dirname}/.phpstorm.meta.php", wrap generate files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment