{"id":28847,"date":"2018-10-09T15:59:46","date_gmt":"2018-10-09T13:59:46","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=28847"},"modified":"2018-10-09T15:59:46","modified_gmt":"2018-10-09T13:59:46","slug":"php-safe-and-rector","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2018\/10\/09\/php-safe-and-rector\/","title":{"rendered":"PHP Safe and Rector"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p>I came across a couple of very interesting PHP libraries today.<\/p>\n<p>The first one is\u00a0<a href=\"https:\/\/github.com\/thecodingmachine\/safe\">thecodingmachine\/safe<\/a>.\u00a0 This library wraps all PHP functions that return false on failure into another function that throws the exception instead. Think of all those <em>file_get_contents()<\/em> and <em>json_decode()<\/em> situations you had to code around.\u00a0 Not anymore.\u00a0 You can easily have them throw exceptions now.\u00a0 Read <a href=\"https:\/\/thecodingmachine.io\/introducing-safe-php\">this blog post<\/a> for more details.<\/p>\n<p>The second one is\u00a0<a href=\"https:\/\/github.com\/rectorphp\/rector\">rectorphp\/rector<\/a>.\u00a0 It is in fact mentioned in the documentation for the above library.\u00a0 Rector is a refactoring (reconstruction and upgrade) tool that can easily change large chunks of your code.\u00a0 Think of function renaming, parameter changes, and such.\u00a0 Read these blog posts for more details: <a href=\"https:\/\/www.tomasvotruba.cz\/blog\/2018\/02\/19\/rector-part-1-what-and-how\/\">part 1<\/a>, <a href=\"https:\/\/www.tomasvotruba.cz\/blog\/2018\/02\/26\/rector-part-2-maturity-of-php-ecocystem-and-founding-fathers\/\">part 2<\/a>, and <a href=\"https:\/\/www.tomasvotruba.cz\/blog\/2018\/03\/05\/rector-part-3-why-instant-upgrades\/\">part 3<\/a>.<\/p>\n<p>Very handy!<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>I came across a couple of very interesting PHP libraries today. The first one is\u00a0thecodingmachine\/safe.\u00a0 This library wraps all PHP functions that return false on failure into another function that throws the exception instead. Think of all those file_get_contents() and json_decode() situations you had to code around.\u00a0 Not anymore.\u00a0 You can easily have them throw &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2018\/10\/09\/php-safe-and-rector\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">PHP Safe and Rector<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,18,62,1334],"tags":[3069,38,1330],"keyring_services":[],"class_list":["post-28847","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","category-web-work","tag-best-practices","tag-php","tag-web-development"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":28277,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/12\/11\/rector-reconstruct-legacy-php-codebase-to-modern-standards\/","url_meta":{"origin":28847,"position":0},"title":"rector &#8211; reconstruct legacy PHP codebase to modern standards","author":"Leonid Mamchenkov","date":"December 11, 2017","format":false,"excerpt":"rector looks like an excellent tool for those days when you need to rewrite large chunks of legacy code for the modern coding standards and best practices.\u00a0 Of course, there are IDEs that can help a lot with refactoring, but they are usually complex and slow.\u00a0 Regular expressions have always\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":29074,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/12\/10\/php-password-exposed-helper-function\/","url_meta":{"origin":28847,"position":1},"title":"PHP &#8211; Password Exposed Helper Function","author":"Leonid Mamchenkov","date":"December 10, 2018","format":false,"excerpt":"Password Exposed Helper Function is a tiny PHP library that helps checking user passwords against the Have I Been P0wned website API. This is quite common new functionality on many websites and services (see GitHub, for example), which is now available as a quick composer dependency for your PHP projects.","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/12\/password-exposed.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/12\/password-exposed.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/12\/password-exposed.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/12\/password-exposed.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/12\/password-exposed.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":28349,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/01\/25\/httplug-the-http-client-abstraction-for-php\/","url_meta":{"origin":28847,"position":2},"title":"HTTPlug &#8211; The HTTP client abstraction for PHP","author":"Leonid Mamchenkov","date":"January 25, 2018","format":false,"excerpt":"HTTPlug is an HTTP client abstraction for PHP.\u00a0 Using this library you can decouple your code from the specifics of the HTTP implementation in your client of choice, and can also easily switch between different clients, like cURL, Guzzle, and so on. HTTPlug also supports pluggable functionality, so you can\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27844,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/08\/14\/secure-headers-a-php-library-for-easier-management-of-browser-security-features\/","url_meta":{"origin":28847,"position":3},"title":"Secure Headers &#8211; a PHP library for easier management of browser security features","author":"Leonid Mamchenkov","date":"August 14, 2017","format":false,"excerpt":"Modern browsers offer a variety of security mechanisms for web developers. \u00a0Unfortunately, some of these aren't so easy to manage. \u00a0One needs a deep understanding of the functionality as well as theory behind. \u00a0Secure Headers is a library that makes all that work a lot easier for PHP developers. \u00a0Here\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":29009,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/11\/23\/stack-overflow-buddy\/","url_meta":{"origin":28847,"position":4},"title":"Stack Overflow Buddy","author":"Leonid Mamchenkov","date":"November 23, 2018","format":false,"excerpt":"An innocent joke on Facebook brought in something really golden - Stack Overflow Buddy.\u00a0 It is a fun PHP library for all those of you who search for code examples on Stack Overflow and then copy-paste those into your projects. Wow, how's it work? If you're impressed, you should probably\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/11\/developer.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":29219,"url":"https:\/\/mamchenkov.net\/wordpress\/2019\/01\/14\/new-in-php-7-4\/","url_meta":{"origin":28847,"position":5},"title":"New in PHP 7.4","author":"Leonid Mamchenkov","date":"January 14, 2019","format":false,"excerpt":"\"New in PHP 7.4\" is a quick and simple introduction into changes and new features of the upcoming PHP 7.4, which is planned for release in December of 2019. In brief: Preloading (parsed source code caching)Typed propertiesImproved type varianceFFI (Foreign Function Interface) - a way to run C code from\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/28847","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=28847"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/28847\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=28847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=28847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=28847"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=28847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}