Comments (6)
After everything is clean and tidy: phpstan.neon.dist
includes:
- vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
# level: max
level: 5
inferPrivatePropertyTypeFromConstructor: true
paths:
- lib/
ignoreErrors:
# Uses func_get_args()
- '#^Function apply_filters(_ref_array)? invoked with [34567] parameters, 2 required\.$#'
[ERROR] Found 74 errors
Will keep you entertained for 2 hours.
from underpin.
wordpress-autoloader.php
<?php
/**
* Autoloader for WordPress.
*
* @package Underpin
* @link https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#naming-conventions
* @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md#class-example
*/
declare( strict_types = 1 );
namespace Underpin;
use function spl_autoload_register;
spl_autoload_register(
/**
* Closure of the autoloader.
*
* @param class-string $class_name The fully-qualified class name.
* @return void
*/
static function ( $class_name ) {
$project_namespace = __NAMESPACE__ . '\\';
$length = strlen( $project_namespace );
// Class is not in our namespace.
if ( 0 !== strncmp( $project_namespace, $class_name, $length ) ) {
return;
}
// E.g. Model\Item
$relative_class_name = substr( $class_name, $length );
// E.g. model/Item.php
$name_parts = explode( '\\', $relative_class_name );
$last_part = array_pop( $name_parts );
$file = sprintf(
'%1$s/lib%2$s/%3$s.php',
__DIR__,
array() === $name_parts ? '' : '/' . strtolower( str_replace( '_', '-', implode( '/', $name_parts ) ) ),
$last_part
);
if ( ! is_file( $file ) ) {
return;
}
require $file;
}
);
from underpin.
We currently have a mix of PSR-4 class file names and WPCS directory names.
- be bold and use PSR-4 everywhere not just in file names (see Rector)
- or be old-bold and use updated WPCS everywhere :) https://make.wordpress.org/core/2020/03/20/updating-the-coding-standards-for-modern-php/
from underpin.
Going further: underpin()->
may be replaced with a DI container
from underpin.
or be old-bold and use updated WPCS everywhere :) https://make.wordpress.org/core/2020/03/20/updating-the-coding-standards-for-modern-php/
Nope. This plugin is unapologetic-ally intended to avoid that. To me, if you want to use WPCS, use WordPress.
I appreciate the information in this, would it be possible to have a PR submitted? That would make it way easier to understand the differences, and test.
from underpin.
Done.
from underpin.
Related Issues (20)
- Taxonomy Class should not use "name" to declare taxonomy ID. HOT 1
- Add sane defaults to taxonomies and post types
- Exported Events no-longer show in admin menu HOT 1
- Make Underpin Loaders Dynamically Load-able Using a Registry
- Introduce find method in loader registry HOT 1
- Introduce Middleware API
- Reformat exporter to export to JSON
- Update Loader Registry Factory class to include an export callback
- Upgrade Underpin to Support Mozart HOT 3
- Introduce better way to normalize, and hash items
- Update documentation to specify exact location of `composer require` commands HOT 3
- Introduce Integrations API HOT 2
- Accumulators may not be compatible with PHP 8.1
- Update Dependency Processor to Cache sort order for actions
- Update the extension's readme.md & composer pkgs
- Template Trait cannot be used on classes that also have a non-static subject trait
- Add methods to make decisions easier when using Accumulator
- Update loader "add" method to return self
- Update loader registration instances to support chain-able setters
- Several bugs in v3.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from underpin.