Coder Social home page Coder Social logo

thefrosty / wp-utilities Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 2.0 321 KB

A library containing my standard development resources for bootsrapping WordPress plugins.

Home Page: https://austin.passy.co/wordpress-plugins/

PHP 93.10% Shell 5.76% JavaScript 1.15%
wordpress utilities packagist wordpress-php-library php wordpress-utilities wp-utilities php81

wp-utilities's Introduction

Frosty's WordPress Utilities

WP Utilities

PHP from Packagist Latest Stable Version Total Downloads License Build Status codecov Donate with $DOGE

A library containing my standard development resources to build high quality WordPress plugins.

Requirements

PHP >= 8.1
WordPress >= 6.1
PHP version WP Utilities
< 7.1 1.3.x
>= 7.1 && < 7.3 1.9.x
7.3 2.0.0
>= 7.4 2.1.0
>= 8.0 3.0
>= 8.1 3.3

The required WordPress version will always be the most recent point release of the previous major release branch.

For both PHP and WordPress requirements, although this library may work with a version below the required versions, they will not be supported and any compatibility is entirely coincidental.

Installation

To install this library, use Composer:

composer require thefrosty/wp-utilities:^3.3

Then follow examples in the Plugin README

wp-utilities's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar szepeviktor avatar thefrosty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wp-utilities's Issues

Psr/Container: Psr11\ServiceLocator version 2 error

Fatal error: Declaration of Pimple\Psr11\ServiceLocator::has($id) must be compatible with Psr\Container\ContainerInterface::has(string $id): bool in /srv/users/serverpilot/apps/frosty-web-designs/public/wp-content/plugins/satispress/vendor/pimple/pimple/src/Pimple/Psr11/ServiceLocator.php on line 71

PHP8 Fatal error: Declaration must be compatible

PHP Fatal error:  Declaration of Pimple\Psr11\ServiceLocator::get(string $id) 
must be compatible with Psr\Container\ContainerInterface::get($id) in 
/.../plugins/wp-debug-log-widget/vendor/pimple/pimple/src/Pimple/Psr11/ServiceLocator.php on line 59
PHP Fatal error:  Declaration of TheFrosty\WpUtilities\Plugin\Container::get(string $id) 
must be compatible with Psr\Container\ContainerInterface::get($id) in 
/.../plugins/wp-login-locker/vendor/thefrosty/wp-utilities/src/Plugin/Container.php on line 23

PHP 8.2: Errors in PHPStan Runner

