Skip to content

Instantly share code, notes, and snippets.

@ysasaki
Last active January 5, 2016 06:58
Show Gist options
  • Save ysasaki/898ba18e67687a6e6ec5 to your computer and use it in GitHub Desktop.
Save ysasaki/898ba18e67687a6e6ec5 to your computer and use it in GitHub Desktop.
#!/bin/bash
KOHANA_APP_ROOT=${1:-.}
META_FILE=.phpstorm.meta.php
cat > ${META_FILE} <<EOM
<?php
/**
* Used by PhpStorm to map factory methods to classes for code completion, source code analysis, etc.
*
* The code is not ever actually executed and it only needed during development when coding with PhpStorm.
*
* @see http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata
* @see http://blog.jetbrains.com/webide/2013/04/phpstorm-6-0-1-eap-build-129-177/
*/
namespace PHPSTORM_META {
/** @noinspection PhpUnusedLocalVariableInspection */
/** @noinspection PhpIllegalArrayKeyTypeInspection */
\$STATIC_METHOD_TYPES = [
\Model::factory('') => [
EOM
find ${KOHANA_APP_ROOT}/application/classes/Model -type f | \
xargs cat | \
grep class | \
cut -d' ' -f2 | \
perl -F'_' -nale 'shift @F; printf " '\''%s'\'' instanceof \\%s,\n", join("_", @F), $_' >> ${META_FILE}
cat >> ${META_FILE} <<EOM
]
];
}
EOM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment