Comments (10)
Potential solution for the machine-readable versus human-readable: Use @phpstan-param
and @phpstan-return
tags in addition to the existing @param
and @return
tags.
from wordpress-stubs.
There is room for improvement in core's source code.
That "hash-style" thing is from JavaScript. Only WordPress uses it in PHP.
This package does not alter the source code in any way, simply removes function contents.
I am open to add (rock solid) transformations!
from wordpress-stubs.
A few observations:
- Core uses type
string|array
where the parameter technically also accepts a URL query string because the parameter gets passed throughwp_parse_args()
. I think in the context of using a tool such as PHPStan or Psalm this should be treated asarray
only because nobody in their right mind actually uses a query string. - The error message from PHPStan when an incorrect type is used is not very useful if there is a large number of array elements:
Parameter #2 $args of method WP_Http::request() expects array(?'method' => string, ?'timeout' => float, ?'redirection' => int, ?'httpversion' => string, ?'user-agent' => string, ?'reject_unsafe_urls' => bool, ?'blocking' => bool, ?'headers' => array|string, ...), array('blocking' => WP_User) given.
from wordpress-stubs.
- Additional array elements that are not in the documented list are allowed by PHPStan:
( new WP_Http )->request( 'http://example.com', [
'banana' => 'yellow',
] );
[OK] No errors
from wordpress-stubs.
- Developers above 14 years should be punished for storing various data in an array
- I'm just a single person, not capable of processing a huge codebase like WordPress
from wordpress-stubs.
Developers above 14 years should be punished for storing various data in an array
PHP has object properties for more than a decade. Code could be written in a human-friendly way.
from wordpress-stubs.
PHP has object properties for more than a decade. Code could be written in a human-friendly way.
Oh yes I completely agree, these array-style arguments are a nightmare. I regret using them in some of my libraries such as Extended CPTs. This is why I started playing around with johnbillion/args
. Unfortunately we're stuck with them in WordPress core unless we decided to implement such classes.
from wordpress-stubs.
Unfortunately we're stuck with them in WordPress core
Smart people started building dirt-hiding-layers between WordPress core and project-specific code - meaning what you write and read.
dirt=techdebt
from wordpress-stubs.
Alternative: Convince PHPStan and Psalm to support this hash style notation.
from wordpress-stubs.
Alternative: Convince PHPStan and Psalm to support this hash style notation.
WordPress marches into a dead-end. Let's convince others to join :)
from wordpress-stubs.
Related Issues (20)
- Include `wp-includes/compat.php` HOT 10
- `wp_is_development_mode()` is missing from the stubs HOT 5
- wp_insert_attachment doesn't show WP_Error as possible return value HOT 5
- 6.4 new see tag HOT 9
- Tests for functionMap.php HOT 1
- Widget::widget() has never return type HOT 1
- stubs for wpdb::get_row() and wpdb::get_results() are wrong HOT 10
- Thanks HOT 1
- function wp_remote_retrieve_header expects array|WP_Error, httpReturnType given. HOT 3
- Issue with wp_get_global_stylesheet Function Not Recognized by Intelliphense HOT 1
- `add_submenu_page` parameter `$callback` should accept `''|callable` HOT 1
- function `wp_register_script` is missing `$in_footer` argument HOT 2
- Test with new nikic/php-parser HOT 2
- Why globals are not included? HOT 5
- Improve types for `WP_REST_Request` HOT 3
- Check if function exists in wordpress-stubs.php HOT 7
- WordPress 6.2 in WordPress any more HOT 7
- functionMap.php wrong HOT 4
- `WP_Filesystem_Base::dirlist` returns an array<array> HOT 6
- Ondลej says: It doesn't make sense to combine void with something else in a union type. HOT 5
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 wordpress-stubs.