See https://github.com/thefrosty/wp-utilities/actions/runs/4950330475/jobs/8853791217?pr=115


  Line   PostTypes/AbstractPostType.php                                        
 ------ ---------------------------------------------------------------------- 
  62     Method                                                                
         TheFrosty\WpUtilities\PostTypes\AbstractPostType::registerPostType()  
         has invalid return type PostTypes\PostType.                           
  62     Method                                                                
         TheFrosty\WpUtilities\PostTypes\AbstractPostType::registerPostType()  
         has invalid return type PostTypes\PostType.                           
  64     Instantiated class PostTypes\PostType not found.                      
         ๐Ÿ’ก Learn more at https://phpstan.org/user-guide/discovering-symbols   
  65     Call to method register() on an unknown class PostTypes\PostType.     
         ๐Ÿ’ก Learn more at https://phpstan.org/user-guide/discovering-symbols   
 ------ ---------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------ 
  Line   Taxonomies/AbstractTaxonomy.php                                         
 ------ ------------------------------------------------------------------------ 
  45     PHPDoc tag @throws with type                                            
         TheFrosty\WpUtilities\Exceptions\Exception is not subtype of            
         Throwable                                                               
  48     Instantiated class TheFrosty\WpUtilities\Exceptions\Exception not       
         found.                                                                  
         ๐Ÿ’ก Learn more at https://phpstan.org/user-guide/discovering-symbols     
  48     Throwing object of an unknown class                                     
         TheFrosty\WpUtilities\Exceptions\Exception.                             
         ๐Ÿ’ก Learn more at https://phpstan.org/user-guide/discovering-symbols     
  52     Instantiated class TheFrosty\WpUtilities\Exceptions\Exception not       
         found.                                                                  
         ๐Ÿ’ก Learn more at https://phpstan.org/user-guide/discovering-symbols     
  52     Throwing object of an unknown class                                     
         TheFrosty\WpUtilities\Exceptions\Exception.                             
         ๐Ÿ’ก Learn more at https://phpstan.org/user-guide/discovering-symbols     
  73     Method                                                                  
         TheFrosty\WpUtilities\Taxonomies\AbstractTaxonomy::registerTaxonomy()   
         has invalid return type PostTypes\Taxonomy.                             
  73     Method                                                                  
         TheFrosty\WpUtilities\Taxonomies\AbstractTaxonomy::registerTaxonomy()   
         has invalid return type PostTypes\Taxonomy.                             
  75     Instantiated class PostTypes\Taxonomy not found.                        
         ๐Ÿ’ก Learn more at https://phpstan.org/user-guide/discovering-symbols     
  77     Call to method register() on an unknown class PostTypes\Taxonomy.       
         ๐Ÿ’ก Learn more at https://phpstan.org/user-guide/discovering-symbols     
  140    Parameter $taxonomy of method                                           
         TheFrosty\WpUtilities\Taxonomies\AbstractTaxonomy::registerPostTypes()  
         has invalid type PostTypes\Taxonomy.                                    
  140    Parameter $taxonomy of method                                           
         TheFrosty\WpUtilities\Taxonomies\AbstractTaxonomy::registerPostTypes()  
         has invalid type PostTypes\Taxonomy.                                    
  147    Call to method posttype() on an unknown class PostTypes\Taxonomy.       
         ๐Ÿ’ก Learn more at https://phpstan.org/user-guide/discovering-symbols     
 ------ ------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------ 
  Line   Utils/AbstractSingleton.php                                                   
 ------ ------------------------------------------------------------------------------ 
  24     Unsafe usage of new static().                                                 
         ๐Ÿ’ก See:                                                                       
            https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static  
 ------ ------------------------------------------------------------------------------ 

 ------ ----------------------------------------------------------------------- 
  Line   Utils/View.php                                                         
 ------ ----------------------------------------------------------------------- 
  77     Parameter #1 $args of method TheFrosty\WpUtilities\Utils\View::load()  
         expects array<string, array>, array<int, array|string> given.          
  137    Offset 0 does not exist on array<string, array>.                       
  137    Offset 1 does not exist on array<string, array>.                       
  202    PHPDoc tag @return with type mixed is not subtype of native type       
         void.                                                                  
 ------ ----------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------- 
  Line   WpAdmin/DisablePluginUpdateCheck.php                                
 ------ -------------------------------------------------------------------- 
  49     Result of && is always false.                                       
         ๐Ÿ’ก Because the type is coming from a PHPDoc, you can turn off this  
            check by setting treatPhpDocTypesAsCertain: false in your        
            phpstan.neon.dist.                                               
  52     Strict comparison using === between true and false will always      
         evaluate to false.                                                  
         ๐Ÿ’ก Because the type is coming from a PHPDoc, you can turn off this  
            check by setting treatPhpDocTypesAsCertain: false in your        
            phpstan.neon.dist.                                               
 ------ -------------------------------------------------------------------- 

 -- -------------------------------------------------------------------------- 
     Error                                                                     
 -- -------------------------------------------------------------------------- 
     Ignored error pattern #^Function apply_filters(_ref_array)? invoked with  
     [34567] parameters, 2 required\.$# was not matched in reported errors.    
 -- -------------------------------------------------------------------------- 

Error:  [ERROR] Found 54 errors          

Can't add object with properties

In AbstractPlugin::addOnHook the first parameter is a string (the fully qualified class name) so that the class isn't instantiated earlier than the hook it's needed to be loaded on, but that doesn't allow any properties to be passed to the class if it has dependencies.

Look into an alternative like changing it to an array where the key is the class and the value is an array of properties to inject or possibly a model using the BaseModel class.

This project needs a name

Please give it a name.

Maybe something not beginning with "WordPress". Maybe ending in "for WordPress"

e.g. Frosty Utils for WordPress

Support for adding on condition

Just like addOnHook, maybe add an addOnCondition that a callback can be passed in to add conditional instantiations based on things like class_exits or the like.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.