PHP code example of alleyinteractive / alley-coding-standards
1. Go to this page and download the library: Download alleyinteractive/alley-coding-standards library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alleyinteractive / alley-coding-standards example snippets
// Passes.
echo get_block_wrapper_attributes( [ 'data-id' => $id ] );
echo get_block_wrapper_attributes( [ sanitize_key( $key ) => $value ] );
// Fails with UnsafeKey.
echo get_block_wrapper_attributes( [ $key => $value ] );
echo get_block_wrapper_attributes( [ 'data-' . $key => $value ] );
// Fails with UnverifiableKeys.
echo get_block_wrapper_attributes( array_merge( $defaults, $extra ) );
function render( $attributes ) {
return get_block_wrapper_attributes( $attributes );
}
// Passes.
add_filter( 'the_title', fn( $title ) => (string) $title );
add_filter( 'the_title', fn( mixed $title ) => (string) $title );
// Fails with ParameterTypehint.
add_filter( 'the_title', fn( string $title ) => $title );
return [
'Alley.PHP.BlockWrapperAttributes.UnsafeKey' => [ 9, 12, 15 ],
];
xml
<rule ref="Alley-Interactive">
<exclude name="Alley.PHP.BlockWrapperAttributes.UnverifiableKeys" />
</rule>
echo ...