Giter VIP home page Giter VIP logo

Comments (6)

szepeviktor avatar szepeviktor commented on June 19, 2024 1

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.

szepeviktor avatar szepeviktor commented on June 19, 2024

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;
	}
);

Original: https://github.com/szepeviktor/debian-server-tools/blob/master/webserver/wp-install/wordpress-autoloader.php

from underpin.

szepeviktor avatar szepeviktor commented on June 19, 2024

We currently have a mix of PSR-4 class file names and WPCS directory names.

from underpin.

szepeviktor avatar szepeviktor commented on June 19, 2024

Going further: underpin()-> may be replaced with a DI container

from underpin.

alexstandiford avatar alexstandiford commented on June 19, 2024

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.

szepeviktor avatar szepeviktor commented on June 19, 2024

Done.

from underpin.

Related Issues (20)

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.