Thread: Using PhpStorm

Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,571
    Plugin Contributions
    30

    Default Using PhpStorm

    The inspections in PhpStorm flag up constants that it cannot find, such as those in the database, as errors.

    As far as I can tell, the only way to stop these errors is to have the database constants (configuration_keys) duplicated in a file that PhpStorm CAN find/index.

    So I did a script that generates a suitable file:
    https://github.com/torvista/zen-cart...tion-constants

    Constructive criticism welcome!
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  2. #2
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Using PhpStorm

    Great idea.

    As for naming convention, I have both my .gitignore and my FTP app set to ignore all "dev-*.php" files, so that they aren't committed to VCS nor uploaded to servers.
    Alternatively, other utility tools often use underscore prefixes, for example one of them is: _ide_helper.php
    (I avoid using dot-prefixed files for semi-sensitive things like this, just in case I accidentally ignore them because they're hidden-by-default.)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,571
    Plugin Contributions
    30

    Default Re: Using PhpStorm

    Is there any way to get these sql inspections to work, instead of switching them off?
    Name:  Clipboard01.gif
Views: 1628
Size:  18.6 KB
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  4. #4
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Using PhpStorm

    Quote Originally Posted by torvista View Post
    Is there any way to get these sql inspections to work, instead of switching them off?
    Name:  Clipboard01.gif
Views: 1628
Size:  18.6 KB
    I haven't tried it in a while, but supposedly if a connection to a database was made, then those type of notifications would go away. I found this related to making that connection: https://www.jetbrains.com/help/phpst...-database.html

    Last time I tried to do this a couple of years ago I ran into some sort of issue that I'm sure was my fault or doing.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,571
    Plugin Contributions
    30

    Default Re: Using PhpStorm

    The problem is not the database connection (that is working ok), but that PhpStorm cannot read/substitute the database constants in those queries for the constant definitions in
    includes/database_tables.php with the DB_PREFIX.

    So, this does not work:
    define('TABLE_PRODUCTS', DB_PREFIX . 'products');

    but this does work (clears the error)
    define('TABLE_PRODUCTS', 'products');

    web searches indicate this is not possible, I was just wondering if anyone had found a way to make it work without changing includes/database_tables.php.
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  6. #6
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,571
    Plugin Contributions
    30

    Default Re: Using PhpStorm

    There is a PHP inspection plugin for Phpstorm called EA Extended: another world of php nitpicking to spend endless hours with, but the principal things it spits out are

    recommending strict comparisons when possible.
    ie.
    if ($action == 'edit')...
    to
    if ($action === 'edit')...

    and using single quotes around sql text chunks

    As there are so many of them to initially correct, it's hard to see any real issues (can't see the wood for the trees).

    For ongoing code/PR submissions, should I "correct" these things or ignore them?
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  7. #7
    Join Date
    Jan 2007
    Posts
    1,484
    Plugin Contributions
    10

    Default Re: Using PhpStorm

    Quote Originally Posted by torvista View Post
    The problem is not the database connection (that is working ok), but that PhpStorm cannot read/substitute the database constants in those queries for the constant definitions in
    includes/database_tables.php with the DB_PREFIX.

    So, this does not work:
    define('TABLE_PRODUCTS', DB_PREFIX . 'products');

    but this does work (clears the error)
    define('TABLE_PRODUCTS', 'products');

    web searches indicate this is not possible, I was just wondering if anyone had found a way to make it work without changing includes/database_tables.php.

    Did you ever find a workaround? I have modified includes/database_tables on my local install to avoid the issue.

    Zen Cart and it's community are the best!!

  8. #8
    Join Date
    Jan 2007
    Posts
    1,484
    Plugin Contributions
    10

    Default Re: Using PhpStorm

    Quote Originally Posted by torvista View Post
    There is a PHP inspection plugin for Phpstorm called EA Extended: another world of php nitpicking to spend endless hours with, but the principal things it spits out are

    recommending strict comparisons when possible.
    ie.
    if ($action == 'edit')...
    to
    if ($action === 'edit')...

    and using single quotes around sql text chunks

    As there are so many of them to initially correct, it's hard to see any real issues (can't see the wood for the trees).

    For ongoing code/PR submissions, should I "correct" these things or ignore them?
    I'll have to install that, thanks for pointing it out. I think it's important moving forward to future-proof so think making the changes as the code is being worked on would be the best way. That's what I've been doing, and the amount of warnings when the log all errors mod is on is steadily shrinking.

    Zen Cart and it's community are the best!!

  9. #9
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,571
    Plugin Contributions
    30

    Default Re: Using PhpStorm

    Did you ever find a workaround?
    No. I did the same.
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  10. #10
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,571
    Plugin Contributions
    30

    Default Re: Using PhpStorm

    To prevent php inspection flagging up multiple errors as "undefined variables" for uses of messagestack and zco_notifier, you can add this to the start of the file you are working on, temporarily:

    /**
    * @var messageStack $messageStack
    * @var zcObserverLogEventListener $zco_notifier
    */

    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v138a Requiring account creation using when using Paypal Express?
    By Zeebra in forum PayPal Express Checkout support
    Replies: 6
    Last Post: 28 Oct 2013, 10:59 PM
  2. Using % in text
    By FukienMan in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 9 Nov 2011, 03:31 AM
  3. Using prettyPhoto???
    By DPeaGreenDesigns in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 28 Jun 2010, 12:40 PM
  4. Replies: 1
    Last Post: 24 May 2009, 05:36 AM
  5. using zc_install
    By d1gitalconcepts in forum Installing on a Linux/Unix Server
    Replies: 11
    Last Post: 20 Jul 2006, 04:07 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR